:root {
  --bg: #140e0a;
  --bg-2: #1f1611;
  --card: #241a14;
  --card-2: #2d211a;
  --line: rgba(255, 228, 190, 0.12);
  --text: #f6ecdc;
  --muted: #b7a690;
  --red: #e1262a;
  --red-deep: #a8191c;
  --green: #b9dba1;
  --green-deep: #3f7a3a;
  --gold: #f2c94c;
  --ivory: #f8f1df;
  --win: #7ddc8a;
  --loss: #ff7b72;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
  /* shared game shell (assets/game-shell.css) */
  --gs-bg: var(--bg); --gs-panel: var(--card); --gs-text: var(--text); --gs-muted: var(--muted);
  --gs-accent: #ee3a36; --gs-accent-2: var(--red-deep); --gs-accent-ink: #fff;
  --gs-display: Inter, "Segoe UI", system-ui, sans-serif; --gs-body: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 30% -10%, rgba(225, 38, 42, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(185, 219, 161, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button, .seg, .topbar, .tile, .pill { -webkit-user-select: none; user-select: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

[lang="ne"], small[lang="ne"] { font-family: "Noto Sans Devanagari", "Nirmala UI", Inter, sans-serif; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 12px; opacity: 0.8; margin-left: 6px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
img { display: block; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: rgba(255, 228, 190, 0.35); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(180deg, #ee3a36, var(--red-deep));
  border-color: #ff6a5c;
  box-shadow: 0 6px 18px rgba(225, 38, 42, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.icon { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 999px; }
.btn.iconic { display: inline-flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------- header */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(20, 14, 10, 0.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; background: var(--green); border: 3px solid var(--red); }
.brand h1 { font-size: 22px; font-weight: 900; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.top-actions [data-gs-icon] { display: contents; }
.gs-start .gs-title { font-weight: 900; color: var(--text); letter-spacing: -0.02em; }
.gs-start .gs-title-row img { border-radius: 14px; }
.gs-start .gs-sub { max-width: 34ch; }
.topbar > a.btn.icon { flex: none; margin-right: -8px; color: var(--muted); text-decoration: none; }
.topbar > a.btn.icon:hover { color: var(--text); }

/* ------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.scene-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #1b130e;
}
.scene { width: 100%; aspect-ratio: 3 / 2; max-height: calc(100vh - 230px); min-height: 300px; }
.scene canvas { display: block; width: 100% !important; height: 100% !important; touch-action: manipulation; }
.scene-fallback { display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

.stage-status { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.stage-status > * { pointer-events: auto; }
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(20, 14, 10, 0.78);
  border: 1px solid var(--line);
}
.pill[data-state="ROLLING"], .pill[data-state="LOCKED"] { color: var(--gold); border-color: rgba(242, 201, 76, 0.5); }
.pill[data-state="COMPLETE"] { color: var(--win); }

/* ------------------------------------------------------- result strip */
.result-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 16px;
  min-height: 76px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}
.dice-row { display: flex; gap: 8px; }
.die {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background: var(--ivory);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.35);
  padding: 4px;
  animation: pop 0.35s both;
}
.die img { width: 100%; height: 100%; }
.die:nth-child(2) { animation-delay: 0.05s; }
.die:nth-child(3) { animation-delay: 0.1s; }
.die:nth-child(4) { animation-delay: 0.15s; }
.die:nth-child(5) { animation-delay: 0.2s; }
.die:nth-child(6) { animation-delay: 0.25s; }
.die.rolling { background: linear-gradient(135deg, var(--ivory), #d9cfb8); animation: wobble 0.5s infinite alternate; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wobble { from { transform: rotate(-8deg); } to { transform: rotate(8deg) translateY(-3px); } }

/* -------------------------------------------------------------- panel */
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.start-bar { display: flex; gap: 10px; }
.btn.start.lift:not(.primary) { font-size: 18px; }
.btn.start:disabled { animation: none; }
.btn.start {
  flex: 1;
  height: 64px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 16px;
}
.btn.start:not(:disabled) { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 6px 28px rgba(225, 38, 42, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.25); } }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--green);
  color: #151515;
  box-shadow: inset 0 0 0 3px var(--gold);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.tile img { width: 46px; height: 46px; border-radius: 8px; }
.tile-name { font-weight: 800; font-size: 13px; }
.tile-name small { font-weight: 600; opacity: 0.75; }
.tile-count { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; }
.tile:not(.hit):not(.idle) { opacity: 0.45; }
.tile.hit { box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 3px var(--gold), 0 0 22px rgba(242, 201, 76, 0.55); transform: translateY(-2px); }
.tile.hit .tile-count { color: var(--red-deep); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
th:first-child, td:first-child { text-align: left; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0; }
.muted { color: var(--muted); }
.scene.ready canvas { cursor: pointer; }
.skip { position: absolute; bottom: 12px; right: 12px; }
.view-ctrls { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.view-ctrls .btn { background: rgba(20, 14, 10, 0.78); }
.view-ctrls .btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.view-ctrls .fs-btn { display: inline-flex; align-items: center; gap: 6px; }
.view-ctrls .fs-btn svg { width: 16px; height: 16px; }
.view-ctrls .fs-btn [data-gs-icon] { display: contents; }
html.gs-fullscreen .view-ctrls .fs-btn span { display: none; }
@media (max-width: 440px) { .view-ctrls .fs-btn span { display: none; } }
.scene.portrait { aspect-ratio: 4 / 5; max-height: calc(100vh - 160px); }

/* -------------------------------------------------------- tabs (mobile) */
.seg { display: none; }
.seg-btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg-btn[aria-selected="true"] { background: var(--card-2); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.seg-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: rgba(242, 201, 76, 0.18); color: var(--gold); font-size: 11px; line-height: 18px; }
.seg-badge:empty { display: none; }

/* ------------------------------------------------------------ history */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 280px; overflow: auto; }
.history li { display: grid; grid-template-columns: 40px auto 1fr; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.history li.muted { display: block; border: 0; }
.h-num { color: var(--muted); font-size: 12px; }
.h-dice { display: flex; gap: 3px; }
.h-dice img { width: 22px; height: 22px; border-radius: 5px; }
.h-top { text-align: right; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ dialogs */
.dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.dialog-head h2 { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }
.dialog-body { padding: 8px 20px 20px; }
.rules { padding-left: 20px; }
.rules li { margin: 6px 0; }
kbd { padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--bg-2); font: 700 12px Inter, sans-serif; }
.settings fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; padding: 10px 14px 14px; }
.settings legend { font-weight: 800; padding: 0 6px; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.row select, .row input[type="range"] { flex: 1; }
select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--red); }
input[type="range"] { accent-color: var(--gold); }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  box-shadow: var(--shadow);
  animation: pop 0.2s both;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.error { border-left-color: var(--loss); }
.toast.warn { border-left-color: #ffb347; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* --------------------------------------------------------- responsive */
@media (max-width: 1100px) and (orientation: portrait) {
  .layout { grid-template-columns: 1fr; }
  .scene { max-height: none; }
}
/* Tablets and small laptops held sideways: keep the mat and the controls side by side so Roll stays on screen. */
@media (max-width: 1100px) and (orientation: landscape) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; padding: 14px 16px 20px; }
  .scene { min-height: 0; }
}
@media (max-width: 760px) {
  /* App shell: one screen, no page scroll; the mat fills whatever is left. */
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; height: 100svh; height: var(--gs-vh, 100svh); background: var(--bg); }
  .topbar {
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    gap: 10px;
    background: var(--bg);
    backdrop-filter: none;
  }
  .brand { gap: 10px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; border-width: 2px; }
  .brand h1 { font-size: 18px; }
  .brand p { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .btn { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 999px; border-color: transparent; }
  .top-actions .btn span { display: none; }
  .top-actions .btn:active { background: var(--card-2); }
  .top-actions svg { width: 22px; height: 22px; }

  .layout { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 0; max-width: none; width: 100%; margin: 0; }
  .stage { flex: 1; min-height: 0; gap: 0; position: relative; }
  .scene-wrap { flex: 1; min-height: 0; border-radius: 0; border: 0; box-shadow: none; }
  /* Absolute so the canvas size can't feed back into the flex layout. */
  .scene, .scene.portrait { position: absolute; inset: 0; aspect-ratio: auto; min-height: 0; max-height: none; }
  .stage-status { top: 10px; left: 12px; }
  .view-ctrls { top: 10px; right: 12px; }
  .view-ctrls .btn, .skip { backdrop-filter: blur(8px); border-radius: 999px; padding: 7px 12px; }
  .skip { bottom: 28px; right: 12px; }

  /* Dice result floats over the bottom edge of the mat. */
  .result-strip {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 28px;
    min-height: 0;
    padding: 8px 10px;
    justify-content: center;
    background: rgba(20, 14, 10, 0.72);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    font-size: 13px;
    text-align: center;
    pointer-events: none;
  }
  .stage:has(.skip:not([hidden])) .result-strip { right: 88px; }
  .result-strip:has(.muted) { display: none; }
  .dice-row { gap: 6px; }
  .die { width: 38px; height: 38px; border-radius: 8px; padding: 3px; }

  /* Bottom sheet: tabs, the active card, then the thumb-reach action bar. */
  .panel {
    flex: none;
    gap: 10px;
    padding: 10px max(12px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom, 0px) + var(--gs-bottom-gap, 0px)) max(12px, env(safe-area-inset-left));
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    margin-top: -16px;
    position: relative;
    z-index: 2;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  }
  .panel::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: rgba(255, 228, 190, 0.2); margin: -2px auto 0; }
  .seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); }
  .panel .card { padding: 0; background: none; border: 0; box-shadow: none; }
  .panel .card h2 { display: none; }
  .panel[data-tab="result"] .tab-history,
  .panel[data-tab="history"] .tab-result { display: none; }

  .tiles { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .tile { padding: 6px 2px 4px; border-radius: 10px; gap: 0; box-shadow: inset 0 0 0 2px var(--gold); }
  .tile img { width: 34px; height: 34px; border-radius: 6px; }
  .tile-name { font-size: 10px; line-height: 1.2; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tile-name small { display: none; }
  .tile-count { font-size: 17px; line-height: 1.2; }
  .tile.hit { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px var(--gold), 0 0 16px rgba(242, 201, 76, 0.5); }

  .history { height: 92px; max-height: none; overscroll-behavior: contain; }
  .history li { grid-template-columns: 34px auto 1fr; }
  .h-dice img { width: 20px; height: 20px; }

  .start-bar { order: 10; gap: 8px; }
  .btn.start { height: 56px; font-size: 17px; border-radius: 16px; }
  .btn.start { white-space: nowrap; letter-spacing: 0.02em; }
  .btn.start.lift { font-size: 14px !important; }
  .btn.start:active:not(:disabled) { transform: scale(0.97); }

  .toasts { top: calc(64px + env(safe-area-inset-top)); bottom: auto; left: 12px; right: 12px; max-width: none; }

  /* Dialogs become bottom sheets. */
  .dialog {
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior: contain;
  }
  .dialog[open] { animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
  .dialog-head { padding: 14px 16px; }
  .dialog-body { padding: 4px 16px 20px; }
  .row { min-height: 40px; }
}
/* "Tap the mat" prompt: tapping the 3D mat rolls, and lifts the bucket when the dice are covered. */
.tap-hint {
  position: absolute; left: 50%; bottom: 16px; z-index: 3; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 10px; border-radius: 999px;
  background: rgba(20, 14, 10, 0.8); border: 1px solid rgba(242, 201, 76, 0.6); color: var(--ivory);
  font-weight: 800; font-size: 15px; white-space: nowrap; pointer-events: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: hint-in 0.3s ease both;
}
.tap-hint[hidden] { display: none; }
.tap-ring { position: relative; width: 26px; height: 26px; flex: none; }
.tap-ring::before, .tap-ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.tap-ring::before { background: var(--gold); transform: scale(0.42); box-shadow: 0 0 10px rgba(242, 201, 76, 0.8); }
.tap-ring::after { border: 2px solid var(--gold); animation: tap-pulse 1.4s ease-out infinite; }
@keyframes tap-pulse { 0% { transform: scale(0.45); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translateX(-50%); } }
/* The button for the next step glows so it is obvious what to press. */
.btn.start.attention:not(:disabled) { animation: next-step 1.6s ease-in-out infinite; }
@keyframes next-step { 0%, 100% { box-shadow: 0 6px 18px rgba(225, 38, 42, 0.35), 0 0 0 0 rgba(242, 201, 76, 0); } 50% { box-shadow: 0 6px 18px rgba(225, 38, 42, 0.5), 0 0 0 5px rgba(242, 201, 76, 0.45); } }
@media (max-width: 760px) {
  .tap-hint { bottom: 32px; font-size: 14px; }
  .stage:has(.result-strip .dice-row) .tap-hint { bottom: 100px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .tap-hint { bottom: 12px; font-size: 13px; }
  .stage:has(.result-strip .dice-row) .tap-hint { bottom: 72px; }
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
/* Phones held sideways (any width): the mat fills the left side at full height, and the controls sit in a
   column on the right with Roll and Pick up bucket first, so they are always on screen. */
@media (orientation: landscape) and (max-height: 500px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; height: 100svh; height: var(--gs-vh, 100svh); background: var(--bg); }
  .topbar {
    padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    gap: 10px; background: var(--bg); backdrop-filter: none;
  }
  .brand { gap: 8px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; border-width: 2px; }
  .brand h1 { font-size: 17px; }
  .brand p { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .btn { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 999px; border-color: transparent; }
  .top-actions .btn span { display: none; }

  .layout { flex: 1; min-height: 0; display: flex; flex-direction: row; gap: 0; padding: 0; max-width: none; width: 100%; margin: 0; }
  .stage { flex: 1; min-height: 0; min-width: 0; gap: 0; position: relative; }
  .scene-wrap { flex: 1; min-height: 0; border-radius: 0; border: 0; box-shadow: none; }
  .scene, .scene.portrait { position: absolute; inset: 0; aspect-ratio: auto; min-height: 0; max-height: none; }
  .stage-status { top: 8px; left: 10px; }
  .view-ctrls { top: 8px; right: 10px; }
  .result-strip {
    position: absolute; left: 10px; right: 10px; bottom: 10px; min-height: 0; padding: 6px 10px;
    justify-content: center; background: rgba(20, 14, 10, 0.72); backdrop-filter: blur(10px);
    border-radius: 12px; font-size: 13px; text-align: center; pointer-events: none;
  }
  .result-strip:has(.muted) { display: none; }

  .panel {
    flex: none; width: min(40vw, 300px); display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
    margin: 0; border-radius: 0; box-shadow: none; border-left: 1px solid var(--line); border-top: 0;
    padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom, 0px) + var(--gs-bottom-gap, 0px)) 10px;
    background: var(--bg-2);
  }
  .panel::before { display: none; }
  .start-bar { order: -1; display: grid; grid-template-columns: 1fr; gap: 6px; }
  .btn.start { height: 46px; font-size: 16px; border-radius: 14px; white-space: nowrap; }
  .btn.start.lift { font-size: 13px !important; }
  .seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); }
  .panel .card { padding: 0; background: none; border: 0; box-shadow: none; }
  .panel .card h2 { display: none; }
  .panel[data-tab="result"] .tab-history, .panel[data-tab="history"] .tab-result { display: none; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .tile { padding: 4px 2px; border-radius: 10px; gap: 0; }
  .tile img { width: 28px; height: 28px; border-radius: 6px; }
  .tile-name { display: none; }
  .tile-count { font-size: 16px; line-height: 1.2; }
  .history { height: auto; max-height: none; }
}
@media (max-width: 760px) and (max-height: 620px) {
  .tile-name { display: none; }
  .history { height: 64px; }
  .btn.start { height: 50px; }
}
@media (max-width: 360px) {
  .die { width: 32px; height: 32px; }
  .tile img { width: 28px; height: 28px; }
  .tiles { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
