@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;600;700;800&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg-a: #ffe7d4;
  --bg-b: #fff8f2;
  --bg-c: #d7f7f3;
  --ink: #17203c;
  --muted: #4f5f93;
  --line: #aeb8e7;
  --card: rgba(255, 255, 255, 0.92);
  --accent: #06b993;
  --accent-2: #ff6b2d;
  --accent-3: #ff5b8a;
  --good: #119f73;
  --bad: #d63f6a;
  --shadow: 0 18px 42px rgba(41, 56, 111, 0.18);
  --shadow-soft: 0 8px 20px rgba(52, 67, 126, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  background:
    radial-gradient(760px 460px at 10% -10%, #ffaf746e, transparent 58%),
    radial-gradient(820px 560px at 90% 112%, #72efe08c, transparent 62%),
    linear-gradient(145deg, var(--bg-a) 0%, var(--bg-b) 44%, var(--bg-c) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(29, 56, 121, .09) 1px, transparent 1px),
    linear-gradient(115deg, rgba(255,255,255,.24), rgba(255,255,255,0));
  background-size: 22px 22px, 100% 100%;
  opacity: .26;
}

.app, .hub {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 28px);
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(1.95rem, 3.3vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: .15px;
}

h2, h3 { margin: 0 0 10px; }
p { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #aab7ea;
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.98), rgba(236, 244, 255, 0.96));
  color: #24335f;
  text-decoration: none;
  font-weight: 700;
  font-size: .98rem;
  box-shadow: var(--shadow-soft);
}

.panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--card), rgba(244, 248, 255, 0.95)),
    linear-gradient(130deg, rgba(255,255,255,.8), rgba(235,245,255,.75));
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.controls-row {
  align-items: center;
}

.controls-row .action-btn {
  min-width: 148px;
}

.controls-row .badge {
  font-size: .95rem;
}

.lobby-row label {
  min-width: 180px;
  flex: 1 1 220px;
}

.field-code {
  flex: 0 1 220px;
  text-transform: uppercase;
  letter-spacing: .8px;
  font-weight: 700;
}

.field-name {
  flex: 1 1 240px;
}

.action-btn {
  min-height: 52px;
  padding-inline: 20px;
}

label {
  display: grid;
  gap: 5px;
  color: #3f4a77;
  font-size: .92rem;
  font-weight: 600;
}

