:root {
  --yellow: #f8d400;
  --yellow-2: #ffe74a;
  --red: #ef1c27;
  --red-dark: #a60d17;
  --ink: #1f1814;
  --paper: #fff9d8;
  --cream: #fff4b3;
  --muted: #6f5c47;
  --shadow: 0 16px 50px rgba(49, 14, 7, .22);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    linear-gradient(122deg, transparent 0 72%, rgba(239,28,39,.12) 72% 76%, transparent 76%),
    var(--yellow);
  color: var(--ink);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

#app { min-height: 100vh; }

.page { min-height: 100vh; padding: 24px; }
.shell { width: min(1180px, 100%); margin: 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: clamp(26px, 4vw, 54px);
  transform: skew(-7deg);
}
.brand.small { font-size: 28px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red); color: var(--yellow);
  font-size: 22px; transform: skew(7deg);
}

.home-grid {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr);
  gap: 36px;
  align-items: center;
}
.cover-wrap { position: relative; }
.cover-wrap::before {
  content: ""; position: absolute; inset: -16px 18px 18px -16px;
  background: var(--red); transform: rotate(-2deg); z-index: 0;
}
.cover {
  display: block; width: min(100%, 500px); aspect-ratio: 617/965; object-fit: cover;
  position: relative; z-index: 1; box-shadow: var(--shadow); border: 3px solid var(--ink);
}

.home-panel {
  background: rgba(255,249,216,.94);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 54px);
  position: relative;
  overflow: hidden;
}
.home-panel::after {
  content: ""; position: absolute; width: 220px; height: 40px; background: var(--red);
  right: -60px; top: 32px; transform: rotate(18deg);
}
.kicker { color: var(--red); font-weight: 1000; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(42px, 7vw, 82px); line-height: .92; margin-bottom: 18px; letter-spacing: -.04em; text-transform: uppercase; }
h2 { font-size: clamp(28px, 4vw, 46px); line-height: 1; text-transform: uppercase; }
h3 { font-size: 20px; text-transform: uppercase; letter-spacing: .05em; }
.lede { font-size: 20px; line-height: 1.45; max-width: 680px; }

.form-grid { display: grid; gap: 14px; margin-top: 28px; }
.field { display: grid; gap: 6px; }
label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
input, select {
  width: 100%;
  border: 2px solid var(--ink);
  background: #fffdf1;
  color: var(--ink);
  padding: 13px 14px;
  min-height: 48px;
  outline: none;
  border-radius: 0;
}
input:focus, select:focus { box-shadow: 0 0 0 4px rgba(239,28,39,.18); border-color: var(--red); }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; color: var(--muted); margin: 20px 0; font-weight: 800; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; height: 2px; background: rgba(31,24,20,.2); }

.btn {
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--yellow);
  min-height: 48px;
  padding: 12px 18px;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .06em;
  box-shadow: 5px 5px 0 var(--red);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 7px 7px 0 var(--red); }
