:root {
  --bg: #14161c;
  --panel: #1e2230;
  --ink: #e8ecf4;
  --muted: #8b93a7;
  --accent: #46d39a;
  --accent2: #5aa2ff;
  --danger: #ff5d6c;
  --line: #2c3142;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.screen { width: 100%; max-width: 820px; }
.hidden { display: none !important; }

h1 { font-size: 40px; letter-spacing: -1px; margin: 8px 0 0; }
h2 { line-height: 1.2; }
.tag { color: var(--muted); margin-top: 4px; }
a { color: var(--accent2); }

.home-copy, .content-card {
  margin-top: 28px;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.home-copy h2, .content-card h1, .content-card h2 { margin-top: 0; }
.home-copy ol { padding-left: 22px; }
.content-card { max-width: 760px; }
.content-card h2 { margin-top: 28px; }
.content-card li + li { margin-top: 8px; }
.page-nav, .site-footer {
  width: 100%;
  max-width: 820px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.page-nav { margin-bottom: 18px; }
.site-footer {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

label { display: block; margin: 14px 0; }
input {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.row { display: flex; gap: 10px; align-items: center; }
.row input { margin-top: 0; }

button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #05130d;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

.account-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px; font-size: 13px;
}
.account-bar .acct-link {
  margin-left: auto; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  text-decoration: none; font: inherit; cursor: pointer;
}
.account-bar #acctStatus .acct-name { color: var(--accent); font-weight: 600; }

/* Public room browser */
.game-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin-top: 20px; padding: 4px; border: 1px solid var(--line);
  border-radius: 10px; background: #101219;
}
.game-tab { background: transparent; color: var(--muted); }
.game-tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.35); }
.game-mode-panel {
  padding: 18px; border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 10px 10px; background: rgba(30,34,48,.55);
}
.game-mode-panel h2 { margin: 0 0 4px; font-size: 20px; }
.auth-notice {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 14px;
  align-items: center; margin: 12px 0 16px; padding: 12px 14px;
  border: 1px solid #765d25; border-radius: 8px; background: rgba(117,82,20,.16);
}
.auth-notice span { color: var(--muted); font-size: 13px; }
.auth-notice a { grid-column: 2; grid-row: 1 / span 2; }
.auth-notice.signed-in { border-color: #275d48; background: rgba(39,93,72,.16); }
.auth-notice.signed-in a { display: none; }
.room-browser { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.room-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-weight: 500;
}
.pub-toggle {
  display: flex; align-items: center; gap: 8px; margin: 10px 0;
  font-size: 14px; color: var(--ink);
}
.pub-toggle input { width: auto; margin: 0; }

/* Match-end ad slot + consent banner */
.ad-slot { width: 100%; max-width: 360px; margin: 4px auto; min-height: 60px; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 90px; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
}
.consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: var(--ink);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
.consent .consent-btns { display: flex; gap: 8px; }
.consent button { padding: 8px 14px; }

.err { color: var(--danger); min-height: 1.2em; }
.hint { color: var(--muted); font-size: 13px; }
.code, .badge {
  font-family: ui-monospace, monospace;
  letter-spacing: 2px;
  background: var(--panel);
  padding: 2px 8px;
  border-radius: 6px;
}

#playerList { list-style: none; padding: 0; }
#playerList li {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.you { color: var(--accent); }
.host-tag { color: var(--accent2); font-size: 12px; }

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.preset { margin: 0; }
.presets img {
  width: 96px; height: 64px; object-fit: cover;
  border-radius: 6px; cursor: pointer; border: 2px solid transparent;
  display: block;
}
.presets img.sel { border-color: var(--accent); }
.preset figcaption { margin-top: 3px; font-size: 11px; color: var(--muted); text-align: center; }

#hud {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.badge.hider { background: #1d3b2e; color: var(--accent); }
.badge.seeker { background: #2a2140; color: #c9a6ff; }
.timer { font-family: ui-monospace, monospace; font-size: 22px; margin-left: auto; }

#stage { position: relative; width: 768px; max-width: 100%; }
#view {
  width: 100%;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}

/* Corner minimap */
.minimap {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 168px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  background: #000;
  pointer-events: none;
}

/* Floating zoom / view controls */
#viewControls {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 17, 24, 0.82);
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
#viewControls button {
  padding: 4px 10px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1;
}
#zoomLabel {
  min-width: 34px;
  text-align: center;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--muted);
}
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 22px; font-weight: 600;
  background: rgba(10, 12, 18, 0.82);
  border-radius: 8px;
  flex-direction: column; gap: 8px;
}

