/* Shared look. Games may use these variables and classes. */
:root {
  --bg: #fff6e6;
  --panel: #ffffff;
  --ink: #1f2544;
  --muted: #6b7190;
  --line: #e7dcc6;
  --accent: #ffb703;
  --good: #2fbf71;
  --bad: #ff5d5d;
  --blue: #3d8bff;
  --radius: 16px;
  --bar-h: 40px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* Game area: hidden in the lobby, shown while playing, sits under the top bar */
#game { display: none; }
body[data-phase="playing"] #game {
  display: block;
  min-height: 100%;
  padding-top: var(--bar-h);
}

/* Buttons */
.fg-btn {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
  touch-action: manipulation;
  user-select: none;
}
.fg-btn:hover { filter: brightness(1.05); }
.fg-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.fg-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--ink); }
.fg-btn-ghost { background: var(--panel); }
.fg-btn-go { background: var(--good); color: #fff; }
.fg-btn-bad { background: var(--bad); color: #fff; }
.fg-btn-big { font-size: 1.3rem; padding: 16px 28px; }

/* Panels */
.fg-panel {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
  padding: 16px;
}

/* Lobby: a night-time start screen. The game's scene fills the back; the hero sits top left,
   the "Your game" card on the right and the controls bar along the bottom. On phones they stack. */
.fg-lobby {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  overflow: auto;
  color: #eef0ff;
  background: #060914;
  color-scheme: dark;
  font-family: "Nunito", var(--font);
}
body[data-phase="lobby"] .fg-lobby { display: block; }
.fg-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.fg-scene > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fg-wrap {
  position: relative; z-index: 1;
  min-height: 100%; max-width: 1500px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 22px;
  padding: clamp(16px, 3.2vh, 40px) max(18px, 2.6vw, env(safe-area-inset-right, 0px)) clamp(14px, 2.6vh, 28px) max(18px, 2.6vw, env(safe-area-inset-left, 0px));
}
.fg-cols {
  flex: 1 0 auto;
  display: grid; gap: 24px; align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 520px);
  grid-template-areas: "hero room";
}
.fg-hero { grid-area: hero; min-width: 0; }
.fg-room { grid-area: room; }
.fg-intro { min-width: 0; }
.fg-title {
  margin: 0; font-size: clamp(2.6rem, 8vw, 4.2rem); line-height: 1; color: #fff;
}
.fg-tagline { margin: 8px 0 0; color: #c9cdf0; font-size: 1.08rem; }
.fg-tagline:empty { display: none; }
.fg-how { margin: 8px 0 14px; padding-left: 20px; }
.fg-how:empty { display: none; }
.fg-how li { margin: 3px 0; }

/* the "Your game" card */
.fg-card {
  background: rgba(9, 13, 30, .8);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 2px solid rgba(214, 221, 255, .5); border-radius: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  padding: 24px 24px 20px;
}
.fg-rhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fg-rt {
  margin: 0; display: flex; align-items: center; gap: 10px; color: #fff;
  font: italic 800 2.9rem/1 "Barlow Condensed", "Arial Narrow", sans-serif; letter-spacing: .005em;
}
.fg-rt-sm { font-size: 2.35rem; }
.fg-ico { width: 1.05em; height: 1.05em; color: #ffc93c; flex: none; }
.fg-pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 1.5px solid rgba(220, 226, 255, .6); border-radius: 999px; padding: 5px 16px;
  font-weight: 800; font-size: 1.15rem; color: #fff;
}
.fg-count b, .fg-code b { color: #ffc93c; letter-spacing: .06em; }
.fg-name { display: flex; align-items: center; gap: 20px; margin-top: 18px; font-weight: 800; font-size: 1.25rem; color: #fff; }
.fg-name span { white-space: nowrap; }
.fg-name input {
  flex: 1; min-width: 0; font: inherit; font-weight: 800; font-size: 1.3rem; color: #fff;
  background: rgba(5, 8, 20, .55); border: 1.5px solid rgba(220, 226, 255, .55); border-radius: 12px; padding: 9px 18px;
}
.fg-name input:focus { outline: none; border-color: #ffc93c; box-shadow: 0 0 0 3px rgba(255, 201, 60, .25); }
.fg-hr { border: 0; height: 1px; background: rgba(206, 214, 255, .22); margin: 20px 0 18px; }
.fg-invite { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.fg-link { flex: 1; min-width: 0; margin: 0; font-size: .82rem; color: #c9cdf0; word-break: break-all; }
.fg-sub, .fg-solo { margin: 6px 0 0; font-size: .82rem; color: #9aa3d6; }

/* player tiles */
.fg-players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.fg-tile {
  --c: #3d8bff;
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 12px; border-radius: 16px;
  border: 1.5px solid color-mix(in srgb, var(--c) 60%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 24%, #0b1024), #0b1024 72%);
  animation: fg-pop .45s cubic-bezier(.2, .9, .3, 1.3) both;
}
.fg-tile:nth-child(2) { animation-delay: .06s; }
.fg-tile:nth-child(3) { animation-delay: .12s; }
.fg-tile:nth-child(4) { animation-delay: .18s; }
.fg-tile.fg-off { opacity: .45; }
.fg-ava {
  flex: none; width: 74px; height: 74px; border-radius: 14px; display: grid; place-items: center;
  font-size: 2.6rem; line-height: 1;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 55%, #000));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 4px 14px color-mix(in srgb, var(--c) 35%, transparent);
}
.fg-ava img { width: 112%; height: 112%; object-fit: contain; margin-top: 6%; display: block; pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); }
.fg-pic .fg-ava { overflow: hidden; }
.fg-tname { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.fg-tname b { font-size: 1.5rem; font-weight: 900; color: #fff; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-tname em {
  font-style: normal; font-size: .88rem; font-weight: 800; color: #e6e9ff;
  background: rgba(255, 255, 255, .14); border-radius: 999px; padding: 2px 12px;
}
.fg-me .fg-tname em { background: rgba(255, 201, 60, .2); color: #ffd86b; }
.fg-x {
  position: absolute; top: 4px; right: 6px;
  font: inherit; border: 0; background: none; color: #cfd4ff; cursor: pointer; padding: 2px 4px; font-size: 1.35rem; line-height: 1;
}
.fg-x:hover { color: var(--bad); }
.fg-x:focus-visible { outline: 2px solid #8fb6ff; border-radius: 6px; }

/* buttons in the lobby */
.fg-lobby .fg-btn { font-family: inherit; }
.fg-lobby .fg-btn:focus-visible { outline: 3px solid #8fb6ff; outline-offset: 3px; }
.fg-lobby .fg-btn-ghost {
  background: rgba(10, 14, 32, .4); color: #fff; border: 1.5px solid rgba(220, 226, 255, .55); box-shadow: none;
}
.fg-lobby .fg-btn-ghost:hover { background: rgba(255, 255, 255, .08); border-color: #fff; filter: none; }
.fg-lobby .fg-btn-ghost:active { transform: translateY(1px); box-shadow: none; }
.fg-copy { font-size: .85rem; padding: 7px 12px; white-space: nowrap; }
.fg-addbot { display: block; width: 100%; margin-top: 14px; font-size: 1.4rem; font-weight: 900; padding: 10px 16px; }
.fg-actions { display: block; }
.fg-gowrap { display: flex; flex-direction: column; align-items: center; width: 100%; }
.fg-lobby .fg-btn-go {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%;
  font-size: clamp(1.9rem, 3vw, 2.8rem); font-weight: 900; letter-spacing: -.01em; padding: 16px 24px;
  color: #11142a; background: linear-gradient(180deg, #ffdf4d, #ffb400);
  border: 2px solid #ffe98f; border-radius: 16px;
  box-shadow: 0 6px 0 #a46f00, 0 0 34px rgba(255, 196, 40, .38);
}
.fg-lobby .fg-btn-go:hover { filter: brightness(1.05); box-shadow: 0 6px 0 #a46f00, 0 0 46px rgba(255, 196, 40, .55); }
.fg-lobby .fg-btn-go:active { transform: translateY(4px); box-shadow: 0 2px 0 #a46f00, 0 0 30px rgba(255, 196, 40, .4); }
.fg-lobby .fg-btn-go:disabled { opacity: .5; box-shadow: 0 6px 0 #a46f00; }
.fg-lobby .fg-btn-go::after {      /* a gleam that sweeps across now and then */
  content: ""; position: absolute; z-index: -1; top: -20%; bottom: -20%; left: -40%; width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .65), transparent);
  transform: skewX(-18deg); animation: fg-gleam 4.5s ease-in-out 1.2s infinite;
}
.fg-btn-go:disabled::after { display: none; }
.fg-arrow { width: 1em; height: 1em; flex: none; animation: fg-nudge 1.6s ease-in-out infinite; }
/* the note under the start button: handwritten, decorative */
.fg-startnote {
  display: block; margin: 12px 0 0; text-align: center; pointer-events: none;
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive; font-weight: 600; font-size: 1.7rem; line-height: 1;
  color: #c7cbe6; transform: rotate(-2deg);
}
.fg-startnote b { font-weight: 600; }
.fg-note { margin: 10px 0 0; text-align: center; color: #c7cbe6; font-size: .95rem; }
.fg-note:empty { display: none; }

@keyframes fg-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fg-gleam { 0%, 62% { left: -40%; } 100% { left: 130%; } }
@keyframes fg-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

@media (max-width: 900px) {
  .fg-cols { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "room"; }
}
@media (max-width: 420px) {
  .fg-card { padding: 16px 14px 14px; border-radius: 20px; }
  .fg-rt { font-size: 2.1rem; }
  .fg-rt-sm { font-size: 1.7rem; }
  .fg-name { gap: 10px; }
  .fg-players { gap: 8px; }
  .fg-tile { gap: 8px; padding: 8px; }
  .fg-ava { width: 46px; height: 46px; font-size: 1.6rem; border-radius: 10px; }
  .fg-tname b { font-size: 1.05rem; }
}
/* PC screens up to 1000px tall: everything on one screen, no scrolling. The layout stays as
   designed (controls bar along the bottom) and the card tightens its spacing. */
@media (min-width: 901px) and (max-height: 1000px) {
  .fg-wrap { gap: 16px; padding-top: clamp(12px, 2.4vh, 28px); padding-bottom: clamp(12px, 2.4vh, 24px); }
  .fg-card { padding: 16px 18px 14px; }
  .fg-rt { font-size: 2.3rem; }
  .fg-rt-sm { font-size: 1.9rem; }
  .fg-pill { font-size: 1rem; padding: 3px 14px; }
  .fg-invite { margin-top: 10px; }
  .fg-name { margin-top: 10px; font-size: 1.1rem; }
  .fg-name input { font-size: 1.1rem; padding: 6px 14px; }
  .fg-hr { margin: 12px 0 10px; }
  .fg-players { margin-top: 10px; gap: 8px; }
  .fg-tile { padding: 8px; gap: 10px; }
  .fg-ava { width: 54px; height: 54px; font-size: 1.9rem; border-radius: 12px; }
  .fg-tname b { font-size: 1.25rem; }
  .fg-addbot { margin-top: 10px; padding: 6px 16px; font-size: 1.15rem; }
  .fg-lobby .fg-btn-go { font-size: clamp(1.6rem, 2.4vw, 2.1rem); padding: 10px 20px; }
  .fg-startnote { margin-top: 8px; font-size: 1.4rem; }
}
/* Short PC screens (laptops): not enough height for the bar along the bottom, so it moves under
   the hero on the left and the card takes the full height on the right. */
@media (min-width: 901px) and (max-height: 860px) {
  .fg-wrap {
    display: grid; column-gap: 24px; row-gap: 16px; align-content: stretch;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 470px);
    grid-template-rows: auto 1fr;
    grid-template-areas: "hero room" "intro room";
  }
  .fg-cols { display: contents; }
  .fg-room { align-self: start; }
  .fg-intro { grid-area: intro; align-self: end; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .fg-sub { display: none; }
  .fg-rt { font-size: 2rem; }
  .fg-rt-sm { font-size: 1.7rem; }
  .fg-hr { margin: 9px 0 8px; }
  .fg-ava { width: 46px; height: 46px; font-size: 1.6rem; border-radius: 10px; }
  .fg-tname b { font-size: 1.12rem; }
  .fg-tname em { font-size: .8rem; }
  .fg-lobby .fg-btn-go { padding: 8px 20px; font-size: 1.7rem; }
  .fg-startnote { margin-top: 6px; font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  .fg-tile, .fg-arrow, .fg-lobby .fg-btn-go::after { animation: none; }
}

/* Top bar while playing */
.fg-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--bar-h);
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 12px;
  background: var(--ink); color: #fff; font-size: .85rem;
}
body[data-phase="playing"] .fg-bar { display: flex; }
.fg-bar a { color: #cfd4ff; text-decoration: none; white-space: nowrap; }
.fg-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fg-bar .fg-spec { color: var(--accent); }
.fg-barbtn {
  font: inherit; font-size: .8rem; font-weight: 700; color: var(--ink); background: var(--accent);
  border: 0; border-radius: 8px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}

/* Toast */
.fg-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; text-align: center;
}

/* Scoreboard helper */
.fg-scores { display: flex; flex-wrap: wrap; gap: 8px; }
.fg-score {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px 3px 4px; font-weight: 700;
}
.fg-score i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.fg-score b { margin-left: 4px; }
