/* Scale the playing surface to the available screen, with controls beside the activity. */
.game-shell { --board-size:min(90vw,34rem); --stage-border:#d9d1e2 }
.game-shell.wide { --board-size:min(76vw,calc(100dvh - 280px),44rem) }
.page-game .game-shell.wide:not(.theme-wolf,.theme-likely) .play {
  width:min(96%,108rem); max-width:none; min-height:calc(100dvh - 58px);
  justify-content:safe center; margin-inline:auto; padding:1rem clamp(.6rem,2vw,2rem)
}
.game-shell.wide .play > .session-banner { max-width:70rem; width:100%; margin-inline:auto }
.game-shell.wide .play > .actions { width:fit-content; max-width:100%; align-self:center; margin:.8rem auto .2rem }
.game-shell.wide .play > :is(.session-recap,.exp-trail) { width:min(100%,56rem); max-width:56rem; margin-inline:auto }
.game-shell .play :is(.exp-map,.exp-grid,.exp-switches,.exp-recall-grid,.table-collection-grid,.pair-duel,.gravity-stack,.toss-grid,.sketch-sheet) {
  width:var(--board-size); max-width:100%; margin-inline:auto
}
.game-shell.wide .play :is(.exp-choices,.exp-menu,.poll-comparison,.exp-ranking,.word-duel-board,.coord-board,.inspection-layout,.overlap-desk) {
  width:min(100%,68rem); max-width:none; margin-inline:auto
}
.game-shell.wide .play :is(.exp-task,.taboo-ticket) { width:min(100%,62rem); max-width:62rem; padding:clamp(1rem,3vmin,2.8rem); font-size:clamp(1.15rem,2.8vmin,1.8rem) }
.game-shell.wide .play .table-clock { min-width:clamp(6rem,16vmin,11rem); padding:.8rem 1.5rem }
.game-shell.wide .play .table-clock strong { font-size:clamp(3rem,8vmin,6rem) }
.game-shell .play .actions .button { min-height:46px; padding:.55rem 1rem }
.game-shell.wide .play :is(.exp-grid,.table-collection-grid,.toss-grid) .exp-cell { font-size:clamp(1.05rem,3vmin,2.1rem) }

/* A taped tabletop and crumpled paper, with a readable team mark. */
.game-shell .play .toss-grid {
  aspect-ratio:1; gap:clamp(.35rem,1vmin,.7rem); padding:clamp(.7rem,2vmin,1.5rem);
  background:repeating-linear-gradient(2deg,#ece2d3 0 2px,#e9decc 3px 13px);
  border:1px solid #cbb99c; border-radius:1.2rem; box-shadow:0 12px 28px #4b36221a,inset 0 0 0 6px #f5edde;
}
.toss-grid button {
  position:relative; display:grid; place-items:center; aspect-ratio:1; min-height:0;
  background:#ffffff35; border:2px solid #fff9e5c9; border-radius:.3rem; padding:.3rem;
}
.toss-grid .toss-position { color:#6b593e; font-size:clamp(.75rem,2vmin,1.2rem); align-self:start; justify-self:start }
.toss-grid button[aria-pressed=true]:not(.is-winning) { background:#ffffff40; border-color:#eee7d9 }
.paper-ball {
  display:grid; place-items:center; width:72%; aspect-ratio:1; font-size:clamp(1.3rem,5vmin,3.6rem); font-weight:800;
  color:#625079; transform:rotate(-11deg);
  background:url("paper-ball.webp") center / contain no-repeat;
  filter:drop-shadow(3px 6px 4px #45332835);
  text-shadow:1px 1px white;
}
.paper-team-1 { color:#ac5d48; transform:rotate(13deg) }
.toss-grid button.is-winning { background:#cfc0e366; border-color:#8b72ae; box-shadow:inset 0 0 0 2px #aa91c8 }
.toss-grid button:focus-visible { outline:3px solid var(--brand); outline-offset:3px }
@media(min-width:760px) {
  .page-game .game-shell.wide.theme-toss .play {
    display:grid; grid-template-columns:minmax(0,1.3fr) minmax(15rem,.7fr);
    grid-template-rows:1fr auto auto auto 1fr; align-content:center; align-items:center;
    gap:.7rem 2rem; width:min(96%,82rem)
  }
  .game-shell.wide.theme-toss .toss-grid { grid-column:1; grid-row:1 / 6; width:min(100%,calc(100dvh - 140px),42rem); margin:0 auto }
  .game-shell.wide.theme-toss .play > .session-banner { grid-area:2 / 2; align-self:end; margin:0 }
  .game-shell.wide.theme-toss .play > .arena-tally { grid-area:3 / 2; font-size:clamp(1rem,2.5vmin,1.6rem) }
  .game-shell.wide.theme-toss .play > .actions { grid-area:4 / 2; align-self:start; width:100%; margin:0; justify-content:center }
}

/* A working light-code console. History stays next to the controls. */
.code-machine { display:grid; grid-template-columns:minmax(0,1.7fr) minmax(13rem,1fr); gap:1.25rem; width:min(100%,78rem); margin:1rem auto; align-items:start }
.code-console { min-width:0 }
.page-game .game-shell.theme-code .play .code-panel {
  max-width:none; padding:clamp(1rem,3vmin,2rem); border:1px solid #898591; border-radius:1.3rem;
  background:linear-gradient(145deg,#f2f0f4,#d7d3dc 53%,#eeebf1); box-shadow:inset 0 2px 1px #fff,0 9px 0 #b0aab9,0 16px 25px #31293e1c;
}
.code-slots { padding:.5rem .3rem 1.3rem; border-bottom:1px solid #b9b2c2; gap:clamp(.35rem,1.3vmin,.9rem) }
.code-panel .code-slots button { background:#39343f; border:4px solid #b8b1c3; border-radius:50%; padding:.4rem; box-shadow:inset 0 2px 5px #0008,0 1px 1px white }
.code-panel .code-slots { flex-wrap:nowrap }
.code-panel .code-slots button { min-width:0; flex:0 1 auto }
.code-panel .code-slots button .code-dot { max-width:100%; flex-shrink:1 }
.code-panel .code-slots .code-dot { width:clamp(2.2rem,7vmin,5rem); height:auto; aspect-ratio:1; font-size:clamp(1.1rem,3vmin,1.8rem) }
.code-dot:not(.empty) {
  background:radial-gradient(circle at 30% 23%,#ffffffd9,transparent 34%),radial-gradient(circle at 54% 42%,var(--chip),color-mix(in srgb,var(--chip) 60%,#111) 85%);
  box-shadow:inset 0 -4px 7px #0005,inset 0 1px 2px #fff8,0 0 14px color-mix(in srgb,var(--chip) 35%,transparent);
}
.code-dot.empty { background:radial-gradient(circle at 35% 30%,#77717f,#2d2932); color:#b5aebb; box-shadow:inset 0 3px 6px #0008 }
.code-panel .code-palette { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.65rem; padding-top:1rem; margin:0 }
.code-panel .code-palette button { flex-direction:column; border:1px solid #b8b0c4; background:#eeebf1; padding:.5rem .2rem; font-size:.85rem; gap:.4rem }
.code-panel .code-palette button:enabled:hover { background:#fff; box-shadow:0 3px 6px #33253b24 }
.code-console > .actions { justify-content:center; margin:1.2rem 0 0 }
.code-machine .code-history { width:100%; max-width:none; max-height:min(62dvh,40rem); margin:0; padding:1rem; border-left:2px solid #d3c8df; background:#f3eff7; border-radius:.6rem; overflow:auto }
.code-history summary { color:var(--brand); padding-bottom:.8rem; font-weight:800 }
.code-history li { padding:.7rem .1rem; border-color:#d9cfdf }
.code-history li strong { display:block; font-size:.9rem; margin-top:.35rem }
.code-waiting { color:var(--muted); line-height:1.7 }
@media(min-width:1000px) and (min-height:650px) {
  .game-shell.wide .code-panel { min-height:46dvh; display:flex; flex-direction:column; justify-content:space-between }
  .game-shell.wide .code-panel .code-slots .code-dot { width:min(10vmin,calc((100vw - 330px)/12),7rem) }
  .game-shell.wide .code-panel .code-palette button { min-height:5.5rem }
  .game-shell.wide .code-history .code-dot { width:2.3rem; height:2.3rem }
}

/* Distinct physical surfaces for the existing mechanics. */
.play .reversi-desk { padding:clamp(.5rem,2vmin,1.5rem); background:#e4d5be; border:1px solid #c2ae8d; border-radius:1rem }
.play .gravity-board { background:#74618f; padding:.65rem; border-radius:.8rem; box-shadow:0 7px 0 #514360 }
.play .gravity-board .exp-cell { border-radius:50%; box-shadow:inset 0 3px 7px #30223d55 }
.play .hex-board { padding:.8rem; background:#f1eadb; border-radius:1rem }
.play .exp-switches .exp-cell { border-radius:.6rem; box-shadow:inset 0 2px 2px #fff8,0 3px 0 #c7becf }
.play .exp-switches .exp-cell[aria-pressed=true] { box-shadow:inset 0 0 12px #fff7,0 0 14px #d0b4eb }
.play .memory-tray { padding:1rem; border:7px solid #c8bca7; background:#e9e2d3; border-radius:1.4rem; box-shadow:inset 0 2px 8px #5b462e26 }
.play .timeline-order button { background:#fffdf5; border-radius:.2rem; box-shadow:2px 3px 0 #cbc2b532 }
.play .exp-ranking li { padding:.65rem; background:#fff; border-bottom:1px solid var(--line) }
.play .letter-tile { box-shadow:inset 0 2px 0 #fff,0 5px 0 #d1c2ab; background:#f5ead3; color:#4f3e2f }
.play .exp-map { padding:.6rem; background:#eee8da; border:1px solid #c8bba4; border-radius:.5rem; box-shadow:4px 6px 0 #d9d0c133 }
.play .exp-pixel { padding:.7rem; background:#fffdf8; border:1px solid #d3c9b6; box-shadow:5px 7px 0 #ddd4c340 }
.play .exp-sort { gap:.9rem; padding:.8rem }
.play .exp-sort > button { border:2px solid #a7b2c5; border-top:5px solid #ced7e4; background:linear-gradient(90deg,#fff9,#e7eef34d,#fff9); border-radius:.2rem .2rem 1.6rem 1.6rem; box-shadow:inset 5px 0 8px #fff9,3px 5px 8px #39445b18 }
.play .exp-ball { box-shadow:inset 3px 3px 5px #ffffffa6,inset -3px -4px 5px #2224,0 2px 3px #30304033 }
.play .exp-token-pile i { background:radial-gradient(circle at 30% 25%,#f4e9d6,#b49a74); border-color:#927953; box-shadow:inset 0 0 0 2px #e6d1aa,2px 4px 4px #4d3f3029 }
.play .exp-slider input { accent-color:var(--brand) }
.play .exp-axis { height:.85rem; border-radius:1rem; background:linear-gradient(90deg,#dfd5ed,#967cb8); box-shadow:inset 0 2px 4px #39304429 }
.play .reaction-pad { border:5px solid #beb5cd; background:radial-gradient(circle at 40% 20%,#f3eef8,#ccc0db); box-shadow:0 8px 0 #a498b4,0 13px 25px #30223d24 }
.play .reaction-pad[data-lit=true] { background:radial-gradient(circle at 40% 20%,#9cdec5,#29755c); box-shadow:0 7px 0 #205c47,0 0 32px #6ed7a777 }
.game-shell.wide .play .collection-twin { width:min(100%,76rem); max-width:none; gap:clamp(1rem,3vw,3rem) }
.game-shell.wide .play .mosaic-board { width:min(35vw,calc(100dvh - 290px),31rem) }
.game-shell.wide .play .exp-sort { width:min(100%,50rem); max-width:none }
.game-shell.wide .play .exp-sort > button { height:clamp(9rem,34dvh,20rem) }
.game-shell.wide .play .reaction-pad { width:min(90%,52rem); min-height:min(40dvh,24rem) }
.game-shell.wide .play .memory-tray { width:min(100%,58rem) }
.game-shell.wide .play .exp-token-pile { width:min(100%,54rem) }
.game-shell.wide .play .exp-token-pile i { width:clamp(2rem,6vmin,4rem) }
@media(prefers-reduced-motion:no-preference) {
  .paper-ball.is-new-paper { animation:paper-land .25s cubic-bezier(.2,.7,.3,1.2) both }
  @keyframes paper-land { from { opacity:.2; translate:0 -22px; scale:.7 } to { opacity:1; translate:0 0; scale:1 } }
  .code-dot:not(.empty) { animation:lamp-on .18s ease-out both }
  @keyframes lamp-on { from { filter:brightness(.6) } to { filter:brightness(1) } }
}
@media(max-width:760px) {
  .code-machine { grid-template-columns:minmax(0,1fr) }
  .code-machine .code-history { max-height:16rem; border-left:0; border-top:2px solid #d3c8df }
  .game-shell.wide .code-machine .code-history { max-height:18dvh }
  .code-panel .code-palette { grid-template-columns:repeat(4,minmax(0,1fr)) }
}
@media(max-height:550px) {
  .game-shell.wide { --board-size:min(48vw,calc(100dvh - 190px),24rem) }
  .game-shell.wide .play .sketch-sheet { width:min(45vw,calc(100dvh - 215px)) }
  .game-shell.wide .play .hex-board { padding:.15rem }
  .game-shell.wide .play .exp-sort > button { height:6.4rem }
  .game-shell.wide .play .exp-token-pile i { width:1.65rem }
  .game-shell.wide .play .mosaic-board { width:min(30vw,calc(100dvh - 205px)) }
  .game-shell.wide .play .memory-tray { padding:.3rem; border-width:3px }
  .game-shell.wide .play .exp-pixel { padding:.15rem }
  .game-shell.wide .play .exp-ranking li { padding:.1rem; font-size:.9rem }
  .game-shell.wide .play .exp-ranking .button { min-height:30px; padding:.15rem .5rem }
  .page-game .game-shell.wide:not(.theme-wolf,.theme-likely) .play { min-height:0; padding:.35rem .6rem; justify-content:flex-start }
  .game-shell.wide .play .actions .button { min-height:38px; padding:.25rem .65rem }
  .game-shell.wide .play .table-clock { min-width:4rem; padding:.25rem .7rem }
  .game-shell.wide .play .table-clock strong { font-size:2.2rem }
  .game-shell.wide .code-machine { grid-template-columns:minmax(0,1.7fr) minmax(11rem,1fr); margin:.2rem auto; gap:.6rem }
  .game-shell.wide.theme-code .code-instruction { font-size:.82rem; line-height:1.35; margin:.2rem 0 }
  .page-game .game-shell.wide.theme-code .play .code-panel { padding:.5rem }
  .game-shell.wide .code-slots { padding:.15rem 0 .4rem }
  .game-shell.wide .code-panel .code-slots button { padding:.15rem; border-width:2px; min-height:38px }
  .game-shell.wide .code-panel .code-slots .code-dot { width:1.9rem }
  .game-shell.wide .code-palette { padding-top:.4rem; gap:.3rem }
  .game-shell.wide .code-panel .code-palette { padding-top:.25rem; gap:.25rem }
  .game-shell.wide .code-palette button { flex-direction:row; font-size:.72rem; padding:.2rem }
  .game-shell.wide .code-panel .code-palette button { min-height:34px }
  .game-shell.wide .code-machine .code-history { max-height:48dvh }
  .game-shell.wide .code-console > .actions { margin-top:.15rem }
}
