:root {
  color-scheme: light;
  --app-scale: 1;
  --ink: #0b5b65;
  --deep: #123844;
  --papyrus: #fff2cf;
  --papyrus-dark: #efd48a;
  --gold: #e5aa20;
  --sun: #f4c94f;
  --red: #ca5d2e;
  --river: #0a8ea2;
  --river-deep: #087187;
  --white: #fffaf0;
  --shadow: 0 24px 60px rgba(22, 50, 54, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--deep);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 18% 10%, rgba(244, 201, 79, 0.35), transparent 28rem),
    linear-gradient(135deg, #f7e3a2 0%, #fcf5df 42%, #cfe9e9 100%);
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 4px solid #ffffff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--ink);
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
}

.workspace {
  width: min(calc(1180px * var(--app-scale)), 100%);
  height: calc(100vh - 16px);
  height: calc(100dvh - 16px);
  position: relative;
}

.board {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  position: relative;
  border: 3px solid rgba(11, 91, 101, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.86), rgba(255, 242, 207, 0.8) 58%, transparent 59%),
    repeating-linear-gradient(0deg, rgba(11, 91, 101, 0.06) 0 1px, transparent 1px 32px),
    var(--papyrus);
  box-shadow: var(--shadow);
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 82px;
  pointer-events: none;
}

.board::before {
  background:
    repeating-radial-gradient(ellipse at 12% 70%, transparent 0 17px, rgba(255, 250, 240, 0.85) 18px 20px, transparent 21px 34px),
    repeating-linear-gradient(104deg, transparent 0 38px, rgba(255, 250, 240, 0.42) 39px 42px, transparent 43px 76px),
    linear-gradient(180deg, var(--river), var(--river-deep));
  background-size:
    220px 110px,
    180px 82px,
    100% 100%;
  animation: nile-flow 8s linear infinite;
  clip-path: polygon(0 24%, 100% 0, 100% 100%, 0 100%);
}

.board::after {
  height: 34px;
  background:
    repeating-linear-gradient(112deg, transparent 0 24px, rgba(255, 250, 240, 0.8) 25px 28px, transparent 29px 52px);
  background-size: 180px 100%;
  animation: nile-sparkle 5s linear infinite;
  opacity: 0.72;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(9px * var(--app-scale)) clamp(12px, 2vw, 22px) 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.box-logo {
  width: clamp(56px, calc(5vw * var(--app-scale)), 86px);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.82);
}

.sfinks-wordmark {
  width: clamp(210px, calc(26vw * var(--app-scale)), 440px);
  max-height: clamp(48px, calc(8vw * var(--app-scale)), 92px);
  display: block;
  object-fit: contain;
}

.material-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.82);
  font-size: 0.95rem;
  font-weight: 1000;
  text-decoration: none;
  white-space: nowrap;
}

.material-link:hover {
  background: var(--white);
}

.gallery-open {
  font-family: inherit;
  cursor: pointer;
}

.gallery-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 8px;
  color: var(--deep);
  background: #fffaf0;
  box-shadow: 0 28px 80px rgba(10, 46, 50, 0.35);
  overflow: hidden;
}

.gallery-dialog::backdrop {
  background: rgba(7, 44, 49, 0.72);
  backdrop-filter: blur(3px);
}

.gallery-window {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(100vh - 38px);
  max-height: calc(100dvh - 38px);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(11, 91, 101, 0.2);
}

.gallery-header p {
  margin-bottom: 2px;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.gallery-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.gallery-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: #ffffff;
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.gallery-close:hover,
.gallery-close:focus-visible {
  color: #ffffff;
  background: var(--ink);
}

.gallery-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 18px;
  background: rgba(247, 190, 37, 0.16);
}

.gallery-tab {
  min-height: 42px;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 950;
  cursor: pointer;
}

.gallery-tab:hover,
.gallery-tab:focus-visible {
  background: #fff2bd;
}

.gallery-tab.active {
  color: #ffffff;
  background: var(--ink);
}

.gallery-panels {
  min-height: 0;
  padding: 0 18px 16px;
  overflow: auto;
}

.gallery-panel {
  width: 100%;
  margin: 0;
}

.gallery-panel[hidden] {
  display: none;
}

