:root {
  --bg: #14101c; --panel: #241c30; --panel2: #2f2540; --ink: #f3ead7; --mute: #a99bb8;
  --accent: #e0483a; --accent2: #f2b134; --line: #4a3b5c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: 'Pixelify Sans', monospace; overflow: hidden; -webkit-tap-highlight-color: transparent; }
#bg { position: fixed; inset: 0; image-rendering: pixelated;
  background:
    radial-gradient(circle at 75% 25%, #f2d7a0 0 60px, transparent 61px),
    linear-gradient(#2a1d3d 0%, #5b2a4a 55%, #c4583a 100%);
}
#bg::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 35%;
  background:
    linear-gradient(135deg, transparent 49%, #1a1424 50%) 0 0/120px 120px repeat-x,
    linear-gradient(225deg, transparent 49%, #1a1424 50%) 60px 0/120px 120px repeat-x,
    linear-gradient(transparent 120px, #1a1424 120px);
}
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.screen.on { display: flex; }
#s-game { padding: 0; }
#game-root { position: absolute; inset: 0; }
.panel { position: relative; width: 100%; max-width: 380px; background: var(--panel); border: 4px solid var(--line);
  box-shadow: 0 0 0 4px #0b0810, 8px 8px 0 4px rgba(0,0,0,.45); padding: 24px 20px; display: flex; flex-direction: column; gap: 10px; margin: auto; }
.panel.wide { max-width: 560px; }
.logo { margin: 0; text-align: center; font-size: clamp(28px, 8vw, 44px); letter-spacing: 2px; color: var(--accent2);
  text-shadow: 3px 3px 0 var(--accent), 6px 6px 0 #0b0810; }
h2 { margin: 0 0 6px; color: var(--accent2); text-shadow: 2px 2px 0 #0b0810; }
.sub { text-align: center; margin: 0 0 10px; color: var(--mute); }
label { font-size: 14px; color: var(--mute); margin-top: 4px; }
input, select { font: inherit; font-size: 18px; padding: 10px; background: #120e18; color: var(--ink);
  border: 3px solid var(--line); outline: none; width: 100%; }
input:focus, select:focus { border-color: var(--accent2); }
.btn { font: inherit; font-size: 18px; padding: 12px 14px; cursor: pointer; color: var(--ink); background: var(--panel2);
  border: 3px solid #0b0810; box-shadow: inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 rgba(255,255,255,.1); width: 100%; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.primary { background: var(--accent); }
.btn.small { font-size: 14px; padding: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.status { text-align: center; color: var(--mute); font-size: 13px; margin: 4px 0 0; min-height: 1em; }
.clans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.clan { cursor: pointer; border: 3px solid #0b0810; background: #120e18; padding: 6px 2px; text-align: center; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.clan canvas { width: 48px; height: 48px; image-rendering: pixelated; }
.clan.sel { border-color: var(--accent2); background: var(--panel2); }
.clan.taken { opacity: .3; cursor: not-allowed; }
.clan .sw { width: 100%; height: 4px; }
.rooms { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.room { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: #120e18;
  border: 3px solid var(--line); cursor: pointer; }
.room:hover { border-color: var(--accent2); }
.room .code { color: var(--accent2); }
.empty { color: var(--mute); text-align: center; padding: 12px; border: 3px dashed var(--line); }
.share { background: #120e18; border: 3px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.code { font-size: 22px; letter-spacing: 3px; color: var(--accent2); }
.players { display: flex; flex-direction: column; gap: 6px; }
.pl { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: #120e18; border-left: 8px solid #888; }
.pl canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.pl .nm { flex: 1; }
.pl .tag { font-size: 12px; color: var(--mute); }
.off { opacity: .5; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0b0810; border: 3px solid var(--accent);
  padding: 10px 16px; max-width: 90vw; display: none; z-index: 9999; }
#toast.on { display: block; }
.host-only { display: none !important; }
.is-host .host-only { display: flex !important; }
.is-host button.host-only { display: block !important; }

.mg-title { font-size: 14px; color: var(--mute); }
.mygame { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #120e18; border: 3px solid var(--line); }
.mygame.turn { border-color: var(--accent2); }
.mygame .info { flex: 1; font-size: 13px; line-height: 1.3; }
.mygame .info b { color: var(--accent2); font-size: 16px; letter-spacing: 2px; }
.mygame .btn { width: auto; }
.badge { background: var(--accent2); color: #14101c; padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--ink); cursor: pointer; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent2); border: none; background: transparent; }
.help p { margin: 0; line-height: 1.4; font-size: 15px; }
.help b { color: var(--accent2); }
.pl select { width: auto; font-size: 13px; padding: 4px; }


.help { max-height: calc(100vh - 32px); overflow-y: auto; }
.help h3 { margin: 8px 0 0; color: var(--accent2); font-size: 18px; }
.clan-help, .unit-help { display: flex; flex-direction: column; gap: 6px; }
.ch { display: flex; gap: 10px; align-items: flex-start; background: #120e18; padding: 8px; border-left: 6px solid #888; font-size: 14px; line-height: 1.35; }
.ch canvas { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
.ch b { color: var(--ink); }
.unit-help table { width: 100%; border-collapse: collapse; font-size: 13px; }
.unit-help td, .unit-help th { padding: 3px 4px; border-bottom: 2px solid var(--line); text-align: center; }
.unit-help td:first-child, .unit-help th:first-child { text-align: left; }
.unit-help canvas { width: 24px; height: 24px; image-rendering: pixelated; vertical-align: middle; margin-right: 4px; }
.camp-intro { margin: 0; line-height: 1.4; color: var(--mute); font-size: 15px; }
.missions { display: flex; flex-direction: column; gap: 6px; }
.mission { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #120e18; border: 3px solid var(--line); cursor: pointer; }
.mission:hover { border-color: var(--accent2); }
.mission.sel { border-color: var(--accent2); background: var(--panel2); }
.mission.locked { opacity: .4; cursor: not-allowed; }
.mission .num { font-size: 22px; color: var(--accent2); width: 28px; text-align: center; }
.mission .t { flex: 1; }
.mission .st { font-size: 13px; color: var(--mute); }
.mission .done { color: #6fd896; }
.mission-detail { background: #120e18; border: 3px solid var(--accent2); padding: 12px; display: none; flex-direction: column; gap: 8px; line-height: 1.4; }
.mission-detail.on { display: flex; }
.mission-detail .obj { color: var(--accent2); }
.mission-detail .foes { font-size: 13px; color: var(--mute); }