input, select, button, textarea {
  min-height: 46px;
  border-radius: 13px;
  border: 1px solid #b3c0ec;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

input::placeholder { color: #8f98b8; }

button {
  cursor: pointer;
  font-weight: 700;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease, border-color .12s ease;
  box-shadow: 0 6px 14px rgba(62, 79, 141, 0.14);
}

button:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 20px rgba(52, 70, 133, 0.2);
}
button:active { transform: translateY(1px); }

button.cta {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(140deg, #05b58f, #26cfad 50%, #41ddbb 100%);
  box-shadow: 0 10px 22px rgba(18, 167, 129, 0.28);
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #1e57d8;
  outline-offset: 2px;
}

.small {
  color: #42538c;
  font-size: .98rem;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 14px;
  margin-top: 10px;
}

.clue {
  min-height: 260px;
  border: 1px solid #b8c7ee;
  border-radius: 18px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(170deg, rgba(255, 255, 255, .97), rgba(232, 245, 255, .95));
}

.host-clue {
  min-height: 340px;
}

.host-backdrop {
  position: absolute;
  inset: -20%;
  filter: blur(18px);
  opacity: .95;
  animation: sway 15s linear infinite;
}

.host-headline {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.host-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  border: 1px solid rgba(88, 105, 171, .35);
  background: linear-gradient(160deg, #ffffff, #deedff);
  box-shadow: var(--shadow-soft);
}

.points {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: .92rem;
  font-weight: 800;
}

.text {
  margin-top: 10px;
  font-size: clamp(1.2rem, 2.6vw, 2.3rem);
  line-height: 1.2;
  font-weight: 700;
  color: #252b45;
  text-wrap: balance;
  position: relative;
  z-index: 1;
}

.host-text {
  font-size: clamp(1.55rem, 3.2vw, 3rem);
  letter-spacing: .15px;
}

.player-clue {
  min-height: 200px;
  margin-top: 10px;
}

.scenario-media {
  margin: 12px 0 0;
  border: 1px solid #bcc7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #f8faff;
  position: relative;
  z-index: 1;
}

.scenario-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.img-credit {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.img-credit a {
  color: #2f5cc8;
}

.join-url {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: 'Space Grotesk', monospace;
  font-size: .84rem;
}

.qr-panel {
  width: min(240px, 100%);
  text-align: center;
}

.qr-panel canvas {
  display: block;
  margin: 8px auto;
  border: 1px solid #c3cbeb;
  border-radius: 10px;
  background: #fff;
}

.qr-panel img {
  display: block;
  width: 200px;
  height: 200px;
  margin: 8px auto;
  border: 1px solid #c3cbeb;
  border-radius: 10px;
  background: #fff;
}

.qr-in-clue {
  margin-top: 12px;
  border: 1px solid #b4c2eb;
  border-radius: 12px;
  background: linear-gradient(165deg, #ffffff, #eaf4ff);
  padding: 14px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.qr-in-clue img {
  display: block;
  width: min(220px, 100%);
  height: auto;
  margin: 8px auto;
  border: 1px solid #c3cbeb;
  border-radius: 10px;
  background: #fff;
}

.review {
  margin-top: 10px;
  border: 1px solid #c4b7f3;
  border-radius: 14px;
  background: linear-gradient(165deg, #ffffff, #f8efff);
  padding: 14px;
  position: relative;
  z-index: 1;
}

.review h3 {
  margin-bottom: 8px;
}

.review #reviewItems {
  display: grid;
  gap: 6px;
  font-size: 1rem;
  line-height: 1.45;
}

.log {
  margin-top: 10px;
  color: #42517f;
  min-height: 56px;
  position: relative;
  z-index: 1;
  font-size: 1rem;
  font-weight: 600;
}

.state-strip {
  margin-top: 8px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .2px;
  border: 1px solid #aebceb;
  background: #f4f8ff;
  color: #2e3f73;
}

.state-pill.state-prestart {
  background: #eff4ff;
  border-color: #bac8ee;
}

.state-pill.state-live {
  background: #e7fff9;
  border-color: #7de3c3;
  color: #0d6f58;
}

.state-pill.state-answering {
  background: #fff2df;
  border-color: #ffc889;
  color: #8d4f16;
}

.state-pill.state-review {
  background: #fdf0ff;
  border-color: #ebbcff;
  color: #74248c;
}

.conn-banner {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid #efb3b0;
  background: #fff1f1;
  color: #8a2625;
  padding: 10px 12px;
  font-size: .95rem;
  font-weight: 700;
}

.conn-banner.success {
  border-color: #a6e4d4;
  background: #ecfff7;
  color: #0f7a60;
}

.join-gate h3 {
  margin-bottom: 8px;
}

.join-gate .small {
  margin-top: 8px;
}

.action-hint {
  margin-top: 8px;
  min-height: 1.4em;
  font-size: 1rem;
  font-weight: 700;
  color: #2f4279;
}

.timer {
  font-family: 'Space Grotesk', monospace;
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: .4px;
}

.phase-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.phase-step {
  border-radius: 10px;
  border: 1px solid #b9c4ea;
  text-align: center;
  padding: 6px;
  background: #f9fbff;
  color: #516097;
  font-size: .9rem;
  font-weight: 700;
}

.phase-step.active {
  border-color: #ffbb75;
  background: linear-gradient(180deg, #fff2e1, #ffe2c2);
  color: #9a5622;
}

.phase-step.done {
  border-color: #9eb4e7;
  color: #36508f;
}

.players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.host-view .players {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.player {
  border: 1px solid #afbee9;
  border-radius: 12px;
  background: linear-gradient(160deg, #ffffff, #e9f1ff);
  padding: 10px;
}

.player button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(140deg, #4b6bc5, #6280d2);
  color: #ffffff;
}

#buzz {
  font-size: clamp(1.5rem, 4.8vw, 2.6rem) !important;
  min-height: 84px !important;
  letter-spacing: .7px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 20;
  background: rgba(45, 53, 88, .35);
}
.modal.show { display: grid; }
.modal .box { width: min(560px, 92vw); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  border-radius: 16px;
  border: 1px solid #bcc6e8;
  padding: 18px;
  background: linear-gradient(165deg, #ffffff, #edf3ff);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

.good { color: var(--good); }
.bad { color: var(--bad); }
.hidden { display: none !important; }

.host-clue.phase-0 .host-backdrop { background: radial-gradient(circle at 25% 20%, rgba(74,196,255,.34), transparent 58%); }
.host-clue.phase-1 .host-backdrop { background: radial-gradient(circle at 55% 18%, rgba(57,235,188,.34), transparent 58%); }
.host-clue.phase-2 .host-backdrop { background: radial-gradient(circle at 76% 22%, rgba(255,214,105,.33), transparent 58%); }
.host-clue.phase-3 .host-backdrop { background: radial-gradient(circle at 37% 18%, rgba(255,152,89,.35), transparent 60%); }
.host-clue.phase-4 .host-backdrop { background: radial-gradient(circle at 48% 16%, rgba(255,92,130,.36), transparent 62%); }

@keyframes sway {
  0% { transform: translate3d(-6%, 0, 0) scale(1); }
  50% { transform: translate3d(7%, -4%, 0) scale(1.06); }
  100% { transform: translate3d(-6%, 0, 0) scale(1); }
}

@media (max-width: 980px) {
  .top {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls-row .action-btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .lobby-row .action-btn {
    width: 100%;
  }

  .answer-row #answer {
    flex: 1 1 100%;
  }

  .answer-row #submit {
    width: 100%;
  }

  .grid { grid-template-columns: 1fr; }
  .players, .host-view .players { grid-template-columns: 1fr; }
  .host-text { font-size: clamp(1.4rem, 6.2vw, 2.1rem); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
