/* The shared tabletop lives in the Night scene. */
.pantry-board {
  --felt-edge: #10251d;
  --felt-mid: #204131;
  --felt-light: #38533a;
  --felt-sheen: #a9bcb20c;
  --table-text: #fff0d3;
  --wake-gold: #ffcf73;
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  max-width: 56rem;
  margin-inline: auto;
}

.pantry-board::before {
  position: absolute;
  z-index: -1;
  inset: 1% 0 -4%;
  background: radial-gradient(ellipse at 50% 48%, #0b120ed9 15%, #0b120e56 58%, transparent 77%);
  content: '';
  pointer-events: none;
}

.pantry-board[data-visibility='awake'] {
  --felt-edge: #1c2e21;
  --felt-mid: #375036;
  --felt-light: #6b6642;
  --felt-sheen: #ffd78d25;
}

.pantry-board[data-visibility='asleep'] {
  --felt-edge: #0e1f19;
  --felt-mid: #162e24;
  --felt-light: #264032;
}

.pantry-table {
  position: relative;
  isolation: isolate;
  height: clamp(318px, min(63vh, 75vw), 506px);
  height: clamp(318px, min(63svh, 75vw), 506px);
  width: 100%;
}

.pantry-table::before,
.pantry-table::after {
  position: absolute;
  display: block;
  border-radius: 50%;
  content: '';
  pointer-events: none;
}

.pantry-table::before {
  z-index: -2;
  inset: 7% 2.6% 6%;
  border: 1px solid #af8659;
  background:
    radial-gradient(ellipse at 39% 1%, #efc07d8c 0%, transparent 46%),
    repeating-linear-gradient(174deg, #40241350 0 1px, #943d1422 1px 3px, transparent 3px 6px),
    linear-gradient(162deg, #966e49, #634127 47%, #8c5634 64%, #513224);
  box-shadow:
    inset 0 0 0 2px #6b452bd9,
    inset 0 0 0 4px #d8ae743b,
    0 5px 0 #432819,
    0 10px 0 #281b15,
    0 22px 26px #07100bcc;
}

.pantry-table::after {
  z-index: -1;
  inset: 10% 5.2% 9.5%;
  border: 1px solid #c19a6461;
  background:
    radial-gradient(ellipse at 45% 43%, var(--felt-sheen), transparent 51%),
    repeating-linear-gradient(126deg, #fff6bc0a 0 1px, transparent 1px 4px),
    repeating-linear-gradient(38deg, #06140d27 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 45% 43%, var(--felt-light), var(--felt-mid) 49%, var(--felt-edge) 91%);
  box-shadow:
    0 0 0 2px #302116,
    0 0 0 3px #bd8c4e63,
    inset 0 0 38px #030c07a3,
    inset 0 2px 7px #040d08a3;
}

.pantry-seats {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pantry-seat {
  position: absolute;
  z-index: 2;
  top: var(--seat-y, 50%);
  left: var(--seat-x, 50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  width: min(21%, 9rem);
  min-width: 0;
  color: var(--table-text);
  text-align: center;
  transform: translate(-50%, -50%);
}

.seat-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, clamp(45px, 10.5vw, 96px));
  height: clamp(51px, 9vw, 85px);
}

.seat-cup {
  position: absolute;
  z-index: 1;
  inset: 0 0 0;
  background: url('/assets/dice-cup.png') center 57% / contain no-repeat;
  filter: drop-shadow(0 8px 4px #07100ecc);
  transform-origin: 53% 70%;
}

.pantry-board[data-visibility='asleep'] .seat-cup {
  filter: brightness(.86) saturate(.83) drop-shadow(0 8px 5px #020a08e0);
}

.seat-eyes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, .5vw, 4px);
  padding: 2px;
  transform: translateY(16%);
  filter: drop-shadow(0 0 8px #efb35969);
}

.seat-eye {
  position: relative;
  display: block;
  width: clamp(12px, 3vw, 23px);
  height: clamp(11px, 2.5vw, 20px);
  border: 1px solid #9a6737;
  border-radius: 59% 59% 51% 51%;
  background: #fff5d9;
  box-shadow: inset 0 -2px 1px #e6c78a, 0 2px 3px #12100999;
}

.seat-eye::after {
  position: absolute;
  top: 27%;
  left: 41%;
  width: 47%;
  height: 58%;
  border-radius: 50%;
  background: radial-gradient(circle at 64% 30%, #fff9d8 0 12%, transparent 15%), #261e18;
  content: '';
}

.pantry-seat[data-awake='true'] .seat-cup {
  transform: translate(15%, -46%) rotate(15deg) scale(.63);
}

.pantry-board.is-waking [data-awake='true'] .seat-cup {
  animation: pantry-lift-cup 460ms var(--ease-out, cubic-bezier(.21,.7,.25,1)) var(--wake-delay, 0ms) both;
}

.pantry-board.is-waking .seat-eyes {
  animation: pantry-open-eyes 460ms var(--ease-out, cubic-bezier(.21,.7,.25,1)) var(--wake-delay, 0ms) both;
}

.seat-name {
  display: block;
  min-width: 0;
  max-width: 100%;
  padding: .14em .44em .19em;
  border-radius: 4px;
  background: #0d211be8;
  box-shadow: 0 2px 3px #080f0b4d;
  font-size: clamp(.82rem, 2.15vw, 1rem);
  font-weight: 700;
  line-height: 1.18;
}

.seat-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-state {
  display: block;
  margin-top: .11em;
  color: var(--wake-gold);
  font-size: .78em;
  font-weight: 650;
  line-height: 1.12;
}

.pantry-seat[data-you='true'] .seat-name {
  color: #ffdfa1;
  box-shadow: inset 0 -1px #f4c66b98, 0 2px 3px #080f0b4d;
}

.pantry-seat[data-awake='true'] .seat-name {
  color: #ffebc5;
  background: #432f20;
  box-shadow: inset 0 -1px #de9d54a3, 0 2px 4px #0a110ea6;
}

.pantry-seat[data-ready='true'] .seat-state { color: #d1e6b3; }

.pantry-center {
  position: absolute;
  z-index: 1;
  top: 48%;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: clamp(4px, 1.2vw, 10px);
  width: min(38%, 13rem);
  min-width: 0;
  text-align: center;
  transform: translate(-50%, -50%);
}

.pantry-board.is-waking .pantry-center {
  animation: pantry-uncover 460ms var(--ease-out, cubic-bezier(.21,.7,.25,1)) var(--wake-delay, 0ms) both;
}

.table-platter {
  position: relative;
  display: grid;
  place-items: center;
  width: min(90%, 11.2rem);
  aspect-ratio: 1.52;
  border: 1px solid #e9d1a4;
  border-radius: 50%;
  background: radial-gradient(ellipse at 48% 42%, #e5d4ac 6%, #b79d75 52%, #f3dfb6 54%, #d4b783 65%, #e6cb99 70%, #9e7d50 84%);
  box-shadow: inset 0 0 0 2px #fef2ce69, 0 2px #846242, 0 9px 14px #09120ca8;
}

.pantry-center[data-cheese='covered'] .table-platter::after {
  position: absolute;
  z-index: 1;
  inset: -7% 5% 11%;
  border: 1px solid #b29a6a;
  border-bottom: 3px solid #665030;
  border-radius: 49% 49% 42% 42%;
  background:
    radial-gradient(ellipse at 28% 22%, #ebc98496, transparent 59%),
    linear-gradient(147deg, #a38859, #5f5137 57%, #353729);
  box-shadow: inset 0 -4px #aa8d5752, 0 4px 6px #0a100bb0;
  content: '';
}

.pantry-center[data-cheese='covered'] .table-platter::before {
  position: absolute;
  z-index: 2;
  top: -14%;
  width: 17%;
  height: 14%;
  border: 1px solid #bfa572;
  border-radius: 55% 55% 32% 32%;
  background: linear-gradient(144deg, #e1bb78, #796743 73%);
  content: '';
}

.table-platter .cheese-token {
  position: absolute;
  inset: auto 4% 8%;
  display: block;
  width: 92%;
  height: 119%;
  clip-path: none;
  background: url('/assets/cheese-token.png') center / contain no-repeat;
  filter: drop-shadow(0 5px 5px #694427aa);
}

.table-platter .is-taken {
  animation: pantry-take-cheese 650ms cubic-bezier(.36,.04,.59,.93) var(--cheese-delay, 0ms) both;
}

.pantry-status {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: #fff2d7;
  font-size: clamp(.78rem, 2.22vw, .97rem);
  font-weight: 700;
  line-height: 1.14;
  text-shadow: 0 1px 3px #08180e, 0 2px 5px #08180e;
}

.pantry-center[data-cheese='covered'] .pantry-status { color: #e2dabf; }
.pantry-center[data-cheese='missing'] .pantry-status { color: #ffcf95; }

@keyframes pantry-lift-cup {
  0% { transform: translate(0,0); }
  21% { transform: translate(-5%,5%) rotate(-6deg); }
  68% { transform: translate(18%,-55%) rotate(21deg) scale(.65); }
  100% { transform: translate(15%,-46%) rotate(15deg) scale(.63); }
}

@keyframes pantry-open-eyes {
  0%, 21% { opacity: 0; transform: translateY(21%) scaleY(.24); }
  64% { opacity: 1; transform: translateY(12%) scaleY(1.08); }
  100% { opacity: 1; transform: translateY(16%) scaleY(1); }
}

@keyframes pantry-uncover {
  from { opacity: .44; transform: translate(-50%,-50%) scale(.95); }
  to { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}

@keyframes pantry-take-cheese {
  0% { opacity: 1; transform: translate(0,0) rotate(0); }
  20% { opacity: 1; transform: translate(-4%,2%) rotate(-4deg); }
  63% { opacity: .92; transform: translate(29%,-24%) rotate(14deg) scale(.8); }
  100% { opacity: 0; visibility: hidden; transform: translate(65%,-47%) rotate(21deg) scale(.56); }
}

@media (max-width: 500px) {
  .pantry-table { height: clamp(252px, min(78vw, 53svh), 350px); }
  .pantry-table::before { inset: 8% 1.5% 7%; }
  .pantry-table::after { inset: 10.5% 4% 10%; }
  .seat-visual { height: clamp(35px, 11vw, 51px); }
  .seat-name { padding-inline: .28em; }
  .pantry-center { top: 48%; width: min(36%, 9.3rem); }
}

@media (max-width: 360px) {
  .pantry-seat { width: min(21%, 4.15rem); }
}

@media (max-width: 375px) and (max-height: 650px) and (orientation: portrait) {
  .scene-night:has(.recruitment) .pantry-table { height: 214px; }
}

@media (max-height: 530px) and (orientation: landscape) {
  .pantry-table { height: clamp(198px, 59svh, 300px); }
  .seat-visual { height: clamp(30px, 10svh, 48px); }
  .pantry-center { top: 46%; gap: 4px; }
  .table-platter { width: min(75%, 9rem); }
}

@media (max-width: 500px) and (orientation: portrait) {
  /* The host reaches the next hour after the optional choices. */
  .scene-night:has(.recruitment) > .host-advance-dock { order: 1; padding: 0; }
  .scene-night:has(.recruitment) .scene-main > :is(.pantry-board, .dawn-platter) { order: 2; }
  .scene-night[data-mode='online'] .scene-main > .stage-progress:has(.phase-time) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    position: sticky;
    inset-block-start: var(--safe-top);
    z-index: 3;
    padding-inline: 8px;
    border-radius: 5px;
    background: #20362c;
    box-shadow: inset 0 0 0 1px var(--frame);
  }
  .scene-night[data-mode='online'] .stage-progress .phase-time { grid-column: 2; }
  :root:has(.scene-night[data-mode='online'] .phase-time) {
    scroll-padding-block-start: calc(45px + var(--safe-top));
  }
}

@media (min-width: 520px) and (max-height: 465px) and (orientation: landscape) {
  .scene-night:has(.recruitment) {
    --night-side-clearance: 61px;
    grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr);
    grid-template-areas:
      "steps steps"
      "heading utility"
      "progress progress"
      "recruit side";
    gap: 8px 14px;
  }
  .scene-night:has(.recruitment):is([data-mode='online'], [data-night-stage='dawn']) {
    --night-side-clearance: 68px;
    grid-template-areas:
      "steps steps"
      "heading utility"
      "recruit side";
  }
  .scene-night:has(.recruitment) > .round-steps { grid-area: steps; }
  .scene-night:has(.recruitment) > .scene-header { grid-area: heading; }
  .scene-night:has(.recruitment) .scene-header h2 { font-size: clamp(1.8rem, 4.2vw, 2.65rem); }
  .scene-night:has(.recruitment) .scene-main > .scene-utility { grid-area: utility; justify-content: end; }
  .scene-night:has(.recruitment) .scene-main > .recruitment { grid-area: recruit; align-self: start; }
  .scene-night:has(.recruitment) .recruitment h3 { font-size: 1.18rem; }
  .scene-night:has(.recruitment) .scene-main > .stage-progress { grid-area: progress; }
  /* Both side items share a track so the control stays beside the scrolling list. */
  .scene-night:has(.recruitment) .scene-main > :is(.pantry-board, .dawn-platter) {
    grid-area: side;
    align-self: start;
    margin-block-start: var(--night-side-clearance);
  }
  .scene-night[data-mode='table']:has(.recruitment) > .host-advance-dock,
  .scene-night[data-mode='online']:has(.recruitment) .scene-main > .stage-progress {
    grid-area: side;
    position: sticky;
    inset: max(10px, var(--safe-top)) auto auto;
    inset-block-start: max(10px, var(--safe-top), calc(40dvh - 42px));
    z-index: 3;
    align-self: start;
  }
  .scene-night[data-mode='table']:has(.recruitment) > .host-advance-dock {
    justify-items: stretch;
    padding: 0;
  }
  .scene-night:has(.recruitment) .host-advance { width: 100%; }
  .scene-night[data-mode='online']:has(.recruitment) .scene-main > .stage-progress {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--frame);
    border-radius: 5px;
    background: #20362c;
  }
  .scene-night[data-mode='online']:has(.recruitment) .stage-progress .phase-time { grid-column: 2; }
  .scene-night[data-mode='online']:has(.recruitment) .stage-progress .stage-note { font-size: .88rem; line-height: 1.3; }
  .scene-night:has(.recruitment) .seat-name { padding-inline: .28em; font-size: .87rem; }
  .scene-night:has(.recruitment) .seat-state { font-size: .7em; white-space: nowrap; }
}

@media (min-width: 580px) and (max-height: 465px) and (orientation: landscape) {
  .scene-night:has(.pantry-board) .scene-main > .recruit-receipt { grid-area: recruit; }
}

@media (prefers-reduced-motion: reduce) {
  .pantry-board.is-waking [data-awake='true'] .seat-cup,
  .pantry-board.is-waking .seat-eyes,
  .pantry-board.is-waking .pantry-center,
  .table-platter .is-taken {
    animation: none;
  }
  .table-platter .is-taken { visibility: hidden; }
}
