:root {
  --bg: #071318;
  --panel: #10262d;
  --panel-2: #0b1b21;
  --cream: #f3e3b7;
  --gold: #cda253;
  --teal: #4f8d8b;
  --teal-2: #78aaa5;
  --red: #b74736;
  --red-dark: #6f241d;
  --green: #67b193;
  --amber: #c99b46;
  --shadow: rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--cream);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 50% 12%, rgba(82, 145, 142, 0.18), transparent 30%),
    linear-gradient(180deg, #050d11 0%, #0c1a20 55%, #1d211f 100%);
}

button,
select {
  font: inherit;
}

.app {
  width: min(100vw, 520px);
  height: min(100vh, 940px);
  padding: 10px;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 2px solid var(--gold);
  border-radius: 30px;
  background: linear-gradient(180deg, #122b32, #07171d);
  box-shadow:
    0 0 0 7px #111a1d,
    0 0 0 9px #71542d,
    0 28px 90px rgba(0, 0, 0, 0.65),
    inset 0 0 45px rgba(91, 147, 143, 0.08);
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  height: 106px;
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(205, 162, 83, 0.38);
  background: linear-gradient(180deg, rgba(6, 18, 23, 0.98), rgba(10, 28, 34, 0.9), transparent);
  text-shadow: 0 2px 8px #000;
}

.brand small {
  display: block;
  color: #7fa9a5;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.brand h1 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 6vw, 35px);
  letter-spacing: 0.06em;
  line-height: 1;
}

.brand h1 span {
  color: #d35a43;
}

.top-stat {
  min-width: 0;
  text-align: center;
}

.top-stat.right {
  text-align: right;
}

.top-stat span {
  display: block;
  color: #82a09d;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.top-stat strong {
  display: block;
  margin-top: 3px;
  color: #f4dda0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 6vw, 34px);
}

.stage {
  position: absolute;
  inset: 92px 12px 215px;
  overflow: hidden;
  border: 2px solid rgba(213, 175, 98, 0.62);
  border-radius: 27px;
  background: #15323c;
  box-shadow:
    inset 0 0 0 4px rgba(5, 14, 18, 0.67),
    inset 0 0 45px rgba(0, 0, 0, 0.42),
    0 9px 28px rgba(0, 0, 0, 0.35);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.altimeter,
.risk-panel {
  position: absolute;
  z-index: 4;
  border: 1px solid rgba(205, 162, 83, 0.6);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(18, 42, 48, 0.9), rgba(7, 20, 24, 0.94));
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

.altimeter {
  top: 86px;
  left: 10px;
  width: 58px;
  display: grid;
  gap: 13px;
  padding: 12px 7px 12px 20px;
  color: #829693;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.altimeter::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 9px;
  width: 2px;
  border-radius: 6px;
  background: linear-gradient(180deg, #e0bf6c, #8c6030);
}

.altimeter i {
  position: absolute;
  left: 4px;
  bottom: 9px;
  width: 11px;
  height: 11px;
  border: 2px solid #f0d789;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px rgba(215, 88, 67, 0.8);
  transition: bottom 0.35s ease;
}








.risk-panel {
  left: 50%;
  bottom: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  transform: translateX(-50%);
}

.risk-panel span {
  color: #93aaa6;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.risk-panel select {
  border: 1px solid rgba(218, 181, 105, 0.55);
  border-radius: 7px;
  outline: none;
  padding: 5px 8px;
  color: #f1d997;
  background: #0b1d22;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.result-banner {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 22%;
  min-width: 190px;
  padding: 11px 18px 9px;
  border: 1px solid rgba(240, 210, 132, 0.75);
  border-radius: 999px;
  color: #f3dc9c;
  background: linear-gradient(180deg, rgba(25, 58, 61, 0.96), rgba(7, 21, 25, 0.96));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.96);
  transition: 0.18s ease;
}

.result-banner.show {
  opacity: 1;
  transform: translate(-50%, -18px) scale(1);
}

.result-banner.danger {
  border-color: rgba(234, 102, 79, 0.8);
  color: #ffc1b0;
  background: linear-gradient(180deg, rgba(104, 37, 30, 0.97), rgba(43, 13, 12, 0.97));
}

.control-deck {
  position: absolute;
  z-index: 10;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 190px;
  display: grid;
  grid-template-columns: 1fr 1fr 42px 42px;
  grid-template-rows: 62px 60px 42px;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(205, 162, 83, 0.68);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(37, 62, 66, 0.97), rgba(8, 23, 28, 0.99));
  box-shadow:
    inset 0 0 0 4px rgba(4, 15, 18, 0.55),
    0 11px 34px rgba(0, 0, 0, 0.45);
}

.readout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(218, 181, 105, 0.42);
  border-radius: 12px;
  background: linear-gradient(180deg, #102a31, #07191e);
}

.readout span {
  color: #7f9d99;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.readout strong {
  margin-top: 4px;
  overflow: hidden;
  color: #f0d58f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  text-overflow: ellipsis;
}

.small-button {
  border: 1px solid rgba(218, 181, 105, 0.55);
  border-radius: 12px;
  color: #f1d38e;
  background: linear-gradient(180deg, #35595c, #142b30);
  box-shadow: inset 0 0 0 3px rgba(4, 16, 19, 0.45);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  cursor: pointer;
}

.main-button,
.collect-button {
  border-radius: 13px;
  color: #fff0be;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 4px rgba(51, 19, 15, 0.28),
    0 7px 18px rgba(0, 0, 0, 0.35);
}

.main-button {
  grid-column: 1 / 3;
  border: 2px solid #e0bb66;
  background: radial-gradient(circle at 50% 30%, #dc694e, #aa3e31 58%, #68231c);
  font-size: 19px;
}

.collect-button {
  grid-column: 3 / 5;
  border: 2px solid #91c3b4;
  background: linear-gradient(180deg, #4f9486, #27645e);
  font-size: 15px;
}

.collect-button small {
  display: block;
  margin-top: 3px;
  color: #fff0ba;
  font-size: 12px;
}

button:disabled,
select:disabled {
  cursor: default;
  filter: grayscale(0.75) brightness(0.68);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

.history {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(218, 181, 105, 0.35);
  border-radius: 11px;
  background: rgba(5, 18, 22, 0.74);
}

.history > span {
  color: #789490;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#historyList {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 1px 4px;
  color: #e1c98a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(218, 181, 105, 0.38) transparent;
}

#historyList::-webkit-scrollbar {
  height: 4px;
}

#historyList::-webkit-scrollbar-track {
  background: transparent;
}

#historyList::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(218, 181, 105, 0.38);
}

.history-empty {
  color: #6f8986;
}

.history-chip {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 4px 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 7px rgba(0, 0, 0, 0.24);
}

.history-chip.success {
  color: #baf6d2;
  border-color: rgba(80, 216, 143, 0.62);
  background:
    linear-gradient(180deg, rgba(37, 124, 82, 0.76), rgba(13, 62, 44, 0.88));
  text-shadow: 0 0 7px rgba(91, 243, 157, 0.36);
}

.history-chip.fail {
  color: #ffd0c8;
  border-color: rgba(239, 91, 67, 0.7);
  background:
    linear-gradient(180deg, rgba(151, 54, 43, 0.8), rgba(73, 24, 21, 0.92));
  text-shadow: 0 0 7px rgba(255, 103, 79, 0.4);
}

.history-chip.max-win {
  color: #fff1b8;
  border-color: rgba(237, 202, 102, 0.82);
  background:
    linear-gradient(180deg, rgba(40, 134, 87, 0.9), rgba(17, 70, 49, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 225, 132, 0.2),
    0 0 10px rgba(222, 188, 87, 0.24);
}

.scanlines,
.grain {
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
}

.scanlines {
  opacity: 0.07;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.2) 0 1px, transparent 1px 4px);
}

.grain {
  opacity: 0.045;
  background-image:
    radial-gradient(circle at 20% 30%, white 0 0.7px, transparent 0.9px),
    radial-gradient(circle at 70% 65%, white 0 0.5px, transparent 0.8px);
  background-size: 6px 6px, 8px 8px;
  animation: grain 0.2s steps(2) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(1%, 1%); }
  100% { transform: translate(0, 0); }
}

