:root {
  color-scheme: light;
  --ink: #173432;
  --ink-soft: #49645f;
  --paper: #f6efd9;
  --paper-deep: #e7d9b5;
  --sand: #d8943b;
  --sand-light: #f2c46d;
  --plus: #247f72;
  --minus: #b8544f;
  --stop: #766f63;
  --line: rgba(23, 52, 50, 0.22);
  --shadow: rgba(40, 34, 23, 0.18);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  background: #173432;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #173432;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(241, 196, 109, 0.16), transparent 28rem),
    radial-gradient(circle at 84% 30%, rgba(103, 179, 160, 0.15), transparent 30rem),
    linear-gradient(150deg, #102c2b 0%, #1b3d39 54%, #112927 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.85) 0 0.6px, transparent 0.8px),
    radial-gradient(circle, rgba(13, 35, 32, 0.9) 0 0.6px, transparent 0.8px);
  background-position: 0 0, 7px 9px;
  background-size: 13px 13px, 17px 17px;
  content: "";
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #ffd57a;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding-bottom: 38px;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(246, 239, 217, 0.24);
  color: var(--paper);
}

.back-link {
  color: inherit;
  text-decoration: none;
  font: 750 0.68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.back-link span {
  display: inline-block;
  margin-right: 8px;
  transition: transform 160ms ease;
}

.back-link:hover span {
  transform: translateX(-4px);
}

.run-stats {
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(246, 239, 217, 0.2);
}

.run-stats > span {
  min-width: 72px;
  padding: 9px 12px;
  display: grid;
  gap: 4px;
  text-align: right;
}

.run-stats > span + span {
  border-left: 1px solid rgba(246, 239, 217, 0.2);
}

.run-stats small {
  color: rgba(246, 239, 217, 0.62);
  font: 700 0.55rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.run-stats strong {
  font: 800 1rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.title-block {
  padding: clamp(54px, 8vw, 92px) 0 clamp(34px, 5vw, 58px);
  color: var(--paper);
}

.eyebrow,
.section-label {
  margin: 0;
  font: 800 0.64rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.16em;
}

.eyebrow {
  color: var(--sand-light);
}

.title-block h1 {
  margin: 18px 0 20px;
  font-size: clamp(3.3rem, 10vw, 7.5rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.title-block h1 span {
  display: block;
  margin-bottom: 0.16em;
  color: var(--sand-light);
  font-size: 0.42em;
  letter-spacing: 0.08em;
}

.lead {
  max-width: 640px;
  margin: 0;
  color: rgba(246, 239, 217, 0.76);
  font-weight: 600;
  line-height: 1.9;
}

.play-panel {
  padding: clamp(18px, 4vw, 42px);
  border: 1px solid rgba(246, 239, 217, 0.48);
  background:
    linear-gradient(rgba(246, 239, 217, 0.92), rgba(246, 239, 217, 0.96)),
    repeating-linear-gradient(4deg, transparent 0 7px, rgba(111, 89, 54, 0.08) 8px 9px);
  box-shadow: 18px 18px 0 rgba(4, 20, 18, 0.24);
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-label {
  color: var(--ink-soft);
}

.panel-heading h2 {
  margin: 8px 0 0;
  font-size: clamp(1.25rem, 4vw, 2rem);
  letter-spacing: -0.04em;
}

.panel-heading h2 strong {
  display: inline-grid;
  width: 1.35em;
  height: 1.35em;
  margin-left: 0.12em;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.text-button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.text-button:hover {
  background: rgba(23, 52, 50, 0.08);
}

.puzzle-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(88px, 0.78fr) repeat(3, minmax(100px, 1fr));
  grid-template-rows: 184px repeat(3, minmax(126px, 1fr));
  gap: 10px;
}

.grid-corner {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  text-align: center;
}

.grid-corner span {
  font: 800 0.56rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.grid-corner strong {
  font: 900 2.2rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hourglass-control {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
}

.hourglass-button {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 253, 245, 0.66);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.column-control .hourglass-button {
  flex-direction: column;
}

.hourglass-button:not(:disabled):hover {
  border-color: rgba(23, 52, 50, 0.5);
  background: #fffdf5;
  transform: translateY(-2px);
}

.hourglass-button:not(:disabled):active {
  transform: translateY(1px) scale(0.98);
}

.hourglass-button:disabled {
  cursor: default;
}

.hourglass-control.is-preview .hourglass-button {
  z-index: 2;
  border-color: var(--sand);
  background: #fffaf0;
  box-shadow: 0 0 0 3px rgba(216, 148, 59, 0.25), inset 0 0 0 1px rgba(216, 148, 59, 0.3);
}

.hourglass-control.is-stopped:not(.is-preview) .hourglass-button {
  background: rgba(214, 207, 189, 0.48);
}

.hourglass-control.is-refill-target:not(.is-full) .hourglass-button {
  border-color: var(--sand);
  background: #fff7df;
  box-shadow: inset 0 0 0 2px rgba(216, 148, 59, 0.28);
  animation: refill-target-pulse 700ms ease-in-out infinite alternate;
}

.hourglass-control.is-refill-target.is-full {
  opacity: 0.42;
}

.flip-button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(23, 52, 50, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.flip-button:not(:disabled):hover {
  background: var(--ink);
  color: var(--paper);
}

.flip-button:not(:disabled):active {
  transform: scale(0.97);
}

.flip-button:disabled,
.hourglass-button:disabled {
  cursor: default;
}

.glass-vessel {
  --top-fill: 100%;
  --bottom-fill: 0%;
  position: relative;
  flex: 0 0 auto;
  display: block;
  width: 46px;
  height: 76px;
  transform-origin: center;
}

.just-flipped .glass-vessel {
  animation: vessel-flip 420ms cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-cap {
  position: absolute;
  left: 2px;
  width: 42px;
  height: 6px;
  border: 1px solid rgba(23, 52, 50, 0.46);
  background: var(--ink);
}

.glass-cap-top {
  top: 1px;
}

.glass-cap-bottom {
  bottom: 1px;
}

.glass-bulb {
  position: absolute;
  left: 7px;
  width: 32px;
  height: 31px;
  overflow: hidden;
  border: 1.5px solid rgba(23, 52, 50, 0.48);
  background: rgba(255, 255, 255, 0.54);
}

.glass-bulb-top {
  top: 7px;
  clip-path: polygon(0 0, 100% 0, 58% 100%, 42% 100%);
}

.glass-bulb-bottom {
  bottom: 7px;
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
}

.sand {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 2px 2px, rgba(255, 238, 180, 0.75) 0 1px, transparent 1.3px) 0 0 / 6px 6px,
    linear-gradient(180deg, var(--sand-light), var(--sand));
  transition: height 260ms ease;
}

.sand-top {
  height: var(--top-fill);
}

.sand-bottom {
  height: var(--bottom-fill);
}

.sand-stream {
  position: absolute;
  z-index: 3;
  left: 22px;
  top: 34px;
  width: 2px;
  height: 10px;
  background: var(--sand);
  box-shadow: 0 0 4px rgba(216, 148, 59, 0.55);
  opacity: 0;
  animation: none;
}

.just-poured:not(.is-stopped) .sand-stream {
  opacity: 1;
  animation: sand-stream 260ms linear 2;
}

.glass-copy {
  min-width: 42px;
  display: grid;
  justify-items: center;
  gap: 3px;
}

.glass-copy strong {
  font-size: 0.74rem;
}

.glass-state {
  min-width: 38px;
  padding: 4px 5px;
  background: var(--plus);
  color: white;
  font: 900 0.78rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.glass-vessel.is-reversed + .glass-copy .glass-state,
.hourglass-button:has(.glass-vessel.is-reversed):not(.is-stopped) .glass-state {
  background: var(--minus);
}

.is-stopped .glass-state {
  background: var(--stop) !important;
}

.glass-remaining {
  color: var(--ink-soft);
  font: 700 0.56rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.just-refilled .hourglass-button {
  animation: glass-refilled 680ms ease;
}

.number-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.84);
  display: grid;
  place-items: center;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.number-cell::before {
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(23, 52, 50, 0.12);
  content: "";
}

.number-cell::after {
  position: absolute;
  right: 7px;
  top: 6px;
  color: var(--sand);
  content: attr(data-change);
  font: 900 0.8rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  opacity: 0;
  transform: translateY(7px);
}

.cell-value {
  position: relative;
  z-index: 1;
  font: 900 clamp(2.2rem, 6vw, 4.5rem)/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: -0.08em;
}

.number-cell small {
  position: absolute;
  left: 9px;
  bottom: 8px;
  color: var(--ink-soft);
  font: 800 0.56rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.number-cell.is-target {
  border-color: rgba(36, 127, 114, 0.52);
  background: rgba(196, 228, 207, 0.62);
}

.number-cell.is-target .cell-value {
  color: var(--plus);
}

.number-cell.is-upcoming {
  border-color: var(--sand);
  box-shadow: inset 0 0 0 3px rgba(216, 148, 59, 0.14);
}

.number-cell.changed-plus,
.number-cell.changed-minus,
.number-cell.changed-stop {
  animation: cell-step 540ms ease;
}

.number-cell.changed-plus::after,
.number-cell.changed-minus::after,
.number-cell.changed-stop::after {
  opacity: 1;
  animation: delta-rise 560ms ease forwards;
}

.number-cell.changed-plus::after {
  color: var(--plus);
}

.number-cell.changed-minus::after {
  color: var(--minus);
}

.number-cell.changed-stop::after {
  color: var(--stop);
}

.refill-panel {
  margin-top: 22px;
  padding: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.42);
}

.refill-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.refill-heading h3 {
  margin: 5px 0 0;
  font-size: 1.05rem;
}

.token-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-display strong {
  color: var(--ink-soft);
  font: 850 0.72rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.token-dots {
  display: flex;
  gap: 5px;
}

.token-dots span {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(111, 89, 54, 0.48);
  border-radius: 50%;
  background: rgba(216, 148, 59, 0.08);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.token-dots span.is-filled {
  background: var(--sand);
  box-shadow: inset 0 0 0 4px var(--sand-light);
  transform: scale(1.08);
}

.refill-progress {
  height: 5px;
  margin-top: 14px;
  overflow: hidden;
  background: rgba(23, 52, 50, 0.13);
}

.refill-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--sand), var(--sand-light));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms ease;
}

.refill-panel > p {
  margin: 8px 0 14px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.refill-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.refill-actions button {
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-content: center;
  gap: 5px;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.refill-actions button:not(:disabled):hover {
  border-color: var(--sand);
  background: #fff7df;
  transform: translateY(-2px);
}

.refill-actions button.is-selecting {
  border-color: var(--sand);
  background: var(--sand-light);
}

.refill-actions button:disabled {
  cursor: default;
  opacity: 0.42;
}

.refill-actions strong {
  font-size: 0.72rem;
}

.refill-actions small {
  color: var(--ink-soft);
  font: 750 0.55rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.refill-panel.just-earned {
  animation: token-earned 680ms ease;
}

.status {
  min-height: 3.6em;
  margin: 18px 0 0;
  padding-left: 16px;
  border-left: 4px solid var(--sand);
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.8;
}

.rule-cards {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid rgba(246, 239, 217, 0.28);
  color: var(--paper);
}

.rule-cards article {
  min-height: 210px;
  padding: 26px;
}

.rule-cards article + article {
  border-left: 1px solid rgba(246, 239, 217, 0.28);
}

.rule-cards article > span {
  color: var(--sand-light);
  font: 800 0.62rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.rule-cards h2 {
  margin: 44px 0 12px;
  font-size: 1.15rem;
}

.rule-cards p {
  margin: 0;
  color: rgba(246, 239, 217, 0.67);
  font-size: 0.78rem;
  line-height: 1.85;
}

footer {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: rgba(246, 239, 217, 0.56);
  font: 700 0.58rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 20px;
  overflow-y: auto;
  background: rgba(9, 29, 27, 0.84);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
}

.modal-card {
  width: min(570px, 100%);
  padding: clamp(28px, 6vw, 58px);
  border: 1px solid rgba(246, 239, 217, 0.58);
  background:
    linear-gradient(rgba(246, 239, 217, 0.96), rgba(246, 239, 217, 0.98)),
    repeating-linear-gradient(7deg, transparent 0 9px, rgba(111, 89, 54, 0.08) 10px 11px);
  color: var(--ink);
  box-shadow: 20px 20px 0 rgba(0, 0, 0, 0.2);
}

.intro-card {
  width: min(650px, 100%);
}

.intro-card h2 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.modal-card .eyebrow {
  color: var(--sand);
}

.modal-card h2 {
  margin: 18px 0;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.06em;
}

.modal-card > p:not(.eyebrow) {
  color: var(--ink-soft);
  line-height: 1.9;
}

.intro-example {
  margin: 26px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.example-chip {
  min-width: 62px;
  padding: 11px 9px;
  color: white;
  text-align: center;
  font: 900 0.8rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.example-chip.plus {
  background: var(--plus);
}

.example-chip.minus {
  background: var(--minus);
}

.example-chip.stop {
  background: var(--stop);
}

.example-arrow {
  color: var(--ink-soft);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  margin-top: 18px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 0.08em;
  box-shadow: 7px 7px 0 var(--sand);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button:hover {
  transform: translate(3px, 3px);
  box-shadow: 4px 4px 0 var(--sand);
}

.result-card {
  text-align: center;
}

.result-five {
  width: 110px;
  height: 110px;
  margin: 22px auto 10px;
  border: 2px solid var(--plus);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(196, 228, 207, 0.64);
  color: var(--plus);
  font: 900 4.5rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  animation: result-arrive 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.result-stats {
  margin: 28px 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
}

.result-stats div {
  padding: 14px 8px;
}

.result-stats div + div {
  border-left: 1px solid var(--line);
}

.result-stats dt {
  color: var(--ink-soft);
  font: 800 0.57rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.1em;
}

.result-stats dd {
  margin: 7px 0 0;
  font: 900 0.94rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes sand-stream {
  0% { transform: translateY(-2px); opacity: 0.45; }
  50% { opacity: 1; }
  100% { transform: translateY(3px); opacity: 0.45; }
}

@keyframes vessel-flip {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(0.92); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes refill-target-pulse {
  from { box-shadow: inset 0 0 0 2px rgba(216, 148, 59, 0.18); }
  to { box-shadow: inset 0 0 0 4px rgba(216, 148, 59, 0.38); }
}

@keyframes glass-refilled {
  0% { box-shadow: inset 0 0 0 0 rgba(216, 148, 59, 0); }
  45% { box-shadow: inset 0 0 0 6px rgba(216, 148, 59, 0.48); }
  100% { box-shadow: inset 0 0 0 0 rgba(216, 148, 59, 0); }
}

@keyframes token-earned {
  0% { background: rgba(255, 253, 245, 0.42); }
  45% { background: rgba(242, 196, 109, 0.48); }
  100% { background: rgba(255, 253, 245, 0.42); }
}

@keyframes cell-step {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes delta-rise {
  from { opacity: 0; transform: translateY(8px); }
  25% { opacity: 1; }
  to { opacity: 0; transform: translateY(-12px); }
}

@keyframes result-arrive {
  from { transform: scale(0.7) rotate(-9deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100% - 20px, 680px);
  }

  .topbar {
    min-height: 68px;
  }

  .back-link {
    font-size: 0.57rem;
  }

  .run-stats > span {
    min-width: 53px;
    padding: 8px;
  }

  .run-stats small {
    font-size: 0.47rem;
  }

  .run-stats strong {
    font-size: 0.82rem;
  }

  .title-block {
    padding-top: 48px;
  }

  .play-panel {
    padding: 14px;
    box-shadow: 8px 9px 0 rgba(4, 20, 18, 0.24);
  }

  .panel-heading {
    align-items: center;
  }

  .panel-heading h2 {
    font-size: 1.05rem;
  }

  .text-button {
    padding: 0 10px;
    font-size: 0.66rem;
  }

  .puzzle-grid {
    grid-template-columns: 70px repeat(3, minmax(0, 1fr));
    grid-template-rows: 154px repeat(3, 112px);
    gap: 6px;
  }

  .grid-corner strong {
    font-size: 1.75rem;
  }

  .hourglass-button {
    min-height: 0;
    padding: 5px 3px;
    gap: 3px;
  }

  .hourglass-control {
    gap: 4px;
  }

  .column-control .hourglass-button {
    gap: 1px;
  }

  .row-control .hourglass-button {
    flex-direction: column;
  }

  .flip-button {
    min-height: 44px;
    padding: 2px;
    font-size: 0.56rem;
  }

  .glass-vessel {
    width: 36px;
    height: 62px;
    transform: scale(0.86);
  }

  .just-flipped .glass-vessel {
    animation-name: vessel-flip-mobile;
  }

  .glass-cap {
    left: 1px;
    width: 34px;
    height: 5px;
  }

  .glass-bulb {
    left: 6px;
    width: 24px;
    height: 25px;
  }

  .glass-bulb-top {
    top: 6px;
  }

  .glass-bulb-bottom {
    bottom: 6px;
  }

  .sand-stream {
    left: 17px;
    top: 28px;
    height: 7px;
  }

  .glass-copy {
    min-width: 0;
    gap: 2px;
  }

  .glass-copy strong {
    font-size: 0.62rem;
  }

  .glass-state {
    min-width: 32px;
    padding: 3px;
    font-size: 0.65rem;
  }

  .glass-remaining {
    font-size: 0.45rem;
  }

  .cell-value {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .number-cell small {
    left: 6px;
    bottom: 5px;
    font-size: 0.47rem;
  }

  .refill-panel {
    padding: 14px;
  }

  .refill-heading {
    align-items: flex-end;
  }

  .token-display {
    gap: 7px;
  }

  .token-dots span {
    width: 15px;
    height: 15px;
  }

  .refill-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .refill-actions button {
    min-height: 50px;
  }

  .status {
    font-size: 0.75rem;
  }

  .result-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-stats div:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .result-stats div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .rule-cards {
    grid-template-columns: 1fr;
  }

  .rule-cards article {
    min-height: 0;
    padding: 22px;
  }

  .rule-cards article + article {
    border-top: 1px solid rgba(246, 239, 217, 0.28);
    border-left: 0;
  }

  .rule-cards h2 {
    margin-top: 22px;
  }

  footer {
    padding: 22px 0;
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 410px) {
  .game-shell {
    width: calc(100% - 12px);
  }

  .back-link {
    max-width: 116px;
  }

  .run-stats > span {
    min-width: 48px;
    padding: 7px 6px;
  }

  .title-block h1 {
    font-size: 3.05rem;
  }

  .puzzle-grid {
    grid-template-columns: 62px repeat(3, minmax(0, 1fr));
    grid-template-rows: 146px repeat(3, 106px);
  }

  .glass-vessel {
    transform: scale(0.78);
    margin: -4px 0;
  }

  .cell-value {
    font-size: 2rem;
  }

  .flip-button {
    font-size: 0.5rem;
  }

  .refill-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .modal-card {
    padding: 26px 20px;
  }
}

@keyframes vessel-flip-mobile {
  0% { transform: rotate(0deg) scale(0.86); }
  50% { transform: rotate(180deg) scale(0.78); }
  100% { transform: rotate(360deg) scale(0.86); }
}

@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;
  }
}