.gallery-image-frame {
  width: 100%;
  height: min(65vh, 650px);
  height: min(65dvh, 650px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(11, 91, 101, 0.22);
  background: #ffffff;
  overflow: hidden;
}

.gallery-image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.gallery-image-frame--filled {
  width: min(420px, 100%);
  margin-inline: auto;
}

.gallery-image-frame--filled img {
  object-fit: cover;
  object-position: right center;
}

.gallery-panel figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 9px;
  color: var(--deep);
  font-size: 0.82rem;
  font-weight: 850;
}

.gallery-panel figcaption a {
  color: var(--ink);
  font-weight: 950;
  text-underline-offset: 3px;
}

.info-button {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 3px 0 rgba(11, 91, 101, 0.2);
  font-family: Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  transition:
    color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.info-button:hover,
.info-button:focus-visible,
.info-button[aria-expanded="true"] {
  color: #ffffff;
  background: var(--ink);
  transform: translateY(-1px);
}

.heading-with-help,
.number-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.heading-with-help h2,
.number-heading p {
  margin-bottom: 0;
}

.help-dock {
  position: fixed;
  z-index: 100;
  width: min(280px, calc(100vw - 24px));
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  padding: 13px 34px 13px 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  color: var(--deep);
  background: rgba(255, 250, 240, 0.98);
  box-shadow: 0 18px 36px rgba(22, 50, 54, 0.24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.help-dock::before {
  content: "";
  position: absolute;
  top: 24px;
  width: 16px;
  height: 16px;
  border-left: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: var(--white);
}

.help-dock[data-side="right"]::before {
  left: -10px;
  transform: rotate(45deg);
}

.help-dock[data-side="left"]::before {
  right: -10px;
  transform: rotate(225deg);
}

.help-dock[data-side="top"]::before,
.help-dock[data-side="bottom"]::before {
  display: none;
}

.help-dock.is-active {
  animation: help-pop 220ms ease-out;
}

.workspace.has-help .help-dock {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.help-close {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.help-close:hover {
  color: #ffffff;
  background: var(--ink);
}

.help-dock__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--ink);
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 900;
}

.help-dock__eyebrow {
  margin-bottom: 5px;
  color: var(--red);
  font-size: 0.67rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.help-dock h2 {
  margin-bottom: 7px;
  color: var(--deep);
  font-size: 1rem;
  line-height: 1.1;
}

.help-dock p:last-child {
  margin-bottom: 0;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.3;
}

@keyframes help-pop {
  from {
    opacity: 0.55;
    transform: translateX(8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--deep);
  font-size: clamp(1.35rem, calc(3.2vw * var(--app-scale)), 3.2rem);
  line-height: 0.9;
}

h2 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1rem;
}

.swap-button {
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.82);
  font-size: 1.6rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.swap-button:hover {
  transform: translateY(-2px);
  background: var(--white);
}

.swap-control {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.game-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(calc(310px * var(--app-scale)), 1.25fr) minmax(calc(300px * var(--app-scale)), 0.75fr);
  gap: clamp(8px, calc(1.4vw * var(--app-scale)), 24px);
  align-items: start;
  min-height: 0;
  padding: 0 clamp(10px, 2vw, 22px) 54px;
}

.stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  padding: 4px 0 4px;
}

.winged-sun {
  width: min(calc(190px * var(--app-scale)), 30vw);
  height: calc(32px * var(--app-scale));
  margin: 0 auto;
  position: relative;
}

.winged-sun::before,
.winged-sun::after {
  content: "";
  position: absolute;
  top: 13px;
  width: 42%;
  height: 14px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.winged-sun::before {
  left: 0;
  transform: skewY(12deg);
}

.winged-sun::after {
  right: 0;
  transform: skewY(-12deg);
}

.winged-sun span {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--papyrus);
  transform: translateX(-50%);
}

.pyramid {
  position: absolute;
  left: 50%;
  top: calc(88px * var(--app-scale));
  bottom: auto;
  width: min(calc(350px * var(--app-scale)), 88%);
  height: min(calc(230px * var(--app-scale)), 29vh, 28vw);
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 43%),
    linear-gradient(145deg, #f8d758 0 48%, #e1a823 49% 100%);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  opacity: 0.92;
}

.pyramid-line,
.pyramid-mark {
  position: absolute;
  background: rgba(134, 95, 25, 0.24);
}

.line-a {
  left: 29%;
  top: 35%;
  width: 42%;
  height: 10px;
}

.line-b {
  left: 21%;
  top: 54%;
  width: 58%;
  height: 9px;
}

.line-c {
  left: 13%;
  top: 75%;
  width: 74%;
  height: 11px;
}

.mark-a {
  left: 48%;
  top: 26%;
  width: 12%;
  height: 38px;
}

.mark-b {
  left: 34%;
  top: 60%;
  width: 16%;
  height: 28px;
}

.mark-c {
  left: 58%;
  top: 68%;
  width: 13%;
  height: 44px;
}

.number-panel {
  z-index: 2;
  width: min(calc(280px * var(--app-scale)), 84%);
  margin: 0 auto 8px;
  padding: 8px;
  border: 3px solid var(--ink);
  background: rgba(255, 250, 240, 0.9);
  text-align: center;
}

.number-panel p {
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.number-panel output {
  display: block;
  min-height: 44px;
  color: #21313a;
  font-family: "Comic Sans MS", "Bradley Hand", cursive;
  font-size: clamp(2.55rem, calc(5.8vw * var(--app-scale)), 5.35rem);
  font-weight: 700;
  line-height: 1;
}

.dice-row {
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(6px, 1.3vw, 14px);
  width: min(calc(390px * var(--app-scale)), 100%);
  margin: 0 auto;
}

.die-card {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.die-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  font-size: 0.9rem;
}

.die {
  width: clamp(78px, calc(10vw * var(--app-scale)), calc(138px * var(--app-scale)));
  aspect-ratio: 1;
  border: 0;
  border-radius: 16px;
  color: #171717;
  background:
    radial-gradient(circle at 24% 22%, #ffffff 0 18%, transparent 19%),
    linear-gradient(145deg, #fffdf6 0%, #d4d1c9 100%);
  box-shadow:
    inset -14px -16px 28px rgba(50, 50, 50, 0.2),
    inset 10px 9px 18px rgba(255, 255, 255, 0.88),
    0 18px 26px rgba(22, 50, 54, 0.18);
  cursor: pointer;
}

.die span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: clamp(2.35rem, calc(5vw * var(--app-scale)), 4.8rem);
  font-weight: 1000;
  line-height: 1;
  transform: rotate(-8deg);
}

.die.nil span {
  color: var(--deep);
  font-size: clamp(1.8rem, 4.5vw, 2.9rem);
}

.side-panel {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 10px;
  align-content: start;
  padding-top: 4px;
}

.roll-panel,
.controls,
.results,
.rounds,
.method-panel {
  display: grid;
  gap: 7px;
}

.roll-panel {
  position: relative;
  z-index: 3;
  width: min(calc(430px * var(--app-scale)), 96%);
  grid-template-columns: 1.45fr 1fr;
  gap: 9px;
  margin: 14px auto 0;
}

.roll-help {
  position: absolute;
  top: -10px;
  right: -8px;
  z-index: 4;
}

.roll-button {
  position: relative;
  isolation: isolate;
  min-height: 58px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 3px solid #9c5d06;
  border-radius: 8px;
  color: #3b2200;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.9) 0 12%, transparent 13%),
    linear-gradient(115deg, transparent 0 34%, rgba(255, 255, 255, 0.6) 42%, transparent 50%),
    linear-gradient(180deg, #ffe271 0%, #f7ad20 47%, #d36e08 100%);
  box-shadow:
    inset 0 3px 2px rgba(255, 255, 255, 0.72),
    inset 0 -10px 18px rgba(113, 54, 0, 0.28),
    0 14px 24px rgba(143, 83, 7, 0.28);
  font-size: clamp(1.08rem, calc(2vw * var(--app-scale)), 1.7rem);
  font-weight: 1000;
  cursor: pointer;
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.roll-button::after {
  content: "";
  position: absolute;
  top: -45%;
  left: -30%;
  width: 42%;
  height: 190%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  transform: rotate(20deg);
  animation: shine 2.8s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

.undo-round-button {
  min-height: 58px;
  border: 3px solid #0b5b65;
  border-radius: 8px;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.8) 0 10%, transparent 11%),
    linear-gradient(180deg, #fafff8 0%, #cce7df 100%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.75),
    inset 0 -8px 14px rgba(11, 91, 101, 0.14),
    0 9px 16px rgba(22, 50, 54, 0.16);
  font-size: 1rem;
  font-weight: 1000;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.manual-round-button {
  grid-column: 1 / -1;
  min-height: 54px;
  border: 3px solid #1f6c2e;
  border-radius: 8px;
  color: #f7fff0;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.74) 0 10%, transparent 11%),
    linear-gradient(180deg, #69c84b 0%, #27913d 48%, #145f29 100%);
  box-shadow:
    inset 0 3px 2px rgba(255, 255, 255, 0.5),
    inset 0 -10px 18px rgba(5, 58, 20, 0.34),
    0 12px 22px rgba(23, 102, 46, 0.24);
  font-size: clamp(1.08rem, calc(1.7vw * var(--app-scale)), 1.45rem);
  font-weight: 1000;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
  animation: green-pulse 1.8s ease-in-out infinite;
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.manual-round-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.manual-round-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.62;
  transform: none;
  animation: none;
}

.manual-round-note {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.undo-round-button:hover {
  transform: translateY(-2px);
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.84) 0 10%, transparent 11%),
    linear-gradient(180deg, #ffffff 0%, #d9eee8 100%);
}

.undo-round-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.roll-button span {
  position: relative;
  z-index: 1;
}

.roll-button span:first-child {
  font-size: 1.55rem;
  line-height: 1;
}

.roll-button,
.undo-round-button {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.roll-button > * {
  position: relative;
  z-index: 1;
}

.roll-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.roll-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.68;
  transform: none;
}

@keyframes shine {
  0% {
    left: -42%;
  }

  48%,
  100% {
    left: 122%;
  }
}

@keyframes green-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 3px 2px rgba(255, 255, 255, 0.5),
      inset 0 -10px 18px rgba(5, 58, 20, 0.34),
      0 12px 22px rgba(23, 102, 46, 0.24);
  }

  50% {
    box-shadow:
      inset 0 3px 2px rgba(255, 255, 255, 0.7),
      inset 0 -10px 18px rgba(5, 58, 20, 0.2),
      0 0 0 5px rgba(105, 200, 75, 0.24),
      0 14px 28px rgba(23, 102, 46, 0.34);
  }
}

@keyframes nile-flow {
  0% {
    background-position:
      0 0,
      0 0,
      0 0;
  }

  100% {
    background-position:
      220px 0,
      -180px 0,
      0 0;
  }
}

@keyframes nile-sparkle {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 180px 0;
  }
}

.controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0;
}

.control-group {
  padding: 8px;
  border: 2px solid rgba(11, 91, 101, 0.25);
  background: rgba(255, 250, 240, 0.78);
}

.face-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.face-button,
.result-card {
  border: 2px solid var(--ink);
  color: var(--deep);
  background: var(--white);
  cursor: pointer;
}

.face-button {
  min-height: 30px;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 900;
}

.face-button.active,
.result-card.active {
  color: #fff;
  background: var(--ink);
}

.face-button.nil {
  font-size: 0.82rem;
}

.results {
  margin: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-card {
  min-height: 44px;
  border-radius: 6px;
  font-size: clamp(1.45rem, calc(3.4vw * var(--app-scale)), 2.7rem);
  font-weight: 1000;
}

.rounds {
  padding: 8px;
  border: 2px solid rgba(11, 91, 101, 0.25);
  background: rgba(255, 250, 240, 0.78);
}

.rounds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rounds-header h2 {
  margin-bottom: 0;
}

.reset-button {
  min-height: 28px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  background: var(--white);
  font-weight: 900;
  cursor: pointer;
}

.limit-field {
  display: grid;
  grid-template-columns: 1fr 82px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.limit-field input {
  width: 100%;
  min-height: 32px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  color: var(--deep);
  background: var(--white);
  font: inherit;
  font-size: 1rem;
  font-weight: 1000;
  text-align: center;
}

.round-count {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  color: var(--deep);
  font-size: 1.05rem;
  font-weight: 900;
}

.round-count strong {
  color: var(--ink);
  font-size: 1.85rem;
  line-height: 0.9;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width 180ms ease;
}

.rounds-note {
  margin: 0;
  color: var(--deep);
  font-size: 0.78rem;
  font-weight: 800;
}

.method-panel {
  padding: 8px;
  border: 2px solid rgba(11, 91, 101, 0.25);
  background: rgba(255, 250, 240, 0.78);
}

.method-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--deep);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.method-panel li + li {
  margin-top: 3px;
}

@media (min-width: 661px) and (max-height: 700px) {
  .topbar {
    padding-top: 4px;
  }

  .box-logo {
    width: 48px;
  }

  .sfinks-wordmark {
    max-height: 54px;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  .side-panel {
    gap: 6px;
  }

  .method-panel {
    gap: 3px;
    padding: 6px;
  }

  .method-panel h2 {
    margin-bottom: 3px;
  }

  .method-panel ul {
    font-size: 0.7rem;
    line-height: 1.15;
  }

  .method-panel li + li {
    margin-top: 1px;
  }

  .help-dock {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
    padding: 11px 10px;
  }

  .help-dock__mark {
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
  }

  .help-dock h2 {
    font-size: 0.87rem;
  }

  .help-dock p:last-child {
    font-size: 0.68rem;
    line-height: 1.2;
  }
}

@media (min-width: 661px) and (max-width: 900px) and (max-height: 700px) {
  .material-link {
    min-height: 34px;
    padding-inline: 10px;
    font-size: 0.8rem;
  }

  .control-group,
  .rounds {
    padding: 6px;
  }

  .control-group h2,
  .results h2 {
    margin-bottom: 4px;
  }

  .face-button {
    min-height: 27px;
    font-size: 0.88rem;
  }

  .rounds {
    gap: 4px;
  }

  .limit-field input {
    min-height: 28px;
  }

  .round-count strong {
    font-size: 1.55rem;
  }

  .method-panel {
    padding: 4px 6px;
  }

  .method-panel ul {
    padding-left: 14px;
    font-size: 0.62rem;
    line-height: 1.08;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 660px), (max-height: 560px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .workspace {
    width: 100%;
    height: auto;
  }

  .board {
    height: auto;
    min-height: calc(100vh - 16px);
    min-height: calc(100dvh - 16px);
    overflow: visible;
  }

  .game-layout {
    grid-template-columns: 1fr;
    padding: 0 clamp(18px, 4vw, 44px) 96px;
  }

  .stage {
    min-height: 348px;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-panel {
    padding-top: 0;
  }

  .dice-row {
    grid-template-columns: 1fr 48px 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions .material-link:not(.gallery-open),
  .topbar-actions .info-button {
    display: none;
  }

  .gallery-open {
    min-height: 36px;
    padding-inline: 10px;
    font-size: 0.78rem;
  }

  .gallery-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .gallery-window {
    max-height: calc(100dvh - 22px);
  }

  .gallery-header {
    padding: 11px 12px 9px;
  }

  .gallery-header h2 {
    font-size: 1.15rem;
  }

  .gallery-tabs {
    padding: 8px 12px;
  }

  .gallery-tab {
    min-height: 38px;
    font-size: 0.72rem;
  }

  .gallery-panels {
    padding: 0 12px 12px;
  }

  .gallery-image-frame {
    height: min(62dvh, 560px);
  }

}

@media (max-width: 440px) {
  .app-shell {
    padding: 0;
  }

  .board {
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .game-layout {
    padding-inline: 18px;
  }

  .topbar {
    padding-top: 12px;
  }

  .topbar-actions {
    padding-top: 2px;
  }

  .box-logo {
    width: 54px;
  }

  .sfinks-wordmark {
    width: min(250px, 68vw);
  }

  .dice-row {
    gap: 6px;
  }

  .roll-panel {
    grid-template-columns: 1fr;
  }

  .swap-button {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .gallery-tabs {
    grid-template-columns: 1fr;
  }

  .gallery-image-frame {
    height: min(56dvh, 460px);
  }

  .gallery-panel figcaption {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}