@media (max-height: 780px) {
  .topbar {
    height: 92px;
  }

  .stage {
    inset: 80px 10px 198px;
  }

  .control-deck {
    height: 178px;
    grid-template-rows: 56px 56px 40px;
  }
}





.sound-button {
  position: absolute;
  z-index: 18;
  top: 112px;
  right: 22px;
  min-width: 126px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(218, 181, 105, 0.72);
  border-radius: 999px;
  color: #f1d793;
  background: linear-gradient(180deg, rgba(45, 78, 81, 0.98), rgba(12, 31, 36, 0.98));
  box-shadow:
    inset 0 0 0 3px rgba(4, 16, 19, 0.45),
    0 6px 18px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  user-select: none;
}

.sound-button:hover {
  filter: brightness(1.08);
}

.sound-button:active {
  transform: translateY(1px);
}

.sound-icon {
  font-size: 17px;
  line-height: 1;
}

.sound-text {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.sound-button.muted {
  color: #a7aaa1;
  border-color: rgba(163, 165, 157, 0.5);
  background: linear-gradient(180deg, rgba(48, 57, 58, 0.96), rgba(20, 28, 30, 0.98));
  filter: grayscale(0.65) brightness(0.82);
}

.info-button {
  position: absolute;
  z-index: 18;
  top: 112px;
  left: 50%;
  min-width: 96px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(120, 190, 184, 0.7);
  border-radius: 999px;
  color: #bce3dc;
  background: linear-gradient(180deg, rgba(32, 82, 83, 0.98), rgba(9, 34, 39, 0.98));
  box-shadow:
    inset 0 0 0 3px rgba(4, 16, 19, 0.45),
    0 6px 18px rgba(0, 0, 0, 0.34);
  transform: translateX(-50%);
  cursor: pointer;
  user-select: none;
}

.info-button:hover {
  filter: brightness(1.1);
}

.info-button:active:not(:disabled) {
  transform: translateX(-50%) translateY(1px);
}

.info-button-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(224, 194, 120, 0.72);
  border-radius: 50%;
  color: #f2d690;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.info-button-text {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.info-button:focus-visible,
.info-modal-close:focus-visible {
  outline: 3px solid #81d6cb;
  outline-offset: 3px;
}

@media (max-height: 780px) {
  .sound-button,
  .info-button {
    top: 96px;
  }
}

@media (max-width: 420px) {
  .sound-button {
    right: 16px;
    min-width: 42px;
    width: 42px;
    padding: 0;
  }

  .sound-text {
    display: none;
  }

  .info-button {
    min-width: 62px;
    width: 62px;
    padding: 0 8px;
  }

  .info-button-icon {
    width: 16px;
    height: 16px;
    font-size: 11px;
  }

  .info-button-text {
    font-size: 8px;
  }
}


.max-win-panel {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 57px;
  min-width: 96px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(205, 162, 83, 0.46);
  border-radius: 999px;
  color: #8fa6a2;
  background: rgba(7, 20, 24, 0.82);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.24);
  transform: translateX(-50%);
  pointer-events: none;
}

