:root {
  --navy: #10243f;
  --ink: #102039;
  --paper: #f2eadc;
  --paper-deep: #e5dac6;
  --red: #e44732;
  --blue: #2f79b9;
  --yellow: #f4bd38;
  --green: #668a59;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 36, 63, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 36, 63, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Gowun Dodum", sans-serif;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 130px rgba(83, 58, 28, .12);
}

.noise {
  position: fixed;
  inset: 0;
  opacity: .12;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 88px;
  border-bottom: 2px solid var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(22px, 5vw, 72px);
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  font-family: "Black Han Sans", sans-serif;
  line-height: .82;
  letter-spacing: .03em;
}

.brand-ball {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: var(--red);
  color: var(--paper);
  font-size: 24px;
  transform: rotate(-8deg);
}

.text-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--ink);
  background: none;
  padding: 5px 0;
  font-weight: 700;
}

.app {
  min-height: calc(100vh - 88px);
  display: grid;
  align-items: center;
  padding: 46px clamp(22px, 7vw, 110px) 60px;
  position: relative;
  z-index: 1;
}

.setup, .secret-screen, .handoff, .winner { width: min(1060px, 100%); margin: auto; }

.setup {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: clamp(40px, 8vw, 110px);
  align-items: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--red);
  font-family: "Black Han Sans", sans-serif;
  letter-spacing: .16em;
  font-size: 14px;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Black Han Sans", sans-serif; font-weight: 400; }

h1 {
  margin-bottom: 24px;
  font-size: clamp(66px, 10vw, 132px);
  line-height: .82;
  letter-spacing: -.055em;
}

h1 span { color: var(--red); }
.lead { max-width: 560px; font-size: clamp(17px, 2vw, 21px); line-height: 1.75; }

.ball-art {
  aspect-ratio: 1;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: var(--yellow);
  display: grid;
  place-items: center;
  position: relative;
  transform: rotate(5deg);
  box-shadow: 15px 15px 0 var(--red);
}

.ball-art::before, .ball-art::after {
  content: "";
  position: absolute;
  width: 42%;
  height: 13%;
  border-top: 3px solid var(--navy);
  border-radius: 50%;
}
.ball-art::before { top: 24%; left: -3%; transform: rotate(45deg); }
.ball-art::after { bottom: 24%; right: -3%; transform: rotate(45deg); }
.ball-art span { font-family: "Black Han Sans"; font-size: clamp(72px, 11vw, 150px); color: var(--navy); }

.choice-card {
  margin-top: 40px;
  border-top: 2px solid var(--navy);
  padding-top: 22px;
}

.choice-card h2 { font-size: 22px; margin-bottom: 17px; }
.digit-choice { display: flex; gap: 12px; flex-wrap: wrap; }

.big-button, .choice-button {
  border: 2px solid var(--navy);
  padding: 14px 24px;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
  box-shadow: 4px 4px 0 var(--navy);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.big-button:hover, .choice-button:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--navy); }
.choice-button.active { background: var(--navy); color: var(--paper); }
.big-button { background: var(--red); color: white; min-width: 175px; }
.big-button.secondary { background: var(--yellow); color: var(--ink); }
.big-button:disabled { opacity: .35; cursor: not-allowed; }

.secret-screen, .handoff, .winner { text-align: center; max-width: 760px; }
.step-count { font-weight: 700; opacity: .58; letter-spacing: .12em; }
.secret-screen h2, .handoff h2, .winner h2 { font-size: clamp(42px, 7vw, 76px); line-height: 1; margin-bottom: 18px; }
.secret-screen .instruction, .handoff p, .winner p { font-size: 19px; line-height: 1.7; }

