/* The game-night shuffle. Pure CSS, scoped to initial loading: no renderer,
 * asset download, invented percentage or minimum display time. Compact
 * in-game loading cues keep their existing geometry and animation. */
.boot-view--table {
  min-height: 76svh;
  gap: 14px;
  padding: 34px 20px;
}
.boot-view--table .loading-table {
  /* These are illustrated paper objects, not theme surfaces. Keep the
   * faces/pips legible in Night while surrounding UI follows its tokens. */
  --boot-paper: #fff;
  /* Pips and checks are printed ink; rims and lips are soft, and each
   * coloured card sits on a darker lip of its own colour. */
  --boot-outline: #3d2f4a;
  --boot-rim: var(--outline);
  position: relative;
  display: block;
  width: 278px;
  height: 198px;
  margin: 0 0 8px;
  isolation: isolate;
}
.boot-view--table .loading-table[hidden] { display: none; }
.boot-view--table .loading-table::before {
  content: "";
  position: absolute;
  inset: 55px 5px 5px;
  border-radius: 50%;
  background: var(--accent-soft);
  transform: rotate(-8deg);
  z-index: -1;
}
.boot-view--table .loading-table::after {
  content: "";
  position: absolute;
  width: 156px;
  height: 12px;
  bottom: 0;
  left: 61px;
  border-radius: 50%;
  background: var(--boot-outline);
  opacity: .09;
  z-index: -1;
}
.boot-view--table .loading-table i:nth-child(n) {
  position: absolute;
  top: 40px;
  display: block;
  width: 84px;
  height: 116px;
  --boot-lip: var(--boot-rim);
  border: 2px solid var(--boot-lip);
  border-radius: 13px;
  background: var(--boot-paper);
  box-shadow: 0 5px 0 var(--boot-lip);
  animation: none;
  transform-origin: 50% 90%;
}
.boot-view--table .loading-table i::before,
.boot-view--table .loading-table i::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}
.boot-view--table .loading-table i:nth-child(1) {
  left: 28px;
  top: 51px;
  transform: rotate(-19deg);
  background: var(--sun);
  --boot-lip: color-mix(in srgb, var(--sun) 70%, #000);
}
/* Five pips make the first card a die without another image or font. */
.boot-view--table .loading-table i:nth-child(1)::before {
  width: 9px;
  height: 9px;
  left: 34px;
  top: 48px;
  border-radius: 50%;
  background: var(--boot-outline);
  box-shadow: -15px -19px 0 var(--boot-outline), 15px -19px 0 var(--boot-outline), -15px 19px 0 var(--boot-outline), 15px 19px 0 var(--boot-outline);
}
.boot-view--table .loading-table i:nth-child(2) {
  left: 96px;
  top: 15px;
  z-index: 2;
  transform: rotate(-2deg);
}
.boot-view--table .loading-table i:nth-child(2)::before {
  width: 50px;
  height: 50px;
  left: 14px;
  top: 24px;
  border: 0;
  border-radius: 4px;
  background: conic-gradient(var(--boot-outline) 25%, var(--boot-paper) 0 50%, var(--boot-outline) 0 75%, var(--boot-paper) 0) 0 0 / 22px 22px;
}
.boot-view--table .loading-table i:nth-child(2)::after {
  width: 23px;
  height: 23px;
  top: 62px;
  left: 41px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--accent) 70%, #000);
}
.boot-view--table .loading-table i:nth-child(3) {
  left: 164px;
  top: 47px;
  transform: rotate(18deg);
  background: var(--teal);
  --boot-lip: color-mix(in srgb, var(--teal) 70%, #000);
}
.boot-view--table .loading-table i:nth-child(3)::before {
  width: 23px;
  height: 23px;
  left: 27px;
  top: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--boot-paper);
}
.boot-view--table .loading-table i:nth-child(3)::after {
  width: 39px;
  height: 31px;
  left: 19px;
  top: 49px;
  border: 0;
  border-radius: 48% 48% 5px 5px;
  background: var(--boot-paper);
}
.boot-view--table h1 {
  max-width: 18ch;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.15;
  text-wrap: balance;
}
.boot-view--table p { max-width: 35ch; line-height: 1.5; }
.boot-view--table .boot-reload {
  min-height: 44px;
  padding: 9px 18px;
  border: 2px solid var(--outline);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 var(--lift-sm) 0 var(--outline);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.boot-view--table .boot-reload:focus-visible {
  outline: 3px solid var(--accent-deep);
  outline-offset: 4px;
}
.boot-view--table[data-boot-state="error"] { min-height: 65svh; }
@media (prefers-reduced-motion: no-preference) {
  .boot-view--table .loading-table i:nth-child(1) { animation: boot-deal-left 3.2s ease-in-out infinite; }
  .boot-view--table .loading-table i:nth-child(2) { animation: boot-deal-centre 3.2s ease-in-out infinite; }
  .boot-view--table .loading-table i:nth-child(3) { animation: boot-deal-right 3.2s ease-in-out infinite; }
  @keyframes boot-deal-left {
    0%, 62%, 100% { transform: rotate(-19deg); }
    18%, 38% { transform: translate(8px, -9px) rotate(-25deg); }
  }
  @keyframes boot-deal-centre {
    0%, 62%, 100% { transform: rotate(-2deg); }
    24%, 42% { transform: translateY(-13px) rotate(3deg); }
  }
  @keyframes boot-deal-right {
    0%, 62%, 100% { transform: rotate(18deg); }
    30%, 46% { transform: translate(-8px, -7px) rotate(24deg); }
  }
}
@media (prefers-reduced-motion: reduce) {
  .boot-view--table .loading-table i { animation: none !important; }
}
@media (max-width: 360px) {
  .boot-view--table { padding-inline: 16px; }
  .boot-view--table .loading-table { transform: scale(.86); margin: -12px 0 -4px; }
}
@media (max-height: 480px) {
  .boot-view--table { min-height: 90svh; gap: 8px; padding-block: 16px; }
  .boot-view--table .loading-table { transform: scale(.65); height: 198px; margin: -34px 0; transform-origin: 50% 50%; }
  .boot-view--table h1 { max-width: none; font-size: 28px; }
}
/* Reload is a recovery action: hide it during a normal load, show it at
 * once on error and after a few seconds if loading is merely slow. */
.boot-view--table:not([data-boot-state="error"]) .boot-reload:not(:focus-visible) { opacity: 0; pointer-events: none; animation: boot-reload-reveal .3s ease 6s forwards; }
@keyframes boot-reload-reveal { to { opacity: 1; pointer-events: auto; } }

/* ---- Wave 1: tips while the shelf opens, a friendlier failure ---------- */
/* Three real tips share one grid cell, so the line never resizes. Under
 * reduced motion only the first shows; on failure they go away. */
.boot-view--table .boot-tips { display: grid; max-width: 36ch; margin: 0; padding: 8px 16px; border-radius: 16px; background: var(--well); color: var(--ink-dim); font-size: 14px; font-weight: 700; }
.boot-view--table .boot-tips span { grid-area: 1 / 1; }
.boot-view--table .boot-tips span:not(:first-child) { opacity: 0; }
.boot-view--table[data-boot-state="error"] .boot-tips { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .boot-view--table .boot-tips span { opacity: 0; animation: boot-tip 12s cubic-bezier(0.22, 1, 0.36, 1) infinite; }
  .boot-view--table .boot-tips span:nth-child(2) { animation-delay: 4s; }
  .boot-view--table .boot-tips span:nth-child(3) { animation-delay: 8s; }
  .boot-view--table .boot-tips span:first-child { animation-fill-mode: backwards; opacity: 1; }
  @keyframes boot-tip { 0% { opacity: 0; transform: translateY(6px); } 4%, 30% { opacity: 1; transform: none; } 34%, 100% { opacity: 0; transform: translateY(-6px); } }
}
/* Failure: one tipped-over card in place of the deal, and Reload as the
 * clear primary button. */
.boot-view--table[data-boot-state="error"]::before {
  content: "?"; display: grid; place-items: center; width: 84px; height: 116px; margin-bottom: 8px;
  border: 2px solid color-mix(in srgb, var(--sun) 70%, #000); border-radius: 13px; background: var(--sun); box-shadow: 0 5px 0 color-mix(in srgb, var(--sun) 70%, #000);
  color: var(--sun-ink); font: 800 56px/1 var(--font-display); transform: rotate(-12deg);
}
.boot-view--table[data-boot-state="error"] .boot-reload {
  --boot-btn-lip: color-mix(in srgb, var(--accent) 74%, #000);
  min-height: 48px; padding: 12px 24px; border: 2px solid var(--boot-btn-lip); border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; box-shadow: 0 4px 0 var(--boot-btn-lip);
}
.boot-view--table[data-boot-state="error"] .boot-reload:active { transform: translateY(4px); box-shadow: none; }
@media (max-height: 480px) { .boot-view--table .boot-tips { display: none; } }

/* First load of a game: its art bobs over the empty table while tips turn
 * over. Every tip shares one cell, so the card keeps its size. */
.game-preparation.is-first {
  top: 50%; bottom: auto; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 12px; width: min(360px, calc(100vw - 32px)); padding: 24px;
  border: 2px solid var(--outline); border-radius: 24px; box-shadow: 0 6px 0 var(--outline); text-align: center;
}
.game-preparation.is-first .preparation-art { width: 160px; height: 160px; object-fit: cover; border-radius: 20px; border: 0; }
.game-preparation.is-first .preparation-dots i { width: 12px; height: 12px; }
.game-preparation.is-first .preparation-text { justify-items: center; gap: 8px; font: 800 20px/1.2 var(--font-display); }
.preparation-tips { display: grid; }
.preparation-tips small { grid-area: 1 / 1; opacity: 0; transition: opacity .4s ease, transform .4s cubic-bezier(0.22, 1, 0.36, 1); transform: translateY(6px); }
.preparation-tips small.is-on { opacity: 1; transform: none; }
.game-preparation.is-first .preparation-tips small { max-width: 34ch; font-size: 14px; }
@media (prefers-reduced-motion: no-preference) {
  .game-preparation.is-first .preparation-art { animation: prep-bob 2.8s ease-in-out infinite; }
  @keyframes prep-bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
}
@media (prefers-reduced-motion: reduce) { .preparation-tips small { transition: none; transform: none; } }
@media (max-height: 520px) { .game-preparation.is-first .preparation-art { width: 88px; height: 88px; } .game-preparation.is-first { padding: 16px; gap: 8px; } }

/* The plain pre-snapshot loader gets the same sticker art. */
.game-loading .game-loading-art { border: 2px solid var(--outline); box-shadow: 0 6px 0 var(--outline); }

/* A game that failed to load: its own art, tipped over, and one big retry. */
.game-load-error { display: grid; justify-items: center; gap: 12px; max-width: 440px; padding: 32px 24px;
  border: 2px solid var(--outline); border-radius: 24px; box-shadow: 0 6px 0 var(--outline); }
.game-load-error h2 { margin: 0; font: 800 clamp(24px, 4vw, 28px)/1.15 var(--font-display); }
.game-load-error p { max-width: 34ch; margin: 0; line-height: 1.5; }
.load-error-art { position: relative; display: block; width: 120px; height: 120px; margin-bottom: 8px; transform: rotate(-12deg); }
.load-error-art img { width: 100%; height: 100%; object-fit: cover; border-radius: 18px; border: 0; filter: grayscale(.7); opacity: .85; }
.load-error-art::after { content: "!"; position: absolute; right: -12px; top: -12px; display: grid; place-items: center; width: 36px; height: 36px; border: 2px solid color-mix(in srgb, var(--sun) 70%, #000); border-radius: 50%; background: var(--sun); color: var(--sun-ink); font: 800 20px/1 var(--font-display); transform: rotate(12deg); }
.game-load-error #retryGameView { min-height: 48px; padding-inline: 32px; margin-top: 4px; }
@media (max-width: 480px) { .game-load-error { margin-inline: 16px; } }

/* First-load stage: the art hops with a little squash over its own shadow
 * while four confetti bits float around it; the headline turns over in one
 * shared cell so the card never resizes. */
.preparation-stage { position: relative; display: grid; place-items: center; padding-bottom: 14px; }
.preparation-stage::after { content: ""; position: absolute; bottom: 0; width: 120px; height: 12px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 14%, transparent); }
.preparation-stage i { position: absolute; width: 10px; height: 10px; border-radius: 3px; }
.preparation-stage i:nth-of-type(1) { left: -18px; top: 12px; background: var(--accent); transform: rotate(18deg); }
.preparation-stage i:nth-of-type(2) { right: -20px; top: 30px; background: var(--gold, #f5b82e); border-radius: 50%; }
.preparation-stage i:nth-of-type(3) { left: -8px; bottom: 34px; background: var(--green, #2bb673); border-radius: 50%; }
.preparation-stage i:nth-of-type(4) { right: -10px; bottom: 50px; background: #5aa9ff; transform: rotate(-24deg); }
.preparation-lines { display: grid; }
.preparation-lines > span { grid-area: 1 / 1; opacity: 0; transform: translateY(8px) scale(.96); transition: opacity .3s ease, transform .35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.preparation-lines > span.is-on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .game-preparation.is-first .preparation-art { animation: prep-hop 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite; transform-origin: 50% 100%; }
  .preparation-stage::after { animation: prep-shadow 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite; }
  .preparation-stage i { animation: prep-float 3.2s ease-in-out infinite; }
  .preparation-stage i:nth-of-type(2) { animation-delay: -.8s; }
  .preparation-stage i:nth-of-type(3) { animation-delay: -1.6s; }
  .preparation-stage i:nth-of-type(4) { animation-delay: -2.4s; }
  @keyframes prep-hop { 0%, 100% { transform: translateY(0) scale(1.04, .96); } 12% { transform: translateY(0) scale(1); } 45% { transform: translateY(-16px) rotate(-3deg); } 80% { transform: translateY(0) scale(1); } }
  @keyframes prep-shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 45% { transform: scaleX(.7); opacity: .55; } }
  @keyframes prep-float { 50% { translate: 0 -8px; rotate: 40deg; } }
}
@media (prefers-reduced-motion: reduce) { .preparation-lines > span { transition: none; transform: none; } }
@media (max-height: 520px) { .preparation-stage::after { width: 70px; } .preparation-stage i { display: none; } }