.max-win-panel span {
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.max-win-panel strong {
  color: #f0d789;
  font-size: 10px;
  letter-spacing: 0.04em;
}


/* ================================================================
   v0.5 — single-mode controls and modern-vintage betting console
   ================================================================ */

.stage {
  inset: 92px 12px 238px;
}

.control-deck {
  height: 214px;
  grid-template-columns: 0.88fr 1.42fr;
  grid-template-rows: 82px 62px 42px;
  gap: 8px;
  padding: 10px;
  border-color: rgba(222, 183, 101, 0.76);
  background:
    linear-gradient(110deg, rgba(205, 162, 83, 0.07), transparent 28%),
    linear-gradient(180deg, rgba(39, 65, 68, 0.99), rgba(7, 21, 25, 0.99));
}

.balance-readout {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  justify-content: center;
  border-radius: 15px;
  background:
    linear-gradient(145deg, rgba(239, 215, 157, 0.08), transparent 45%),
    linear-gradient(180deg, #18353b, #091c21);
  box-shadow:
    inset 0 0 0 3px rgba(4, 15, 18, 0.42),
    inset 0 -12px 25px rgba(0, 0, 0, 0.18);
}

.balance-readout strong {
  font-size: 23px;
}

.balance-readout small {
  display: block;
  margin-top: 2px;
  color: #637f7c;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.bet-console {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 0.92fr;
  grid-template-rows: 20px 1fr;
  gap: 6px 8px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid rgba(218, 181, 105, 0.52);
  border-radius: 15px;
  background:
    linear-gradient(145deg, rgba(239, 215, 157, 0.08), transparent 42%),
    linear-gradient(180deg, #163239, #081b20);
  box-shadow:
    inset 0 0 0 3px rgba(4, 15, 18, 0.42),
    inset 0 -12px 25px rgba(0, 0, 0, 0.18);
}

.bet-console-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bet-console-head span {
  color: #d8b66c;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bet-console-head small {
  color: #718b88;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.quick-bets {
  display: grid;
  grid-template-columns: repeat(4, minmax(25px, 1fr));
  gap: 4px;
}

.quick-bet {
  border: 1px solid rgba(220, 183, 104, 0.58);
  color: #ecd28e;
  background:
    linear-gradient(180deg, rgba(74, 111, 111, 0.92), rgba(20, 47, 51, 0.98));
  box-shadow:
    inset 0 0 0 2px rgba(4, 15, 18, 0.36),
    0 3px 8px rgba(0, 0, 0, 0.22);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.quick-bet {
  min-width: 0;
  border-radius: 8px;
}

.quick-bet.active {
  color: #fff0bc;
  border-color: #e4bd6c;
  background:
    linear-gradient(180deg, #bf654b, #803226);
  box-shadow:
    inset 0 0 0 2px rgba(70, 20, 15, 0.36),
    0 0 12px rgba(197, 97, 69, 0.22);
}

.custom-bet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.bet-input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(222, 187, 109, 0.62);
  border-radius: 8px;
  outline: none;
  padding: 0 7px;
  color: #f5dda0;
  background: #07191e;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.38);
}

.bet-input:focus {
  border-color: #f0cb75;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.38),
    0 0 0 2px rgba(225, 184, 94, 0.14);
}

.bet-input[aria-invalid="true"] {
  border-color: #ef735f;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.38),
    0 0 0 2px rgba(239, 91, 67, 0.18);
}

.bet-validation {
  position: absolute;
  z-index: 22;
  left: 0;
  right: 0;
  bottom: calc(100% + 7px);
  padding: 6px 8px;
  border: 1px solid rgba(239, 91, 67, 0.82);
  border-radius: 9px;
  color: #ffd0c8;
  background: rgba(73, 24, 21, 0.97);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.36);
  font-size: 8px;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.025em;
  text-align: center;
}


.main-button {
  grid-column: 1;
  grid-row: 2;
  border-radius: 15px;
}

.collect-button {
  grid-column: 2;
  grid-row: 2;
  border-radius: 15px;
}

.history {
  grid-column: 1 / -1;
  grid-row: 3;
}

.quick-bet:disabled,
.bet-input:disabled {
  cursor: default;
  filter: grayscale(0.8) brightness(0.67);
}

.max-win-panel {
  bottom: 13px;
  padding: 6px 11px;
  border-color: rgba(218, 181, 105, 0.58);
  background:
    linear-gradient(180deg, rgba(30, 59, 62, 0.93), rgba(6, 19, 23, 0.94));
}

@media (max-height: 780px) {
  .stage {
    inset: 80px 10px 220px;
  }

  .control-deck {
    height: 202px;
    grid-template-rows: 76px 58px 40px;
  }
}



/* v0.5.1 refinements */
.custom-bet-row { min-width: 0; }
.bet-input { width: 100%; font-size: 16px; letter-spacing: 0.03em; }


/* v0.7 — STATUS legend removed.
   Failure is shown by the tower-impact collapse animation. */


/* v0.7.1 — round history:
   green = successful cashout, red = failed offered multiplier. */


@media (max-width: 420px) {
  .quick-bets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bet-input {
    min-width: 56px;
  }
}

@media (max-width: 350px) {
  .control-deck {
    grid-template-columns: 0.68fr 1.72fr;
  }

  .bet-console {
    grid-template-columns: minmax(0, 1fr) minmax(56px, 0.62fr);
    column-gap: 4px;
  }

  .quick-bets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bet-input {
    min-width: 56px;
    padding-inline: 5px;
  }
}


/* v0.9 build gating */
[hidden] { display: none !important; }


/* ================================================================
   Responsive composition
   Mobile keeps the original absolute layout. The wrappers become
   real layout boxes only for the desktop two-area presentation.
   ================================================================ */

.desktop-control-panel,
.desktop-tools {
  display: contents;
}

.desktop-guide {
  display: none;
}

@media (min-width: 600px) and (max-width: 899px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app {
    width: min(92vw, 680px);
    height: min(calc(100vh - 24px), 940px);
    min-height: 760px;
    padding: 12px;
  }
}

@media (min-width: 900px) {
  body {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 16px;
  }

  .app {
    width: min(calc(100vw - 32px), 1260px);
    height: min(calc(100vh - 24px), 920px);
    min-height: 700px;
    padding: 0;
  }

  .game-shell {
    display: grid;
    grid-template-columns: minmax(480px, 1.65fr) minmax(340px, 0.85fr);
    grid-template-rows: 88px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border-radius: 32px;
  }

  .topbar {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1;
    height: auto;
    padding: 10px 18px;
    border: 1px solid rgba(205, 162, 83, 0.42);
    border-radius: 18px;
    background:
      linear-gradient(110deg, rgba(205, 162, 83, 0.06), transparent 38%),
      linear-gradient(180deg, rgba(12, 34, 40, 0.98), rgba(6, 20, 25, 0.98));
    box-shadow: inset 0 0 0 3px rgba(4, 15, 18, 0.38);
  }

  .brand h1 {
    font-size: 34px;
  }

  .top-stat strong {
    font-size: 30px;
  }

  .stage {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 24px;
  }

  .desktop-control-panel {
    position: relative;
    z-index: 10;
    grid-column: 2;
    grid-row: 1 / 3;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
  }

  .desktop-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    align-items: center;
    padding: 11px 12px 12px;
    border: 1px solid rgba(205, 162, 83, 0.48);
    border-radius: 18px;
    background:
      linear-gradient(110deg, rgba(205, 162, 83, 0.06), transparent 45%),
      linear-gradient(180deg, rgba(25, 51, 55, 0.98), rgba(7, 23, 28, 0.99));
    box-shadow:
      inset 0 0 0 3px rgba(4, 15, 18, 0.38),
      0 8px 24px rgba(0, 0, 0, 0.28);
  }

  .desktop-tools::before {
    content: "MISSION CONTROL";
    grid-column: 1 / -1;
    color: #7f9d99;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-align: center;
  }

  .sound-button {
    position: static;
    inset: auto;
    width: 100%;
    min-width: 0;
    max-width: 190px;
    height: 40px;
    justify-self: center;
    padding: 0 10px;
  }

  .info-button {
    position: static;
    inset: auto;
    width: 100%;
    min-width: 0;
    max-width: 190px;
    height: 40px;
    justify-self: center;
    padding: 0 10px;
    transform: none;
  }

  .info-button:active:not(:disabled) {
    transform: translateY(1px);
  }

  .control-deck {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows:
      84px minmax(112px, auto) 60px minmax(96px, 160px) minmax(110px, 1fr);
    gap: 9px;
    padding: 12px;
    border-radius: 20px;
  }

  .balance-readout {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-inline: 16px;
  }

  .balance-readout strong {
    font-size: 28px;
  }

  .bet-console {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: 1.25fr 0.75fr;
    grid-template-rows: 20px minmax(42px, 1fr) auto;
    padding: 10px 11px;
  }

  .quick-bets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bet-input {
    min-width: 96px;
    font-size: 18px;
  }

  .bet-validation {
    position: static;
    grid-column: 1 / -1;
    padding: 7px 9px;
    font-size: 9px;
  }

  .main-button {
    grid-column: 1;
    grid-row: 3;
    font-size: 17px;
  }

  .collect-button {
    grid-column: 2;
    grid-row: 3;
    font-size: 14px;
  }

  .history {
    grid-column: 1 / -1;
    grid-row: 4;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start;
    padding: 10px 12px;
  }

  .desktop-guide {
    grid-column: 1 / -1;
    grid-row: 5;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    align-content: center;
    min-height: 0;
    padding: 11px;
    border: 1px solid rgba(218, 181, 105, 0.34);
    border-radius: 13px;
    background:
      radial-gradient(circle at 50% 0%, rgba(86, 153, 145, 0.11), transparent 58%),
      rgba(5, 18, 22, 0.72);
  }

  .desktop-guide div {
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid rgba(120, 170, 163, 0.22);
    border-radius: 9px;
    background: rgba(13, 37, 43, 0.72);
  }

  .desktop-guide span,
  .desktop-guide strong {
    display: block;
  }

  .desktop-guide span {
    color: #e1bd6d;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  .desktop-guide strong {
    margin-top: 3px;
    color: #789490;
    font-size: 7px;
    letter-spacing: 0.11em;
  }

  .desktop-guide p {
    grid-column: 1 / -1;
    margin: 2px 0 0;
    color: #607d79;
    font-size: 7px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-align: center;
  }

  #historyList {
    align-content: flex-start;
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 100%;
  }

  .altimeter {
    top: 82px;
    left: 14px;
  }

  .result-banner {
    top: 18%;
    min-width: 220px;
  }

  .max-win-panel {
    bottom: 16px;
  }
}

@media (min-width: 900px) and (max-height: 760px) {
  .app {
    min-height: 680px;
  }

  .game-shell {
    grid-template-rows: 80px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
  }

  .desktop-control-panel {
    gap: 8px;
  }

  .desktop-tools {
    padding-block: 8px;
  }

  .sound-button {
    height: 36px;
  }

  .info-button {
    height: 36px;
  }

  .control-deck {
    grid-template-rows:
      74px minmax(104px, auto) 54px minmax(88px, 120px) minmax(96px, 1fr);
    gap: 7px;
    padding: 10px;
  }
}

/* Shared HOW TO PLAY / GAME INFO overlay. */
body.info-modal-open {
  overflow: hidden;
}

.info-modal-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 30px);
  overflow: hidden;
  background: rgba(2, 9, 12, 0.78);
  backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.info-modal-layer.is-open {
  opacity: 1;
}