#paintPanel {
  display: flex; gap: 24px; margin-top: 14px; align-items: flex-start;
  flex-wrap: wrap;
}
.paint-col h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
#grid {
  display: grid;
  grid-template-columns: repeat(6, 26px);
  grid-template-rows: repeat(6, 26px);
  gap: 2px; background: var(--line); padding: 2px; border-radius: 6px;
}
#grid div { width: 26px; height: 26px; cursor: pointer; }
#palette {
  display: grid; grid-template-columns: repeat(8, 22px); gap: 4px;
  max-width: 212px;
}
#palette div {
  width: 22px; height: 22px; border-radius: 4px; cursor: pointer;
  border: 2px solid transparent;
}
#palette div.sel { border-color: #fff; box-shadow: 0 0 0 1px #000; }
.picker {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 13px; color: var(--muted);
}
.picker input[type="color"] {
  width: 34px; height: 26px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: none; cursor: pointer;
}

/* Seeker skin picker */
#lobbySkinSection { margin-top: 18px; }
#lobbySkinSection h3 { margin: 0 0 2px; }
.skin-picker {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
#skinPanel {
  margin: 10px 0 4px;
  background: rgba(15, 17, 24, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.skin-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 72px; padding: 8px 6px;
  background: var(--panel); color: var(--ink);
  border: 2px solid var(--line); border-radius: 8px;
  font-size: 12px; font-weight: 500; cursor: pointer;
}
.skin-opt .skin-pv {
  width: 44px; height: 44px; image-rendering: pixelated;
  background: #1a2740; border-radius: 6px;
}
.skin-opt.sel { border-color: var(--accent); }
.skin-opt.locked { opacity: 0.6; cursor: not-allowed; }
.skin-opt.deny { animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Controls legend */
.legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 14px; font-size: 13px; color: var(--muted);
}
.legend kbd {
  font-family: ui-monospace, monospace;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink);
  font-size: 12px;
}

/* ---- Touch / mobile ---------------------------------------------------- */

/* Mobile-only affordances are hidden until JS flags a coarse pointer. */
.touch-only, .touch-legend { display: none; }
body.touch .touch-only { display: inline-flex; }
body.touch .touch-legend { display: inline; }

/* Capture touches on the map instead of scrolling the page. */
#view { touch-action: none; }

.overlay-actions { gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Big thumb-reachable Fire / Paint buttons floated over the stage. */
.stage-action {
  position: absolute;
  right: 14px;
  bottom: 64px; /* clear of the view-controls bar at the stage bottom */
  z-index: 5;
  padding: 16px 26px;
  font-size: 16px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  opacity: 0.96;
}
.stage-action.fire { background: var(--danger); color: #fff; }
.stage-action.active { background: var(--accent2); color: #04122b; }

/* ---- Mobile portrait --------------------------------------------------- */
@media (max-width: 760px) {
  body { padding: 10px 8px; justify-content: flex-start; }
  h1 { font-size: 30px; }
  .screen { max-width: 100%; }
  #hud { gap: 8px; margin-bottom: 8px; }
  .timer { font-size: 18px; }
  #stage { width: 100%; }

  /* Paint grid sits BESIDE the palette (not beneath it) on mobile. The first
     column is width-capped so its hint text wraps instead of starving the
     palette column. */
  #paintPanel { flex-wrap: nowrap; gap: 12px; align-items: flex-start; }
  .paint-col:first-child { flex: 0 0 auto; width: min(44vw, 190px); }
  .paint-col:last-child { flex: 1 1 auto; min-width: 0; }
  #grid {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    aspect-ratio: 1;
  }
  #grid div { width: 100%; height: 100%; }
  #palette {
    grid-template-columns: repeat(6, 1fr);
    width: 100%;
    max-width: none;
  }
  #palette div { width: 100%; height: auto; aspect-ratio: 1; }

  /* Roomier tap targets. */
  button { padding: 12px 16px; }
  #viewControls button { padding: 8px 12px; font-size: 15px; }
  .minimap { width: 120px; }
  .game-mode-panel .row { align-items: stretch; flex-direction: column; }
  .auth-notice { grid-template-columns: 1fr; }
  .auth-notice a { grid-column: 1; grid-row: auto; margin-top: 6px; }
}

/* ---- Mobile landscape: map and paint panel side by side ---------------- */
@media (orientation: landscape) and (max-height: 600px) {
  body { padding: 6px 8px; justify-content: flex-start; }
  #game { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 12px; }
  #hud { flex: 1 1 100%; margin-bottom: 2px; gap: 8px; }
  #skinPanel { flex: 1 1 100%; }
  #stage { flex: 0 1 auto; width: auto; display: flex; justify-content: center; }
  #view { width: auto; height: auto; max-height: 84vh; max-width: 60vw; }
  .legend { display: none; }
  #controlsHint { flex-basis: 100%; }

  #paintPanel { flex: 1 1 240px; flex-wrap: nowrap; gap: 10px; margin-top: 0; }
  .paint-col:first-child { flex: 0 0 auto; width: min(24vh, 150px); }
  .paint-col:last-child { flex: 1 1 auto; min-width: 0; }
  #grid { width: 100%; aspect-ratio: 1; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); }
  #grid div { width: 100%; height: 100%; }
  #palette { grid-template-columns: repeat(8, 1fr); width: 100%; max-width: none; }
  #palette div { width: 100%; height: auto; aspect-ratio: 1; }
}
