/* The birthday problem: a green event field (the room's calendar) beside a navy control panel. Base in ../style.css. */
.stage { display: grid; }
.field { position: relative; overflow: hidden; background: var(--green); color: #fff; padding: 0 var(--pad) 22px; display: flex; flex-direction: column; }
.field > * { position: relative; }
/* One giant pictogram per event, cropped off the field's edge. */
.giant { position: absolute; top: 62px; right: calc(-1 * clamp(28px, 5vw, 80px)); width: clamp(120px, 22vw, 300px); aspect-ratio: 1; color: #fff; }
.giant svg { width: 100%; height: 100%; display: block; }
@media (max-width: 899px) { .giant { top: 36px; right: -22vw; width: 64vw; color: rgba(255, 255, 255, 0.16); } }
.field h1 { font-size: clamp(36px, 9vw, 68px); margin: 22px 0 20px; max-width: min(6.5em, calc(100% - clamp(80px, 16vw, 220px))); }

/* The year: a month label, then 31 squares per row. Taken days are white; the shared one is orange. */
.year { display: grid; grid-template-columns: 1.4em repeat(31, minmax(0, 1fr)); gap: clamp(2px, 0.3vw, 4px); align-content: start; }
.year .m { font-size: 11px; font-weight: 800; color: rgba(255, 255, 255, 0.9); display: flex; align-items: center; }
.year i { aspect-ratio: 1; outline: 1px solid rgba(255, 255, 255, 0.35); outline-offset: -1px; }
.year i.x { outline: 0; }
.year i.on { background: #fff; outline-color: #fff; animation: pop 0.35s var(--ease) both; }
.year i.hit { background: var(--orange); outline: 2px solid #fff; outline-offset: 0; animation: pop 0.5s var(--ease) both; position: relative; z-index: 1; }
@keyframes pop { from { transform: scale(2.2); } }

.status { display: flex; gap: clamp(28px, 6vw, 64px); margin-top: 18px; padding-top: 10px; border-top: 2px solid #fff; }
.status .ev { color: rgba(255, 255, 255, 0.9); }
.num { font-size: clamp(34px, 8vw, 56px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }

.panel { background: var(--navy); color: #fff; padding: 24px var(--pad) 28px; }
.soft, .ev.soft { color: var(--navy-soft); }
.panel-title { font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.02em; line-height: 1.05; }
.panel .more { display: inline-block; margin-top: 28px; color: #fff; }

/* Start screen */
.guess { display: grid; gap: 8px; margin-top: 22px; max-width: 520px; }
.guess input { width: 9em; padding: 12px 14px; border: 2px solid #fff; border-radius: 0; background: transparent; color: #fff; font: 800 22px var(--font); font-variant-numeric: tabular-nums; }
.guess input::placeholder { color: var(--navy-soft); font-weight: 400; }
.cta { display: inline-block; margin-top: 22px; padding: 16px 24px; border: 2px solid #fff; border-radius: 0; background: #fff; color: var(--ink); font: 800 14px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease); }
.cta.ghost { background: transparent; color: #fff; }
@media (hover: hover) { .cta:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.cta:active { transform: scale(0.97); }
kbd { display: none; font: inherit; opacity: 0.45; margin-left: 6px; }
@media (hover: hover) and (pointer: fine) { kbd { display: inline; } }

/* Play */
.verdict { margin-top: 14px; padding: 12px 14px; min-height: calc(2.5em + 24px); display: flex; align-items: center; max-width: 520px; font-size: clamp(18px, 4vw, 22px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
.verdict.wait { padding-left: 0; color: var(--navy-soft); font-weight: 700; }
.verdict.hit { background: var(--orange); color: var(--ink); }
.verdict.flash { animation: flash 0.35s var(--ease); }
@keyframes flash { from { transform: scale(0.96); opacity: 0.3; } }
.controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; max-width: 520px; }
.controls .cta { margin-top: 0; padding: 22px 20px; }
.log { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 6px; max-width: 520px; }
.log li { display: grid; grid-template-columns: 7em 1fr; font-size: 15px; animation: in 0.35s var(--ease) both; }
.log li:nth-child(n + 4) { opacity: 0.55; }
@keyframes in { from { opacity: 0; transform: translateY(-6px); } }
.over .log, .over .controls { display: none; }

.end { margin-top: 24px; }
.end .big { white-space: nowrap; font-size: clamp(56px, 7vw, 104px); font-weight: 800; letter-spacing: -0.05em; line-height: 0.85; margin: 12px 0 6px; }
.end .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 22px 0 26px; padding-top: 10px; border-top: 2px solid rgba(255, 255, 255, 0.3); }
.end .stats .val { font-size: clamp(22px, 5vw, 30px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.end .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.end button { display: inline-flex; align-items: center; gap: 10px; padding: 14px 20px; border: 2px solid #fff; border-radius: 0; background: transparent; color: #fff; font: 800 13px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.end button.primary { background: #fff; color: var(--ink); }
@media (hover: hover) { .end button:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.end button .icon { width: 18px; height: 18px; }

/* The math: the no-match ladder and the worked line on the silver ground, the odds on a green field. */
.math { padding-top: clamp(40px, 7vw, 72px); }
.math h2 { font-size: clamp(36px, 6vw, 64px); padding-bottom: 14px; border-bottom: var(--rule) solid var(--ink); }
.math .therefore { margin-top: clamp(20px, 3vw, 32px); font-size: clamp(18px, 2vw, 22px); max-width: 36em; color: var(--ink-soft); }
.math .therefore b { color: var(--ink); }
.math .ladder { list-style: none; margin: clamp(20px, 3vw, 32px) 0 0; padding: 0; max-width: 900px; }
.math .ladder li { display: grid; grid-template-columns: 6.5em 5em 4.5em 1fr; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(20, 33, 61, 0.15); }
.math .ladder .frac { font-size: 17px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.math .ladder b { font-size: clamp(17px, 2vw, 22px); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.math .ladder i { display: block; height: 14px; background: var(--green); }
.math .ladder .gap { display: block; text-align: center; color: var(--ink-soft); letter-spacing: 0.3em; border-top: 0; padding: 2px 0; }
.math .ladder .last { border-top: var(--rule) solid var(--ink); }
.math .ladder .last i { background: var(--orange); }
.math .worked { margin-top: clamp(24px, 4vw, 40px); font-size: clamp(30px, 6.4vw, 80px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.math .worked .hl { background: var(--orange); padding: 0 0.12em; }
.math .odds { margin-top: clamp(32px, 5vw, 56px); background: var(--green); color: #fff; padding: clamp(20px, 4vw, 40px); }
.math .odds h3, .math .test h3 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.02em; }
.math table { width: 100%; border-collapse: collapse; margin: 18px 0 20px; }
.math th, .math td { padding: 12px 0; border-top: 2px solid rgba(255, 255, 255, 0.5); text-align: left; vertical-align: baseline; }
.math th { font-weight: 700; font-size: 17px; padding-right: 16px; }
.math td { text-align: right; font-size: clamp(24px, 4vw, 44px); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.math .odds p { max-width: 40em; color: rgba(255, 255, 255, 0.92); }

/* 1,000 rooms: one bar per room size, the first half of the rooms in orange. */
.math .test { margin-top: clamp(40px, 6vw, 64px); }
.math .soft-ink { margin-top: 8px; color: var(--ink-soft); max-width: 40em; }
.cta.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.hist { margin-top: 24px; max-width: 900px; }
.hist .bars { height: clamp(140px, 22vw, 220px); display: flex; align-items: flex-end; gap: 1px; border-bottom: 2px solid var(--ink); }
.hist .bars i { flex: 1; background: var(--ink); min-height: 1px; }
.hist .bars i.in { background: var(--orange); }
.hist .axis { position: relative; height: 22px; margin-top: 6px; color: var(--ink-soft); }
.hist .axis span { position: absolute; transform: translateX(-50%); }
.math .takeaway { margin-top: 12px; font-size: clamp(18px, 2vw, 22px); max-width: 36em; }
.math .yours { margin-top: 8px; color: var(--ink-soft); }
.math .source { margin-top: 32px; font-size: 15px; color: var(--ink-soft); max-width: 60em; }

@media (min-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1.55fr) minmax(360px, 1fr); min-height: 100svh; }
  .field { padding-bottom: 36px; }
  .field h1 { margin: 30px 0 auto; }
  .year { margin-top: 28px; max-width: 760px; }
  .panel { padding-top: 76px; padding-bottom: 36px; display: flex; flex-direction: column; }
  .panel .more { margin-top: auto; padding-top: 28px; align-self: flex-start; }
}

/* Phones: the calendar turns on its side, one column per month, so the days get bigger squares. */
@media (max-width: 899px) {
  .year { grid-auto-flow: column; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: auto repeat(31, minmax(0, 1fr)); gap: 2px 4px; height: 300px; }
  .year .m { justify-content: center; padding-bottom: 2px; }
  .year i { aspect-ratio: auto; }
}

/* Phones, mid-game: calendar, counters and the add button share one screen. */
@media (max-width: 899px) {
  .playing .year { flex: 1; height: auto; min-height: 0; }
  .over .year { flex: none; height: 300px; }
  .playing .stage { height: 100svh; grid-template-rows: minmax(0, 1fr) auto; }
  .over .stage { height: auto; min-height: 100svh; }
  .playing .field { padding-bottom: 14px; }
  .playing .field h1, .playing .giant, .playing .log, .playing .panel .more { display: none; }
  .playing .year { margin-top: 26px; }
  .playing .status { margin-top: auto; padding-top: 8px; }
  .playing .num { font-size: 30px; }
  .playing .panel { padding-top: 14px; padding-bottom: 18px; }
  .playing .panel-title { font-size: 22px; }
  .playing .verdict { margin-top: 8px; padding: 8px 10px; font-size: 16px; min-height: calc(2.5em + 16px); }
  .playing .verdict.wait { padding-left: 0; }
  .over .verdict { min-height: 0; }
  .playing .controls .cta { padding: 26px 16px; }
  .playing .end { margin-top: 12px; }
  .playing .end .big { font-size: 48px; margin-top: 4px; }
  .playing .end .stats { margin: 10px 0 12px; }
}
@media (max-width: 640px) {
  .math .ladder li { grid-template-columns: 5.4em 4.4em 4em 1fr; gap: 8px; }
  .math .ladder .frac { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .year i.on, .year i.hit { animation: none; } }