.info-modal {
  width: min(720px, 100%);
  max-height: min(82dvh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid rgba(221, 182, 99, 0.86);
  border-radius: 22px;
  color: var(--cream);
  background:
    radial-gradient(circle at 78% 0%, rgba(66, 137, 133, 0.2), transparent 38%),
    linear-gradient(145deg, rgba(31, 61, 64, 0.99), rgba(6, 22, 27, 0.995));
  box-shadow:
    0 0 0 5px rgba(8, 18, 21, 0.94),
    0 0 0 7px rgba(134, 101, 50, 0.72),
    0 28px 80px rgba(0, 0, 0, 0.7),
    inset 0 0 42px rgba(81, 151, 145, 0.08);
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.info-modal-layer.is-open .info-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.info-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(218, 181, 105, 0.4);
  background: linear-gradient(180deg, rgba(7, 25, 30, 0.98), rgba(11, 34, 39, 0.94));
}

.info-modal-kicker {
  display: block;
  margin-bottom: 5px;
  color: #7eb2ad;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.info-modal h2 {
  margin: 0;
  color: #f2d999;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 3.8vw, 28px);
  letter-spacing: 0.055em;
  line-height: 1.05;
}

.info-modal-close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(231, 119, 92, 0.82);
  border-radius: 50%;
  color: #ffd5c7;
  background: linear-gradient(180deg, #a94a3b, #60241e);
  box-shadow: inset 0 0 0 3px rgba(44, 12, 10, 0.36);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.info-modal-close:hover {
  filter: brightness(1.12);
}

.info-modal-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(218, 181, 105, 0.62) rgba(4, 17, 21, 0.5);
}

.info-modal-intro {
  max-width: 58ch;
  margin: 0 auto 16px;
  color: #b8cbc6;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.info-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.info-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(218, 181, 105, 0.36);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(206, 166, 82, 0.055), transparent 40%),
    rgba(5, 20, 24, 0.7);
  box-shadow: inset 0 0 0 3px rgba(3, 13, 16, 0.28);
}

.info-card h3 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(102, 176, 168, 0.32);
  color: #77c4ba;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.info-card ol,
.info-notes {
  margin: 0;
  padding-left: 20px;
  color: #d8d4bd;
  font-size: 12px;
  line-height: 1.5;
}

.info-card li + li {
  margin-top: 7px;
}

.info-card strong {
  color: #f0c86f;
  letter-spacing: 0.035em;
}

.info-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 13px;
}