.number-input {
  display: block;
  width: min(510px, 100%);
  margin: 34px auto 18px;
  border: 0;
  border-bottom: 4px solid var(--navy);
  background: rgba(255,255,255,.22);
  color: var(--navy);
  text-align: center;
  font-family: "Black Han Sans";
  font-size: clamp(54px, 10vw, 96px);
  letter-spacing: .2em;
  padding: 5px 0 5px .2em;
  outline: none;
}
.number-input:focus { border-color: var(--red); }
.error { min-height: 28px; color: #bd2e21; font-weight: 700; }
.privacy-note { margin: 26px auto; padding: 12px; border: 1px dashed var(--navy); max-width: 500px; }

.game { width: min(1180px, 100%); margin: auto; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; border: 2px solid var(--navy); background: rgba(255,255,255,.22); }
.player-score { padding: 18px 24px; }
.player-score:last-child { text-align: right; }
.player-score.active { background: var(--yellow); }
.player-score span { display: block; font-size: 13px; font-weight: 700; opacity: .65; }
.player-score b { font-family: "Black Han Sans"; font-size: 24px; font-weight: 400; }
.versus { display: grid; place-items: center; border-left: 2px solid var(--navy); border-right: 2px solid var(--navy); padding: 0 20px; font-family: "Black Han Sans"; }

.game-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 50px; padding-top: 42px; }
.turn-panel h2 { font-size: clamp(40px, 6vw, 68px); margin-bottom: 10px; }
.turn-panel > p { font-size: 17px; }
.guess-form { margin-top: 28px; }
.guess-form .number-input { margin: 0 0 18px; text-align: left; padding-left: .2em; }

.history { border-left: 2px solid var(--navy); padding-left: 36px; min-height: 380px; }
.history h3 { font-size: 22px; display: flex; justify-content: space-between; border-bottom: 2px solid var(--navy); padding-bottom: 12px; }
.history h3 span { font-family: "Gowun Dodum"; font-size: 14px; }
.history-list { max-height: 400px; overflow: auto; }
.history-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 14px; align-items: center; padding: 13px 4px; border-bottom: 1px solid rgba(16,36,63,.25); }
.history-row .num { font-family: "Black Han Sans"; font-size: 25px; letter-spacing: .12em; }
.badge { padding: 5px 10px; background: var(--blue); color: white; font-weight: 700; min-width: 82px; text-align: center; }
.badge.out { background: var(--red); }
.empty { opacity: .6; padding: 40px 0; text-align: center; }

.handoff-icon { width: 110px; height: 110px; margin: 0 auto 28px; display: grid; place-items: center; border-radius: 50%; background: var(--navy); color: var(--paper); font-size: 50px; }
.handoff-icon.computer-icon { font-family: "Black Han Sans"; font-size: 28px; background: var(--blue); }
.computer-guess { color: var(--red); letter-spacing: .12em; }
.winner-mark { color: var(--red); font-family: "Black Han Sans"; font-size: 22px; letter-spacing: .13em; }
.winner .trophy { font-size: 90px; margin-bottom: 20px; }

.rules-dialog { width: min(560px, calc(100% - 30px)); border: 2px solid var(--navy); background: var(--paper); color: var(--ink); padding: 38px; box-shadow: 10px 10px 0 var(--navy); }
.rules-dialog::backdrop { background: rgba(16, 36, 63, .78); }
.rules-dialog h2 { font-size: 38px; }
.rules-dialog li { margin: 13px 0; line-height: 1.5; }
.dialog-close { float: right; border: 0; background: none; font-size: 28px; }

@media (max-width: 760px) {
  .topbar { height: 72px; }
  .app { min-height: calc(100vh - 72px); padding-top: 32px; }
  .setup { grid-template-columns: 1fr; }
  .ball-art { display: none; }
  .game-grid { grid-template-columns: 1fr; gap: 34px; }
  .history { border-left: 0; border-top: 2px solid var(--navy); padding: 26px 0 0; }
  .scoreboard { grid-template-columns: 1fr 40px 1fr; }
  .player-score { padding: 12px; }
  .player-score b { font-size: 19px; }
  .versus { padding: 0; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
