/* Fangeon — 16-bit dungeon crawl. Host: fog-of-war map + spotted alarms.
   Phone: a digital GameBoy — screen up top, stick & buttons below. */

/* ===================== HOST ===================== */
.fg-stage { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }

.fg-top {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8px 18px;
}
.fg-round { font-family: var(--display); font-size: 18px; color: var(--purple); }
.fg-clock {
  font-family: var(--display); font-size: 30px; color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.fg-clock.is-low { color: var(--red); animation: timerPulse 0.8s ease-in-out infinite; }
.fg-vamptag { font-weight: 900; color: hsl(var(--hue, 300), 90%, 70%); }

.fg-main { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 0 14px 12px; }
.fg-mapwrap {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #07030e;
  border: 3px solid var(--card2);
  border-radius: var(--r-md);
  overflow: hidden;
}
.fg-map { image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; max-height: 100%; }

.fg-side { width: 250px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.fg-status { display: flex; flex-direction: column; gap: 5px; }
.fg-stat-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--r-sm);
  padding: 5px 10px; font-size: 13px;
  border-left: 4px solid hsl(var(--hue, 280), 85%, 60%);
}
.fg-stat-row.is-vamp { border-left-color: var(--red); background: #2a0d18; }
.fg-stat-name { font-weight: 900; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-stat-tag { font-size: 12px; }
.fg-stat-pts { font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; }

.fg-feed { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.fg-feed-line {
  background: rgba(36, 16, 64, 0.6); border-radius: var(--r-sm);
  padding: 5px 10px; font-size: 12.5px; font-weight: 700;
  animation: rowPop 0.3s ease backwards;
}
.fg-feed-line.is-kill { border-left: 3px solid var(--red); }
.fg-feed-line.is-good { border-left: 3px solid var(--green); }

/* vampire-spotted: zoom inset + red pulsing edges + shake */
.fg-focus {
  position: absolute; right: 280px; bottom: 26px;
  background: #07030e; border: 3px solid var(--red);
  border-radius: var(--r-md); padding: 8px;
  box-shadow: 0 0 34px rgba(255, 59, 59, 0.55);
  animation: fgFocusPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 5;
}
.fg-focus.is-hidden { display: none; }
.fg-focus-label {
  font-family: var(--display); font-size: 13px; color: var(--red);
  text-align: center; margin-bottom: 6px;
  animation: fadePulse 0.6s infinite;
}
.fg-focus-canvas { display: block; width: 300px; image-rendering: pixelated; }
@keyframes fgFocusPop { from { transform: scale(0.6); opacity: 0; } }

.fg-vignette { position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0; transition: opacity 0.25s ease; }
.game-fangeon .is-alarm .fg-vignette,
.is-alarm .fg-vignette {
  opacity: 1;
  box-shadow: inset 0 0 130px 40px rgba(255, 30, 40, 0.55);
  animation: fgAlarm 0.7s ease-in-out infinite;
}
@keyframes fgAlarm {
  0%, 100% { box-shadow: inset 0 0 110px 30px rgba(255, 30, 40, 0.4); }
  50% { box-shadow: inset 0 0 170px 62px rgba(255, 30, 40, 0.72); }
}
.is-alarm .fg-mapwrap { border-color: var(--red); }

/* round brief + results (host) */
.fg-brief { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px; }
.fg-brief-round { font-family: var(--display); color: var(--purple); letter-spacing: 0.2em; }
.fg-brief-moon { font-size: 74px; animation: fgMoon 3s ease-in-out infinite; }
@keyframes fgMoon { 50% { transform: translateY(-10px); } }
.fg-brief-title { font-family: var(--display); font-size: clamp(26px, 4.5vw, 44px); color: var(--red); }
.fg-brief-name { display: flex; align-items: center; gap: 14px; font-family: var(--display); font-size: clamp(24px, 4vw, 40px); color: hsl(var(--hue, 300), 90%, 70%); }
.fg-brief-sub { color: var(--ink-dim); font-weight: 700; max-width: 560px; }

.fg-result { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; }
.fg-result-head { font-family: var(--display); font-size: clamp(22px, 4vw, 36px); color: var(--yellow); }
.fg-result-sub { color: var(--ink-dim); font-weight: 700; }
.fg-result-next { color: var(--ink-dim); font-weight: 700; animation: fadePulse 1.6s infinite; }

/* ===================== PHONE (GameBoy) ===================== */
/* The whole handheld is a CONTROLLER, never a document: nothing scrolls, no
   pinch-zoom, no pull-to-refresh. Without this a drag on the thumbstick gets
   stolen by the page scroller and the player can't move at all. */
.pgame-fangeon {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}
.fgp {
  flex: 1;
  height: 100%; min-height: 0;
  display: flex; flex-direction: column;
  background: linear-gradient(170deg, #b9a8d8 0%, #9c88c4 55%, #8672b0 100%);
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  gap: 8px;
  user-select: none; -webkit-user-select: none;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}
.fgp.is-vamp { background: linear-gradient(170deg, #5c1030 0%, #400a22 55%, #2c0616 100%); }

/* The SCREEN yields space to the control deck — the deck is fixed-size and
   must always be fully reachable, so the screen shrinks (keeping 13:9) to fit
   whatever height is left. */
.fgp-screenwrap {
  background: #241040;
  border-radius: 14px 14px 26px 14px;
  padding: 8px 12px 12px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35), 0 6px 0 rgba(0, 0, 0, 0.25);
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.fgp-bezel-label {
  text-align: center; font-weight: 900; letter-spacing: 0.2em;
  font-size: 10px; color: rgba(244, 238, 255, 0.5);
  padding-bottom: 5px;
}
.fgp-screen {
  position: relative;
  background: #0a0612;
  border: 3px solid #07030e;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 13 / 9;
  flex: 1 1 auto; min-height: 0;
  width: auto; max-width: 100%;
  margin: 0 auto;
}
.fgp-canvas {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.fgp-hud {
  position: absolute; top: 3px; left: 6px; right: 6px;
  font-size: 12px; font-weight: 900; letter-spacing: 0.04em;
  color: #fff; text-shadow: 0 1px 0 #000, 0 0 4px #000;
  pointer-events: none; white-space: nowrap; overflow: hidden;
}
.fgp-minimap {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  border: 2px solid var(--green); border-radius: 6px;
  image-rendering: pixelated;
  width: 62%;
}
.fgp-minimap.is-hidden { display: none; }
.fgp-toast {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(7, 3, 14, 0.88); border: 1.5px solid var(--yellow);
  color: var(--yellow); border-radius: 8px;
  padding: 4px 10px; font-size: 11.5px; font-weight: 900;
  white-space: nowrap; max-width: 94%; overflow: hidden; text-overflow: ellipsis;
}
.fgp-toast.is-hidden { display: none; }
.fgp-overlay {
  position: absolute; inset: 0;
  background: rgba(7, 3, 14, 0.82);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 12px;
}
.fgp-overlay.is-hidden { display: none; }
.fgp-over-big { font-family: var(--display); font-size: 22px; color: var(--red); }
.fgp-over-big.is-good { color: var(--green); }
.fgp-over-sub { font-size: 13px; font-weight: 700; color: var(--ink-dim); }

/* taking damage: the screen slams red for a beat */
.fgp-hurtflash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 40, 50, 0.15) 30%, rgba(255, 20, 32, 0.75) 100%);
  opacity: 0;
}
.fgp-hurtflash.is-on { animation: fgpHurt 0.42s ease-out; }
@keyframes fgpHurt {
  0% { opacity: 1; }
  55% { opacity: 0.55; }
  100% { opacity: 0; }
}

.fgp-alarmframe { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.fgp.is-alarm .fgp-alarmframe {
  opacity: 1;
  box-shadow: inset 0 0 34px 10px rgba(255, 30, 40, 0.65);
  animation: fgAlarm 0.6s ease-in-out infinite;
}
.fgp.is-alarm .fgp-screen { border-color: var(--red); }

/* control deck */
.fgp-deck {
  flex: 0 0 auto;          /* never squeezed — the controls must stay reachable */
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.fgp-deck-left { flex: 1; display: flex; align-items: center; justify-content: center; }
.fgp-deck-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; }
.fgp-deck-right { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; }

.fgp-stick {
  width: clamp(104px, 34vw, 150px); height: clamp(104px, 34vw, 150px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #241040, #17092e 70%);
  border: 3px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.5), 0 4px 0 rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.fgp-thumb {
  width: 44%; height: 44%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #6b5a86, #3a2a58);
  border: 3px solid #241040;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.fgp-ab {
  width: clamp(56px, 17vw, 76px); height: clamp(56px, 17vw, 76px);
  border-radius: 50%; border: 0;
  font-family: var(--display); font-size: 22px; color: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4);
  touch-action: none;
}
.fgp-ab.is-a { background: radial-gradient(circle at 36% 30%, #ff5bab, #c21b6e); margin-top: -18px; }
.fgp-ab.is-b { background: radial-gradient(circle at 36% 30%, #37e9ff, #0d9cc2); margin-top: 18px; color: #06333f; }
.fgp-ab.is-down { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.fgp.is-vamp .fgp-ab.is-a { background: radial-gradient(circle at 36% 30%, #ff4b4b, #8e1030); }

.fgp-items { display: flex; flex-direction: column; gap: 6px; }
.fgp-item {
  border: 0; border-radius: 10px;
  background: #241040; color: #fff;
  font-size: 14px; font-weight: 900;
  padding: 7px 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; gap: 5px;
}
.fgp-item b { font-size: 12px; color: var(--yellow); }
.fgp-item:disabled { opacity: 0.45; }
.fgp-item:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.fgp-item.is-map { font-size: 16px; padding: 6px 12px; }

/* keyboard players: little keycaps on the buttons + a hint strip, so desktop
   folks discover WASD/SPACE without anyone having to explain it */
.fgp-kbhint { display: none; }
.fgp.is-kb .fgp-kbhint {
  display: block; text-align: center;
  font-size: 11px; font-weight: 900; letter-spacing: 0.03em;
  color: rgba(36, 16, 64, 0.62);
  padding: 2px 6px 4px;
}
.fgp.is-kb.is-vamp .fgp-kbhint { color: rgba(244, 238, 255, 0.55); }
.fgp.is-kb .fgp-ab, .fgp.is-kb .fgp-item { position: relative; }
.fgp.is-kb .fgp-ab[data-key]::after,
.fgp.is-kb .fgp-item[data-key]::after {
  content: attr(data-key);
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  background: rgba(7, 3, 14, 0.9); color: #cfc4e8;
  border: 1px solid rgba(207, 196, 232, 0.35); border-radius: 4px;
  font-family: var(--body); font-size: 8.5px; font-weight: 900; letter-spacing: 0.06em;
  padding: 1px 4px; line-height: 1.25; white-space: nowrap;
  pointer-events: none;
}
.fgp.is-kb .fgp-item[data-key]::after { bottom: -6px; font-size: 8px; }
/* the item buttons stack vertically — open the gaps so each keycap has room
   to hang below its own button instead of landing on the next one */
.fgp.is-kb .fgp-items { gap: 18px; }
.fgp.is-kb .fgp-deck-mid { gap: 18px; }

/* phone brief / result cards */
.fgp-brief {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 22px;
}
.fgp-brief.is-vamp { background: radial-gradient(600px 400px at 50% 30%, rgba(142, 16, 48, 0.5), transparent 70%); }
.fgp-brief-emoji { font-size: 54px; }
.fgp-brief-title { font-family: var(--display); font-size: 21px; color: var(--yellow); }
.fgp-brief.is-vamp .fgp-brief-title { color: var(--red); }
.fgp-brief-sub { color: var(--ink-dim); font-weight: 700; font-size: 14px; max-width: 340px; }

/* short screens: shrink the deck before the screen */
@media (max-height: 620px) {
  .fgp-stick { width: 92px; height: 92px; }
  .fgp-ab { width: 52px; height: 52px; font-size: 18px; }
  .fgp-item { font-size: 12px; padding: 5px 9px; }
}

/* ===================== ROOM EDITOR ===================== */
.rooms { padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; width: 100%; }
.rooms-top { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.rooms-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.rooms-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.rooms-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--r-md); padding: 8px 14px;
}
.rooms-item-name { font-weight: 900; flex: 1; }
.rooms-item .btn { padding: 7px 12px; font-size: 13px; }

.rooms-editor { background: var(--card); border: 2px solid var(--purple); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.rooms-editor.is-hidden { display: none; }
.rooms-editrow { display: flex; align-items: center; gap: 10px; }
.rooms-label { font-weight: 900; font-size: 12px; letter-spacing: 0.12em; color: var(--ink-dim); }
.rooms-name {
  flex: 1; background: var(--bg1); border: 2px solid var(--card2); border-radius: var(--r-sm);
  color: var(--ink); font-weight: 900; font-size: 16px; padding: 8px 12px;
}
.rooms-palette { display: flex; gap: 6px; flex-wrap: wrap; }
.rooms-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--bg1); border: 2px solid transparent; border-radius: var(--r-sm);
  padding: 6px 8px; cursor: pointer; color: var(--ink);
}
.rooms-swatch.is-sel { border-color: var(--green); background: var(--card2); }
.rooms-swatch-tile {
  width: 28px; height: 28px;
  background-size: cover; image-rendering: pixelated;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.rooms-swatch-name { font-size: 10px; font-weight: 900; }
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 1px;
  background: #07030e; border: 3px solid #07030e; border-radius: 6px;
  touch-action: none;
  max-width: 560px;
}
.rooms-cell {
  aspect-ratio: 1;
  background-size: cover; image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(10px, 2.6vw, 18px);
  cursor: crosshair;
}
.rooms-hint { color: var(--ink-dim); font-size: 13px; font-weight: 700; }