.btn:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--red); }
.btn.secondary { background: var(--yellow); color: var(--ink); box-shadow: 5px 5px 0 rgba(31,24,20,.18); }
.btn.red { background: var(--red); color: #fff; box-shadow: 5px 5px 0 var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 12px; box-shadow: 3px 3px 0 rgba(31,24,20,.2); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.age-note { margin-top: 24px; font-size: 13px; line-height: 1.4; color: var(--muted); }

.topbar {
  display: flex; justify-content: space-between; gap: 20px; align-items: center;
  background: var(--paper); border: 3px solid var(--ink); padding: 14px 18px; box-shadow: 7px 7px 0 var(--red);
  margin-bottom: 26px;
}
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.room-pill, .round-pill {
  border: 2px solid var(--ink); padding: 8px 12px; font-weight: 1000; text-transform: uppercase; background: var(--yellow);
}
.connection-dot { width: 10px; height: 10px; border-radius: 50%; background: #46a049; display: inline-block; }
.connection-dot.off { background: var(--red); }

.panel {
  background: var(--paper); border: 3px solid var(--ink); box-shadow: var(--shadow); padding: clamp(18px, 3vw, 34px);
}
.lobby-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 24px; align-items: start; }
.party-list { display: grid; gap: 10px; margin: 18px 0 0; }
.party-row {
  display: grid; grid-template-columns: 44px 1fr auto auto; gap: 12px; align-items: center;
  border: 2px solid var(--ink); background: #fffdf1; padding: 10px;
}
.seat { display: grid; place-items: center; width: 34px; height: 34px; background: var(--red); color: white; font-weight: 1000; }
.status { font-size: 12px; text-transform: uppercase; font-weight: 900; color: #3f7c3e; }
.status.off { color: var(--red); }
.host-tag, .leader-tag { font-size: 11px; font-weight: 1000; text-transform: uppercase; background: var(--yellow); border: 1px solid var(--ink); padding: 4px 7px; }

.settings-stack { display: grid; gap: 18px; }
.code-box { background: var(--red); color: white; border: 3px solid var(--ink); padding: 18px; text-align: center; }
.code-box strong { display: block; font-size: clamp(38px, 7vw, 64px); letter-spacing: .12em; line-height: 1; }
.code-box span { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }

.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.game-main { display: grid; gap: 20px; }
.scenario-card {
  background: var(--red); color: white; border: 4px solid var(--ink); box-shadow: 9px 9px 0 rgba(31,24,20,.28);
  padding: clamp(24px, 5vw, 52px); min-height: 260px; display: grid; align-content: center; position: relative; overflow: hidden;
}
.scenario-card::before, .scenario-card::after { content: ""; position: absolute; width: 55%; height: 24px; background: var(--yellow); opacity: .95; transform: rotate(66deg); }
.scenario-card::before { left: -26%; top: 15%; }
.scenario-card::after { right: -30%; bottom: 10%; }
.scenario-label { position: relative; z-index: 1; font-size: 12px; letter-spacing: .15em; text-transform: uppercase; font-weight: 1000; color: var(--yellow); margin-bottom: 18px; }
.scenario-text { position: relative; z-index: 1; font-size: clamp(22px, 3vw, 34px); line-height: 1.18; font-weight: 900; }
.required-badge { position: relative; z-index: 1; justify-self: start; margin-top: 18px; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); padding: 7px 10px; font-size: 12px; font-weight: 1000; text-transform: uppercase; }

.leader-banner {
  background: var(--ink); color: var(--yellow); padding: 12px 16px; border: 2px solid var(--ink); display: flex; justify-content: space-between; gap: 12px; align-items: center; text-transform: uppercase; font-weight: 1000;
}

.hand-panel { background: rgba(255,249,216,.8); border-top: 4px solid var(--ink); padding-top: 18px; }
.hand-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 14px; }
.hand { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.answer-card {
  position: relative; min-height: 145px; padding: 16px; background: var(--yellow-2); border: 3px solid var(--ink); text-align: left; font-weight: 900; line-height: 1.18; color: var(--ink); box-shadow: 5px 5px 0 rgba(31,24,20,.18); transition: transform .1s ease, box-shadow .1s ease, background .1s ease;
}
.answer-card:hover { transform: translateY(-3px); }
.answer-card.selected { background: var(--red); color: white; box-shadow: 7px 7px 0 var(--ink); }
.answer-card.disabled { opacity: .58; cursor: default; transform: none; }
.pick-number { position: absolute; top: 7px; right: 7px; width: 28px; height: 28px; display: grid; place-items: center; background: var(--ink); color: var(--yellow); border-radius: 50%; font-weight: 1000; }
.submit-bar { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-top: 16px; }
.selection-copy { font-size: 13px; color: var(--muted); }

.waiting {
  border: 3px solid var(--ink); background: #fffdf1; padding: 26px; text-align: center;
}
.waiting .big { font-size: clamp(28px, 5vw, 52px); font-weight: 1000; text-transform: uppercase; line-height: 1; }
.progress { height: 16px; border: 2px solid var(--ink); background: white; margin-top: 16px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--red); transition: width .25s ease; }

