:root {
  --paper: #f6f2e7;
  --ink: #47554d;
  --muted: #757c70;
  --coral: #df735f;
  --coral-dark: #b95345;
  --teal: #51988f;
  --teal-dark: #346f68;
  --yellow: #edc66a;
  --tray: #d9dfd0;
  --sans: 'Nunito Sans', sans-serif;
  --display: 'Fredoka', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); background: var(--paper);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(ellipse at 50% 5%, #fffcf4 0%, transparent 65%);
}
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--teal-dark); outline-offset: 5px;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; text-wrap: balance; }
p { text-wrap: pretty; }
.shell { max-width: 900px; margin: auto; padding: 0 34px; isolation: isolate; }
header { position: relative; padding: 28px 0 32px; text-align: center; }
.brand a { text-decoration: none; display: inline-block; }
h1 { font-size: 55px; letter-spacing: -2px; line-height: 1.1; }
h1 span:first-child { color: var(--coral); }
h1 span:nth-child(2) { color: var(--teal); }
h1 b { display: inline-block; color: #c49736; font-weight: 500; transform: rotate(9deg); }
.brand p { font-size: 13px; margin-top: 8px; font-weight: 700; color: var(--muted); }
.help-button {
  border: 0; border-radius: 50%; width: 42px; height: 42px; color: var(--ink);
  background: #e8e8da; font-family: var(--display); font-size: 24px;
  box-shadow: 0 3px 0 #d2d6c7; transition: transform .15s;
}
header .help-button { position: absolute; right: 0; top: 40px; }
.help-button:active, .button:active { transform: translateY(2px) scale(.98); }
.arena { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 290px); gap: 54px; justify-content: center; align-items: start; }
.play-panel { min-width: 0; }
.players { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.player { display: flex; align-items: center; gap: 12px; min-width: 0; }
.player:last-child { text-align: right; }
.player strong { font-family: var(--display); font-size: 21px; font-weight: 500; }
.player small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.player-tile {
  display: grid; place-items: center; flex-shrink: 0; width: 47px; height: 50px;
  border-radius: 12px; font: 500 43px/1 var(--display); color: #fff9eb;
}
.player-tile svg { display: block; width: 62%; height: 62%; }
.player-tile.human { background: var(--coral); color: #fff9eb; box-shadow: 0 4px 0 #bc5a48; transform: rotate(-7deg); }
.player-tile.machine { background: var(--teal); color: #fff9eb; box-shadow: 0 4px 0 #38766d; transform: rotate(7deg); }
.versus { font-family: var(--display); font-size: 16px; color: #8c9283; }
.turn-status { text-align: center; padding: 25px 0 19px; min-height: 100px; }
#status { font: 500 28px/1.25 var(--display); letter-spacing: -.4px; }
#hint { margin-top: 5px; font-size: 13px; color: var(--muted); font-weight: 600; min-height: 18px; }
.board-wrap { position: relative; padding-bottom: 10px; }
.board-wrap::before, .board-wrap::after { position: absolute; font-family: var(--display); color: #d4b353; pointer-events: none; }
.board-wrap::before { content: '+'; font-size: 26px; left: -25px; top: 65%; transform: rotate(15deg); }
.board-wrap::after { content: '·'; font-size: 40px; right: -23px; top: 12%; }
.board {
  --padding: 15px; --radius: 29px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 12px; padding: var(--padding); padding-bottom: 21px; aspect-ratio: 1;
  width: 100%; border-radius: var(--radius); background: var(--tray);
  box-shadow: inset 0 3px 0 #cbd2c1, 0 7px 0 #bec8b4, 0 14px 22px #64755514;
}
.cell {
  position: relative; min-width: 0; min-height: 0; border: 0; border-radius: calc(var(--radius) - var(--padding));
  display: grid; place-items: center; color: #a4b39b; background: #e8ecdf;
  box-shadow: inset 0 3px 0 #cdd7c3; padding: 0; transition: transform .14s;
}
.cell small { position: absolute; bottom: 9px; right: 11px; font-size: 10px; font-weight: 800; color: #75896d; }
.cell.human { background: var(--coral); box-shadow: 0 6px 0 var(--coral-dark), inset 0 2px 0 #ed9882; }
.cell.machine { background: var(--teal); box-shadow: 0 6px 0 var(--teal-dark), inset 0 2px 0 #75b4a9; }
.cell.human small, .cell.machine small { color: #fff9ebbf; }
.cell:not(:disabled):active { transform: translateY(3px); }
.cell.win { background: #e9b957; box-shadow: 0 6px 0 #b48938, inset 0 2px 0 #f6d78e; }
.cell.win small { color: #6e5829; }
.mark { display: block; position: relative; width: 100%; height: 100%; font-size: 0; animation: place .18s ease-out; }
.mark::before, .mark::after { content: ''; position: absolute; top: 50%; left: 50%; }
.human .mark::before, .human .mark::after { width: 62%; height: 11%; background: #fff8e8; border-radius: 8px; transform: translate(-50%, -50%) rotate(45deg); }
.human .mark::after { transform: translate(-50%, -50%) rotate(-45deg); }
.machine .mark::before { width: 58%; height: 58%; border: 11px solid #fff8e8; border-radius: 50%; transform: translate(-50%, -50%); }
@media (hover: hover) and (pointer: fine) {
  .cell:not(:disabled):hover { background: #f3f3e9; }
  .cell:not(:disabled):hover::after { content: '×'; font: 500 58px var(--display); color: #c4cbb7; }
  .button:hover { background: #f3d78c; }
  .help-button:hover { background: #e0e4d3; }
}
.game-bottom { display: flex; flex-direction: column; align-items: center; gap: 13px; padding-top: 20px; }
.button {
  min-height: 46px; min-width: 190px; padding: 10px 22px; border: 0; border-radius: 16px;
  background: var(--yellow); color: #624d24; font: 500 18px/1.4 var(--display);
  box-shadow: 0 4px 0 #c7a64e, inset 0 2px 0 #f7dea0; transition: transform .14s;
}
.button span { padding-right: 6px; }
.button:disabled { color: #897442; }
#game-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .5px; min-height: 14px; }
.decision-panel { padding-top: 12px; min-width: 0; }
.journal-heading { display: flex; align-items: center; gap: 10px; padding-bottom: 19px; }
.journal-heading>div { min-width: 0; }
.journal-doodle { font: 500 40px/1 var(--display); color: var(--teal); transform: rotate(-12deg); }
.journal-heading h2 { font-size: 20px; letter-spacing: -.3px; }
.journal-heading p { font-size: 12px; margin-top: 4px; color: var(--muted); }
.live { margin-left: auto; }
.live i { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.feed {
  height: 465px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c8d0bc transparent;
  border-top: 2px dashed #7c8c6d29; border-bottom: 2px dashed #7c8c6d29;
  background-image: repeating-linear-gradient(transparent 0, transparent 29px, #82936c09 29px, #82936c09 30px);
}
.empty-feed { text-align: center; padding: 110px 8px 40px; }
.waiting-tiles { display: flex; align-items: center; justify-content: center; gap: 7px; padding-bottom: 25px; }
.waiting-tiles span { display: grid; place-items: center; width: 43px; height: 48px; border-radius: 10px; font: 500 34px/1 var(--display); background: #f2d3c4; color: var(--coral-dark); box-shadow: 0 4px 0 #e8bcaa; transform: rotate(-10deg); }
.waiting-tiles span:nth-child(2) { background: #eddfb4; color: #9a792e; box-shadow: 0 4px 0 #d9c995; transform: translateY(-6px); }
.waiting-tiles span:nth-child(3) { background: #cce0d5; color: var(--teal-dark); box-shadow: 0 4px 0 #b4cdbf; transform: rotate(10deg); }
.empty-feed h3 { font-size: 24px; }
.empty-feed p { margin-top: 10px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.decision { padding: 18px 3px 19px; border-bottom: 1px dashed #7c8c6d40; }
.decision:last-child { border-bottom: 0; }
.decision-top { font-size: 10px; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.decision h3 { font-size: 20px; margin: 7px 0 9px; color: var(--teal-dark); }
.probability { display: grid; grid-template-columns: 94px minmax(0, 1fr) 38px; align-items: center; gap: 9px; font-size: 11px; margin: 10px 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.track { height: 7px; border-radius: 4px; overflow: hidden; background: #e0e4d5; }
.bar { height: 100%; border-radius: 4px; background: #bac9ac; }
.probability.selected { color: var(--teal-dark); }
.probability.selected .bar { background: var(--teal); }
.confidence { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 7px; }
.decision-options { margin-top: 10px; }
.decision-options summary { font-size: 11px; font-weight: 700; padding: 6px 0; color: var(--teal-dark); }
.waiting { padding: 16px 3px; color: var(--teal-dark); font-size: 13px; font-weight: 800; }
.journal-explainer { margin-top: 14px; }
.journal-explainer summary { font-size: 12px; color: var(--muted); padding: 5px 0; }
.journal-explainer p { font-size: 12px; line-height: 1.7; color: var(--muted); padding-top: 8px; }
.world { padding-top: 37px; }
.world-heading { display: flex; align-items: center; justify-content: center; gap: 18px; }
.world-heading h2 { font-size: 20px; white-space: nowrap; }
.rule { height: 2px; border-top: 2px dashed #7c8c6d29; flex: 1; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); padding: 17px 0 10px; }
.stat { text-align: center; border-right: 1px solid #7c8c6d1a; }
.stat:last-child { border: 0; }
.stat strong { display: block; font: 500 34px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.stat>span { display: block; font-size: 12px; font-weight: 700; margin-top: 4px; white-space: nowrap; }
.human { color: var(--coral-dark); }
.machine { color: var(--teal-dark); }
.world-caption { display: flex; justify-content: center; gap: 10px; padding: 8px 0 13px; font-size: 10px; color: var(--muted); }
.world-caption span+span::before { content: '·'; padding-right: 10px; }
.recent-rounds>summary { display: flex; align-items: center; gap: 8px; width: fit-content; margin: auto; font-size: 12px; font-weight: 700; padding: 8px 12px; list-style: none; }
.recent-rounds>summary::-webkit-details-marker { display: none; }
.recent-chevron { display: block; flex-shrink: 0; }
.recent-rounds[open] .recent-chevron { transform: rotate(180deg); }
.recent { display: flex; gap: 10px; overflow-x: auto; padding: 13px 1px; }
.recent>p { font-size: 13px; color: var(--muted); }
.recent-game { flex: 0 0 138px; border-radius: 11px; background: #e9ecdf; padding: 13px 10px; display: flex; gap: 10px; align-items: center; }
.mini { width: 35px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; flex-shrink: 0; }
.mini span { height: 11px; background: #f9f7ed; font-size: 11px; text-align: center; line-height: 11px; border-radius: 2px; }
.recent-game strong { font-size: 11px; display: block; font-weight: 800; }
.recent-game small { font-size: 10px; color: var(--muted); display: block; margin-top: 4px; }
.stats-footer { display: flex; justify-content: center; gap: 20px; padding: 7px 0; font-size: 11px; color: var(--muted); }
.stats-footer b { font-weight: 700; color: var(--ink); }
footer { display: flex; justify-content: space-between; gap: 16px; padding: 23px 0 26px; color: var(--muted); font-size: 11px; }
footer a { text-decoration: none; }
footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
dialog { max-width: 420px; width: calc(100% - 36px); padding: 34px; border: 0; border-radius: 26px; background: var(--paper); color: var(--ink); box-shadow: 0 12px 0 #a8b49b, 0 20px 60px #253b3940; }
dialog::backdrop { background: #34483d66; backdrop-filter: blur(3px); }
dialog h2 { font-size: 30px; margin: 18px 0; }
dialog p { font-size: 15px; line-height: 1.7; margin: 15px 0; }
dialog .button { width: 100%; margin-top: 10px; }
.close-button { position: absolute; top: 15px; right: 15px; width: 35px; height: 35px; }
@keyframes place { from { transform: scale(.83) rotate(-5deg); } to { transform: scale(1) rotate(0); } }
@media (max-width: 760px) {
  .shell { max-width: 500px; padding: 0 23px; }
  header { padding: 23px 0 25px; }
  h1 { font-size: 44px; }
  .brand p { font-size: 12px; }
  header .help-button { top: 28px; right: -3px; width: 35px; height: 35px; font-size: 21px; }
  .arena { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .player small { font-size: 10px; }
  .player strong { font-size: 20px; }
  .player-tile { width: 40px; height: 44px; font-size: 37px; border-radius: 10px; }
  .player { gap: 9px; }
  .turn-status { min-height: 92px; padding: 21px 0 16px; }
  #status { font-size: 27px; }
  #hint { font-size: 14px; }
  .board { --padding: 12px; --radius: 24px; gap: 10px; padding-bottom: 18px; }
  .machine .mark::before { border-width: 9px; }
  .cell small { font-size: 9px; bottom: 7px; right: 8px; }
  .board-wrap::before { left: -19px; font-size: 20px; }
  .board-wrap::after { right: -17px; }
  .game-bottom { padding-top: 16px; gap: 11px; }
  .decision-panel { padding: 12px 0 0; }
  .journal-heading { padding-bottom: 16px; }
  .journal-heading h2 { font-size: 23px; }
  .journal-heading p { font-size: 14px; }
  .feed { height: 305px; }
  .empty-feed { padding: 50px 0 30px; }
  .empty-feed p { font-size: 16px; }
  .journal-explainer summary { font-size: 14px; padding: 10px 0; }
  .journal-explainer p { font-size: 16px; }
  .probability { font-size: 12px; grid-template-columns: 112px minmax(0, 1fr) 40px; }
  .decision-top { font-size: 11px; }
  .confidence { font-size: 12px; }
  .decision-options summary { font-size: 13px; padding: 10px 0; }
  .world { padding-top: 26px; }
  .stat strong { font-size: 30px; }
  .stat>span { font-size: 10px; }
  .world-caption { flex-direction: column; align-items: center; gap: 3px; }
  .world-caption span+span::before { display: none; }
  .recent-rounds>summary { font-size: 14px; padding: 12px; }
  footer { font-size: 10px; padding-bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.mode-picker { display: flex; width: fit-content; margin: 0 auto 23px; padding: 4px; gap: 4px; border-radius: 16px; background: #e3e7d9; }
.mode-picker button { min-width: 128px; padding: 9px 17px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: 500 18px var(--display); }
.mode-picker button small { display: block; margin-top: 2px; font: 700 10px var(--sans); }
.mode-picker button[aria-pressed="true"] { color: var(--teal-dark); background: #fffbef; box-shadow: 0 2px 0 #bdc8b2; }
#mode-blitz[aria-pressed="true"] { background: var(--yellow); color: #624d24; box-shadow: 0 2px 0 #c7a64e; }
.turn-status { display: flex; justify-content: center; align-items: center; gap: 12px; }
.turn-clock { position: relative; width: 49px; height: 49px; flex-shrink: 0; color: var(--teal-dark); }
.turn-clock svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); fill: none; stroke: currentColor; stroke-width: 3.5; }
.clock-track { opacity: .15; }
#clock-ring { stroke-dasharray: 1; stroke-linecap: round; }
.clock-readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#clock-value { font: 500 18px/1 var(--display); font-variant-numeric: tabular-nums; }
.clock-readout small { font: 700 9px/1 var(--sans); margin-top: 2px; }
.turn-clock.urgent { color: var(--coral-dark); }
.world-caption { flex-wrap: wrap; }
@media(max-width:760px){.world-heading h2{font-size:18px}.world-heading{gap:8px}.mode-picker{margin-bottom:20px}.turn-status:has(.turn-clock:not([hidden])) #status{font-size:23px}.turn-status:has(.turn-clock:not([hidden])) #hint{font-size:12px}}
