.tabletop {
  --fir-dark: #091c20;
  --line: #50665d;
  --muted: #becac1;
  background: radial-gradient(ellipse at 54% -12%, #214643 0, #0d2527 33rem, #091c20 64rem);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
.setup-hero {
  display: grid;
  grid-template-columns: minmax(0,.82fr) minmax(0,1.22fr);
  align-items: center;
  gap: clamp(1.05rem,3vw,3rem);
  padding: clamp(1rem,3.8vw,3.7rem) 0;
  min-height: 0;
  background: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.setup-intro h1 { font-size: clamp(3rem, 6.7vw, 7rem); max-width: 10ch; }
.setup-intro em { font-weight: normal; color: #efbd71; }
.setup-intro p { font: clamp(1.14rem,1.55vw,1.45rem)/1.44 var(--display); margin-top: 1.15rem; }
.setup-intro .actions { margin-top: 1.45rem; }
.setup-grid { margin-top: clamp(1.7rem,4vw,3.4rem); scroll-margin-top: 1rem; }
.setup-details h2, .setup-party h2 { font-size: clamp(1.75rem,2.4vw,2.5rem); }
.mode-picker { display: grid; gap: .44rem; }
.mode-picker label { padding: .65rem .75rem; background: #102a2a; margin: 0; }
.mode-picker label:has(:checked) { background: #283c34; border-color: #e6b56c; }
#story-settings { margin-top: .85rem; }
.bot-count { max-width: 23rem; margin-top: 1rem; }
#bot-preview { font-size: .85rem; padding-top: .28rem; }
.hero-pick { background: #102728; }
.hero-pick:has(:checked) { background: #263d33; }

.stage-host { min-width: 0; }
.table-3d {
  min-height: 20rem;
  height: clamp(20rem,36vw,30rem);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid #6c7662;
  background: #11292c url("../assets/tavolo.webp") center 48% / cover;
  box-shadow: inset 0 0 3rem #061a1f, 0 1.8rem 3.2rem #0511149e;
}
.table-3d.has-webgl {
  background: radial-gradient(ellipse at 49% 44%, #315052a6 0%, #142e31d9 59%, #0b2024fa 100%), url("../assets/tavolo.webp") center / cover;
}
.table-3d.has-webgl::before {
  content: "";
  position: absolute;
  inset: auto 13% 13%;
  height: 28%;
  background: radial-gradient(ellipse, #071619bd, transparent 70%);
  pointer-events: none;
}
.table-3d canvas { width: 100%; height: 100%; position: absolute; inset: 0; opacity: 0; outline: 0; }
.table-3d.has-webgl canvas { opacity: 1; cursor: grab; touch-action: pan-y; }
.table-3d.is-orbiting canvas { cursor: grabbing; }
.table-snow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.table-snow i {
  position: absolute; left: var(--x); top: -1rem; width: var(--size); aspect-ratio: 1;
  border-radius: 50%; background: #dce8df; opacity: .46;
  animation: snowfall var(--duration) linear var(--delay) infinite;
}
@keyframes snowfall { 0% { transform: translate(0,0); opacity: 0; } 12%,85% { opacity: .45; } 100% { transform: translate(2.8rem,32rem); opacity: 0; } }
.table-place { position: absolute; left: .75rem; top: .7rem; max-width: calc(100% - 1.5rem); background: #071d21e8; border: 1px solid #7d8b72; color: #f9e9c2; border-radius: .36rem; padding: .34rem .53rem; font-size: .83rem; font-weight: 650; }
.table-marker {
  position: absolute; z-index: 1; width: 2rem; height: 2rem; padding: 0; border-radius: 50%;
  background: #1d3836e8; border: 1px solid #ffcc78; box-shadow: 0 0 1.35rem #ffd3898f; color: #fbe0ad;
  transform: translate(-50%,-68%); display: grid; place-items: center;
}
.table-marker::before { content: attr(data-count); font-size: .8rem; font-weight: 750; }
.table-3d:not(.has-webgl) .table-marker { display:none; }
.table-3d-controls { position: absolute; right: .65rem; bottom: .65rem; display: flex; padding: .19rem; border: 1px solid #6c806f; background: #0a2226e8; border-radius: .5rem; }
.table-3d-controls button { display: grid; width: 2.45rem; height: 2.37rem; place-items: center; padding: .35rem; background: transparent; border: 0; color: #f1d29a; border-radius: .3rem; }
.table-3d-controls button:hover { background: #314b42; }
.table-3d-controls svg { width: 1.14rem; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.table-3d-status { position: absolute; bottom: .65rem; left: .65rem; right: .65rem; width: fit-content; max-width: calc(100% - 1.3rem); background: #0b2126ed; font-size: .85rem; padding: .35rem .5rem; border-radius: .3rem; }
.table-roll { position: absolute; z-index: 2; pointer-events: none; top: 50%; left: 50%; transform: translate(-50%,-50%); display: grid; place-items: center; gap: .34rem; filter: drop-shadow(0 .55rem 1rem #091d1e); }
.roll-die { width: clamp(5.4rem,10vw,8.5rem); aspect-ratio: 1; display: grid; place-items: center; color: #281f12; font: bold clamp(1.7rem,3vw,3.1rem)/1 var(--display); clip-path: polygon(50% 0,90% 22%,96% 67%,66% 94%,34% 94%,4% 67%,10% 22%); background: conic-gradient(from 23deg,#fbd994 0% 19%,#a47035 19% 34%,#f2ba6a 34% 49%,#c88a42 49% 64%,#efc581 64% 79%,#f9d690 79%); }
.roll-die output { display: grid; place-items: center; width: 58%; aspect-ratio: 1; clip-path: polygon(50% 0,100% 78%,70% 100%,30% 100%,0 78%); background: #f7d598; }
.table-roll small { background: #071c21; padding: .15rem .5rem; border-radius: .25rem; }
.is-rolling .roll-die { animation: roll-on-table .64s cubic-bezier(.15,.55,.31,1.22); }
@keyframes roll-on-table { 0% { transform: translate(-60%,-40%) rotate3d(1,1,1,720deg) scale(.25); } 70% { transform: rotate3d(1,1,1,22deg) scale(1.12); } 100% { transform: none; } }
#play-stage .table-3d { height: clamp(19rem,29vw,25rem); }
.play-grid { grid-template-columns: minmax(0,2.5fr) minmax(17rem,1fr); }
.play-side .toolkit { border-color: #374e49; }
.views { margin-top: .85rem; }
.views #show-board { margin-left: auto; font-size: .88rem; }
.choice { background: #132d2e; border-color: #718067; }
.choice:hover { background: #203d3b; }
.play-side .party-summary { border-left: 3px solid var(--pawn); border-radius: .25rem; }
.party-summary .bot-label {
  display: inline-block; font: 650 .71rem var(--body); color: #dfc087; letter-spacing: .01em;
  padding: .08rem .31rem; border: 1px solid #6d7861; border-radius: .23rem; vertical-align: middle;
}
.bot-companion { margin-top: 1rem; background: #142f31; border: 1px solid #5b776d; border-radius: .56rem; padding: .85rem; }
.bot-companion h3 { font-size: 1.32rem; margin-bottom: .42rem; }
.bot-companion .muted { font-size: .9rem; }
.bot-speech { display: flex; gap: .65rem; align-items: start; padding: .63rem; background: #1d3a38; border-radius: .4rem; margin-block: .48rem; }
.bot-speech p { font-family: var(--display); margin-top: .18rem; font-size: 1.14rem; line-height: 1.34; }
.bot-companion .actions { margin-top: .55rem; }
.bot-form { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .45rem; }
.bot-form summary { font-weight: 700; }
.lesson-tabs { margin: .95rem 0 1.15rem; }
.lesson-tabs button[aria-pressed="true"] { background: #efb85b; color: #282311; border-color: #efb85b; }
.academy-grid { display: grid; grid-template-columns: minmax(0,1.03fr) minmax(0,1fr); gap: clamp(1rem,3vw,2.65rem); align-items: start; }
.academy .table-3d { height: clamp(19rem,34vw,27rem); }
#lesson-content { min-width: 0; }
.lesson-setup p { margin-top: .35rem; }
.mentor-label { color: #e9c181; font-size: .88rem; font-weight: 720; }
.lesson-world { margin: .85rem 0; color: #e0e5d7; }
.lesson-recap > p { margin: .6rem 0; }
.mentor-feedback { padding: .72rem; border-left: 3px solid #e8bb73; background: #273e36; margin: .8rem 0; }
.mentor-feedback h3 { font-size: 1.42rem; margin-bottom: .28rem; }
.mini-check { margin-bottom: .7rem; }
.mini-check p { margin-top: .3rem; }
.own-reply { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .6rem; }
.own-reply p { margin-top: .3rem; color: var(--muted); font-size: .89rem; }
@media (max-width: 850px) { .play-grid { grid-template-columns: minmax(0,1.65fr) minmax(15rem,1fr); } }
@media (max-width: 720px) {
  .setup-hero, .academy-grid { grid-template-columns: 1fr; }
  .setup-intro h1 { max-width: none; font-size: clamp(3rem,12vw,4.2rem); }
  .setup-hero { padding-block: .5rem 1.25rem; gap: 1.4rem; }
  .table-3d, #play-stage .table-3d { height: clamp(18rem,75vw,22rem); min-height: 0; }
  .play-grid { grid-template-columns: minmax(0,1fr); }
  .academy-grid { gap: 1.25rem; }
}
@media (max-width: 440px) {
  .table-3d-controls button { width: 2.1rem; height: 2.1rem; }
  .setup-intro .actions .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .table-snow i, .is-rolling .roll-die { animation: none; } }