.info-specs div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(117, 176, 169, 0.24);
  border-radius: 9px;
  background: rgba(15, 43, 48, 0.78);
}

.info-specs dt {
  color: #789995;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.info-specs dd {
  margin: 4px 0 0;
  color: #f1d58f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 800;
}

.info-notes {
  color: #aebfba;
  font-size: 11px;
}

@media (max-width: 639px) {
  .info-modal-layer {
    padding: 12px;
  }

  .info-modal {
    max-height: calc(100dvh - 24px);
    border-radius: 17px;
  }

  .info-modal-header {
    padding: 14px 14px 12px;
  }

  .info-modal-close {
    width: 40px;
    height: 40px;
  }

  .info-modal-body {
    padding: 14px 14px 18px;
  }

  .info-modal-intro {
    margin-bottom: 12px;
    font-size: 12px;
  }

  .info-modal-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .info-card {
    padding: 13px;
  }
}

@media (max-width: 350px) {
  .info-modal-layer {
    padding: 8px;
  }

  .info-modal {
    max-height: calc(100dvh - 16px);
  }

  .info-modal-header {
    gap: 9px;
    padding: 12px 11px 10px;
  }

  .info-modal h2 {
    font-size: 17px;
  }

  .info-modal-body {
    padding: 11px;
  }

  .info-specs {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .info-modal-layer,
  .info-modal {
    transition: none;
  }
}