.submission-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.submission {
  border: 3px solid var(--ink); background: var(--yellow-2); min-height: 130px; padding: 18px; display: grid; align-content: center; gap: 8px; font-weight: 1000; font-size: 20px; box-shadow: 5px 5px 0 rgba(31,24,20,.18); text-align: left;
}
.submission.clickable:hover { background: #fff09a; transform: translateY(-2px); }
.submission .plus { color: var(--red); font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }

.scoreboard { position: sticky; top: 24px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 7px 7px 0 var(--red); padding: 18px; }
.score-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(31,24,20,.18); align-items: center; }
.score-row:last-child { border-bottom: 0; }
.score-name { display: flex; gap: 7px; align-items: center; min-width: 0; }
.score-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score { font-size: 22px; font-weight: 1000; color: var(--red); }
.reaction-tray { margin-top: 20px; display: flex; gap: 6px; flex-wrap: wrap; }
.reaction-btn { border: 2px solid var(--ink); background: white; font-size: 20px; width: 42px; height: 42px; }
.reaction-btn:hover { background: var(--yellow); }

.winner-panel {
  background: var(--ink); color: white; border: 4px solid var(--red); padding: clamp(30px, 6vw, 70px); text-align: center; box-shadow: 10px 10px 0 var(--red);
}
.winner-panel .eyebrow { color: var(--yellow); text-transform: uppercase; letter-spacing: .18em; font-weight: 1000; }
.winner-answer { font-size: clamp(30px, 6vw, 62px); line-height: 1; font-weight: 1000; color: var(--yellow); margin: 22px auto; max-width: 850px; }
.winner-name { font-size: clamp(24px, 4vw, 42px); text-transform: uppercase; font-weight: 1000; }

.game-over { text-align: center; }
.final-list { width: min(620px,100%); margin: 26px auto; display: grid; gap: 10px; }
.final-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; border: 2px solid var(--ink); background: white; padding: 12px; text-align: left; }
.final-rank { font-size: 24px; font-weight: 1000; color: var(--red); }
.final-score { font-weight: 1000; font-size: 24px; }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: white; border: 2px solid var(--red); padding: 12px 18px; z-index: 100; max-width: min(90vw, 620px); font-weight: 800; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.reactions { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.floating-reaction { position: absolute; bottom: 7%; font-size: 42px; animation: floatReaction 2.4s ease-out forwards; filter: drop-shadow(0 3px 0 white); }
@keyframes floatReaction { 0% { transform: translateY(0) scale(.8) rotate(-8deg); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-70vh) scale(1.35) rotate(8deg); opacity: 0; } }

.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: grid; gap: 14px; }
.spacer { height: 8px; }

@media (max-width: 900px) {
  .home-grid, .lobby-grid, .game-grid { grid-template-columns: 1fr; }
  .cover-wrap { display: none; }
  .home-grid { min-height: calc(100vh - 48px); }
  .scoreboard { position: static; }
  .hand { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 600px) {
  .page { padding: 12px; }
  .topbar { align-items: flex-start; padding: 10px; box-shadow: 4px 4px 0 var(--red); }
  .brand.small { font-size: 22px; }
  .brand-mark { width: 34px; height: 34px; }
  .room-pill, .round-pill { font-size: 11px; padding: 6px 8px; }
  .inline-fields, .hand, .submission-grid { grid-template-columns: 1fr; }
  .answer-card { min-height: 100px; }
  .scenario-card { min-height: 220px; }
  .party-row { grid-template-columns: 36px 1fr auto; }
  .party-row .kick-cell { grid-column: 2 / -1; }
  .submit-bar { align-items: stretch; flex-direction: column; }
  .btn { width: 100%; }
}
