:root {
  --h3-indigo: #16233d;
  --h3-indigo-deep: #0d1526;
  --h3-jade: #1f5c4d;
  --h3-jade-bright: #2e8b74;
  --h3-brass: #d9b25f;
  --h3-brass-dim: #8a6a2f;
  --h3-parchment: #f0e6cf;
  --h3-lantern: #ffb45e;
  --h3-cell: #10202f;
  --h3-cell-line: #33506b;
  --h3-danger: #e0685e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--h3-indigo-deep);
  color: var(--h3-parchment);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

.h3-app {
  height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.h3-top { text-align: center; }
.h3-title-block {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}
.h3-title {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--h3-brass);
  letter-spacing: 2px;
  font-size: 30px;
  margin: 4px 0 0;
}
.h3-beta {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--h3-indigo-deep);
  background: var(--h3-lantern);
  border-radius: 4px;
  padding: 2px 8px;
}
.h3-demo-note { margin: 2px 0 0; font-size: 13px; color: #b9c4d6; }

.h3-feature-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  justify-content: center;
  border: 2px solid var(--h3-lantern);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 15px;
  background: #241a10;
}
.h3-feature-banner strong { color: var(--h3-lantern); letter-spacing: 2px; }
.h3-fs-status { font-size: 13px; color: #b9c4d6; }

.h3-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.h3-board-wrap {
  border: 3px solid var(--h3-brass-dim);
  border-radius: 10px;
  background: var(--h3-indigo);
  padding: 8px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.h3-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
}
.h3-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--h3-cell);
  border: 1px solid var(--h3-cell-line);
  border-radius: 6px;
  overflow: hidden;
  text-align: center;
  padding: 4px;
}
.h3-cell-short { font-family: Georgia, serif; font-size: 24px; font-weight: 700; }
.h3-cell-name { font-size: 11px; color: #b9c4d6; }
.h3-cell[data-kind="premium"] { background: #123b33; }
.h3-cell[data-kind="premium"] .h3-cell-short { color: #ffe9b8; }
.h3-cell[data-kind="plaque"] .h3-cell-short { color: var(--h3-brass); }
.h3-cell[data-kind="wild"] { background: #3a2f12; border-color: var(--h3-brass); }
.h3-cell[data-kind="wild"] .h3-cell-short { color: var(--h3-lantern); font-size: 19px; }
.h3-cell[data-kind="scatter"] { background: #3a2410; border-color: var(--h3-lantern); }
.h3-cell[data-kind="scatter"] .h3-cell-short { color: var(--h3-lantern); font-size: 15px; }
.h3-cell.win { outline: 3px solid var(--h3-lantern); outline-offset: -3px; }
.h3-cell.win-alt { outline-color: #fff3d6; background: #4a3013; }
.h3-cell.travelling { filter: brightness(1.25); }
.h3-lines-label {
  margin: 6px 0 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--h3-brass);
}
.h3-ph-caption { margin: 2px 0 0; text-align: center; font-size: 12px; color: #8d99ae; }

.h3-panel {
  border: 2px solid var(--h3-brass-dim);
  border-radius: 10px;
  background: #0f1c33;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.h3-meters { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.h3-meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.h3-meter-label { font-size: 12px; letter-spacing: 2px; color: #b9c4d6; }
.h3-meter-value { font-size: 22px; font-weight: 700; color: #fff; min-height: 30px; }
.h3-bet-row { display: flex; align-items: center; gap: 8px; }

.h3-status { margin: 0; font-size: 15px; min-height: 21px; }
.h3-alert-row { display: flex; gap: 10px; align-items: center; }
.h3-feature-banner[hidden], .h3-alert-row[hidden] { display: none; }
.h3-alert { margin: 0; flex: 1; color: var(--h3-danger); font-size: 15px; }

.h3-btn {
  font: inherit;
  color: var(--h3-parchment);
  background: #1b2c4a;
  border: 2px solid var(--h3-brass-dim);
  border-radius: 8px;
  min-height: 48px;
  min-width: 48px;
  padding: 8px 16px;
  cursor: pointer;
}
.h3-btn:disabled { opacity: 0.45; cursor: default; }
.h3-btn:focus-visible { outline: 2px solid var(--h3-lantern); outline-offset: 2px; }
.h3-step { font-size: 22px; line-height: 1; padding: 4px 14px; }
.h3-primary { display: flex; gap: 10px; }
.h3-spin {
  flex: 2;
  min-height: 56px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--h3-jade);
  border-color: var(--h3-brass);
}
.h3-spin.stop { background: #6e2a24; }
.h3-auto { flex: 1; min-height: 56px; font-size: 18px; letter-spacing: 1px; }
.h3-speed {
  display: flex;
  gap: 8px;
  border: 1px solid var(--h3-cell-line);
  border-radius: 8px;
  padding: 8px;
  margin: 0;
}
.h3-speed legend { font-size: 12px; letter-spacing: 2px; color: #b9c4d6; padding: 0 6px; }
.h3-speed-btn { flex: 1; }
.h3-speed-btn[aria-pressed="true"] { border-color: var(--h3-brass); color: #ffd97a; }
.h3-secondary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.h3-sound-state { margin: 0; font-size: 13px; color: #8d99ae; }

.h3-dialog {
  background: #101a2f;
  color: var(--h3-parchment);
  border: 3px solid var(--h3-brass);
  border-radius: 10px;
  max-width: 560px;
  width: calc(100vw - 40px);
}
.h3-dialog h2 { color: var(--h3-brass); margin-top: 0; }
.h3-dialog::backdrop { background: rgba(4, 8, 16, 0.8); }
.h3-menu-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.h3-dialog-meta { font-size: 13px; color: #b9c4d6; white-space: pre-wrap; }
.h3-info-body { font-size: 15px; max-height: 60dvh; overflow: auto; }
.h3-paytable { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.h3-paytable dt { color: var(--h3-brass); }
.h3-paytable dd { margin: 0; }

/* Desktop: board dominant, compact strip below. */
@media (min-width: 760px) and (min-height: 480px) {
  .h3-cell-short { font-size: 34px; }
  .h3-cell[data-kind="wild"] .h3-cell-short { font-size: 26px; }
  .h3-cell[data-kind="scatter"] .h3-cell-short { font-size: 20px; }
  .h3-panel {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    grid-template-areas:
      "meters primary"
      "status primary"
      "alert speed"
      "secondary secondary";
    align-items: center;
  }
  .h3-meters { grid-area: meters; }
  .h3-status { grid-area: status; }
  .h3-alert-row { grid-area: alert; }
  .h3-primary { grid-area: primary; }
  .h3-speed { grid-area: speed; }
  .h3-secondary { grid-area: secondary; }
  .h3-sound-state { grid-column: 1 / -1; }
}

/* Short landscape: slim header, dominant board, one narrow right rail. */
@media (max-height: 430px) and (orientation: landscape) {
  .h3-app { padding: 4px 8px 6px; gap: 4px; }
  .h3-title { font-size: 19px; }
  .h3-demo-note { display: none; }
  .h3-feature-banner { font-size: 12px; padding: 2px 8px; }
  .h3-stage { flex-direction: row; align-items: stretch; }
  .h3-board-wrap { flex: 1 1 auto; min-height: 0; min-width: 0; padding: 4px; }
  .h3-board { flex: 1 1 auto; min-height: 0; }
  .h3-cell-short { font-size: 17px; }
  .h3-cell-name, .h3-ph-caption { display: none; }
  .h3-lines-label { display: none; }
  .h3-panel {
    flex: 0 0 148px;
    max-width: 148px;
    padding: 6px;
    gap: 6px;
    overflow: auto;
  }
  .h3-meters { grid-template-columns: 1fr; gap: 2px; }
  .h3-meter-value { font-size: 16px; min-height: 22px; }
  .h3-bet-row { gap: 4px; }
  .h3-step { padding: 2px 10px; }
  .h3-primary { flex-direction: column; }
  .h3-spin, .h3-auto { min-height: 48px; font-size: 16px; }
  .h3-speed { flex-direction: column; padding: 4px; }
  .h3-secondary { grid-template-columns: 1fr 1fr; }
  .h3-secondary .h3-btn { min-height: 48px; padding: 4px 6px; font-size: 13px; }
  .h3-status { font-size: 13px; }
}

/* Constrained heights: reclaim chrome space so all 15 cells stay visible. */
@media (max-height: 740px) {
  .h3-demo-note { display: none; }
  .h3-app { gap: 6px; padding-top: 6px; }
  .h3-panel { gap: 6px; }
}

/* Narrow phones: compact title, single column, large targets. */
@media (max-width: 480px) {
  .h3-title { font-size: 23px; }
  .h3-cell-short { font-size: 21px; }
  .h3-meter-value { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
