:root {
  --cream: #FFF6E6;
  --wood: #F4A43A;
  --cherry: #E8412E;
  --mint: #2FBFA6;
  --plum: #4A2E63;
  --ink: #1E1830;
  --brass: #E9C46A;
  --wood-deep: #B96F1E;
  --plum-deep: #2B1A3D;
  --mint-deep: #137F6E;
  --gutter: clamp(12px, 1.5vw, 28px);
  --shadow: 0 10px 22px rgba(74, 46, 99, 0.28);
}

* { box-sizing: border-box; }

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

body {
  height: 100svh;
  overflow: hidden;
  background: var(--plum-deep);
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 4px;
}

.room {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--cream);
}

.hall {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 52% 50%;
  filter: blur(0.6px) saturate(0.97);
  transform: scale(1.008);
}

.room-light {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 52% at 19% 22%, rgba(255, 224, 168, 0.24), rgba(255, 224, 168, 0) 70%),
    linear-gradient(180deg, rgba(255, 246, 230, 0.04), rgba(74, 46, 99, 0.06));
}

.room-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 20vw rgba(74, 46, 99, 0.22);
  background: radial-gradient(120% 90% at 50% 42%, rgba(30, 24, 48, 0) 58%, rgba(30, 24, 48, 0.22) 100%);
}

.rebirth-door {
  position: fixed;
  left: 64%;
  top: 21%;
  width: clamp(100px, 11.5vw, 178px);
  height: clamp(220px, 42vh, 410px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
  filter: drop-shadow(0 18px 18px rgba(30, 24, 48, 0.26));
  transition: filter 0.2s ease;
}

.rebirth-door:hover { filter: drop-shadow(0 18px 22px rgba(30, 24, 48, 0.34)) brightness(1.03); }
.rebirth-door:active { transform: translateY(1px); }

.door-arch {
  position: absolute;
  inset: -7% -2% 0 -2%;
  border: 5px solid var(--wood-deep);
  border-bottom-width: 0;
  border-radius: 48% 48% 4px 4px / 27% 27% 4px 4px;
  background: linear-gradient(90deg, #6b4a82, #8a639f 20%, #b08bc0 34%, #4A2E63 64%, #35204a);
  box-shadow:
    inset 0 0 0 3px rgba(233, 196, 106, 0.55),
    inset 12px 0 26px rgba(255, 246, 230, 0.08);
}

.door-panel {
  position: absolute;
  inset: 3% 7% 5% 7%;
  border-radius: 44% 44% 3px 3px / 24% 24% 3px 3px;
  background:
    linear-gradient(90deg, rgba(255, 246, 230, 0.11), rgba(255, 246, 230, 0) 23%, rgba(30, 24, 48, 0.24) 100%),
    repeating-linear-gradient(90deg, rgba(30, 24, 48, 0.12) 0 2px, rgba(30, 24, 48, 0) 2px 18px),
    linear-gradient(180deg, #5f3d78, #4A2E63 62%, #38224e);
  box-shadow: inset 0 0 0 2px rgba(30, 24, 48, 0.35);
}

.door-seam {
  position: absolute;
  left: 50%;
  top: 6%;
  bottom: 6%;
  width: 2px;
  background: rgba(30, 24, 48, 0.34);
  box-shadow: 1px 0 0 rgba(255, 246, 230, 0.09);
}

.door-bar {
  position: absolute;
  left: -9%;
  bottom: 35%;
  width: 118%;
  height: auto;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.door-ready {
  position: absolute;
  left: 50%;
  top: -7%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 999px;
  border: 2px solid var(--brass);
  background: var(--plum);
  color: var(--cream);
  font-family: "Bagel Fat One", sans-serif;
  font-size: clamp(8px, 0.7vw, 10px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.rebirth-door.open { filter: drop-shadow(0 18px 20px rgba(30, 24, 48, 0.3)) drop-shadow(0 0 22px rgba(47, 191, 166, 0.65)); }

.rebirth-door.open .door-bar { opacity: 0; transform: translateY(-10px) rotate(-7deg); }

.rebirth-door.open .door-panel {
  box-shadow: inset 0 0 0 2px rgba(30, 24, 48, 0.35), inset 0 0 34px rgba(47, 191, 166, 0.25);
}

.rebirth-door.open .door-ready { opacity: 1; }

.stage-wrap {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: var(--gutter);
  pointer-events: none;
}

.hud-top > * { pointer-events: auto; }

.cash-cluster {
  position: relative;
  width: clamp(240px, 18.5vw, 356px);
  aspect-ratio: 572 / 322;
  flex: 0 0 auto;
}

.cash-pill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 572 / 233;
  transition: transform 0.12s ease;
}

.cash-pill.frame-tick { animation: pill-tick 0.32s ease; }

@keyframes pill-tick {
  0% { transform: scale(1); }
  35% { transform: scale(1.025) rotate(-0.4deg); }
  100% { transform: scale(1); }
}

.pill-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.coin {
  position: absolute;
  left: -8%;
  top: -12%;
  width: 29%;
  height: auto;
  z-index: 2;
  filter: drop-shadow(0 5px 5px rgba(74, 46, 99, 0.35));
  transform: rotate(-7deg);
}

.cash-amount {
  position: absolute;
  left: 27%;
  right: 7%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(22px, 2.1vw, 38px);
  line-height: 1;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.per-sec-pill {
  position: absolute;
  left: 12%;
  top: 77%;
  width: 55%;
  aspect-ratio: 378 / 207;
  z-index: 4;
}

.per-sec {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 2%;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(12px, 1.06vw, 19px);
  color: #0b3a33;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

.top-right {
  display: flex;
  align-items: flex-start;
  gap: clamp(6px, 0.8vw, 12px);
  flex: 0 0 auto;
}

.level-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.level-chip {
  position: relative;
  width: clamp(48px, 4.1vw, 72px);
  aspect-ratio: 1;
}

.chip-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.level-label {
  position: absolute;
  top: 25%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(7px, 0.55vw, 10px);
  letter-spacing: 0.16em;
  color: rgba(255, 246, 230, 0.86);
  text-shadow: 0 1px 2px rgba(30, 24, 48, 0.4);
}

.level-num {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(17px, 1.6vw, 28px);
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(30, 24, 48, 0.35);
}

.level-progress {
  width: 86%;
  height: clamp(6px, 0.72vw, 10px);
  border: 2px solid var(--brass);
  border-radius: 99px;
  background: rgba(255, 246, 230, 0.72);
  box-shadow: inset 0 1px 2px rgba(30, 24, 48, 0.25);
  overflow: hidden;
}

.level-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--mint-deep), var(--mint));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.round-btn {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.round-btn:hover { transform: translateY(-1px) rotate(3deg); filter: brightness(1.05); }
.round-btn:active { transform: translateY(1px) scale(0.97); }

.cog-btn {
  width: clamp(38px, 3.1vw, 56px);
  aspect-ratio: 1;
}

.cog-btn img { width: 100%; height: 100%; display: block; }

.sound-btn {
  width: clamp(32px, 2.5vw, 44px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf4, #f1dcc0 60%, #e9cfa8);
  border: 3px solid var(--brass);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), inset 0 -3px 0 rgba(185, 111, 30, 0.25), 0 4px 7px rgba(74, 46, 99, 0.24);
  margin-top: 3px;
}

.sound-btn svg { width: 58%; height: 58%; display: block; }

.sound-btn .slash {
  position: absolute;
  left: 18%;
  top: 48%;
  width: 64%;
  height: 3px;
  border-radius: 2px;
  background: var(--cherry);
  transform: rotate(-42deg) scaleX(0);
  transform-origin: center;
  transition: transform 0.16s ease;
  box-shadow: 0 1px 0 rgba(255, 246, 230, 0.7);
}

.sound-btn.muted .slash { transform: rotate(-42deg) scaleX(1); }

.brand-crest {
  position: fixed;
  top: clamp(10px, 1.4vh, 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 9px);
  pointer-events: none;
  white-space: nowrap;
}

.brand-plaque {
  width: clamp(36px, 3.1vw, 58px);
  height: auto;
  filter: drop-shadow(0 4px 5px rgba(74, 46, 99, 0.28));
}

.brand-word {
  margin: 0;
  font-family: "Bagel Fat One", sans-serif;
  font-weight: 400;
  font-size: clamp(20px, 1.45vw, 27px);
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 0 var(--cream), 0 0 14px rgba(255, 246, 230, 0.8);
  letter-spacing: 0.01em;
}

.upgrade-column {
  position: fixed;
  top: clamp(86px, 14vh, 148px);
  bottom: calc(var(--gutter) + clamp(140px, 20vh, 190px));
  right: var(--gutter);
  width: clamp(240px, 17.5vw, 332px);
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(74, 46, 99, 0.35) transparent;
  pointer-events: auto;
  padding-right: 3px;
}

.upgrade-column::-webkit-scrollbar { width: 5px; }
.upgrade-column::-webkit-scrollbar-thumb { background: rgba(74, 46, 99, 0.35); border-radius: 99px; }

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.15vh, 13px);
}

.card {
  position: relative;
  width: 100%;
  height: clamp(74px, 8vh, 112px);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, filter 0.16s ease;
  flex: 0 0 auto;
  border-radius: 14px;
}

.card:hover { transform: translateY(-2px); }
.card:active { transform: translateY(1px) scale(0.996); }
.card:focus-visible { outline-offset: 3px; }

.card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  filter: drop-shadow(0 7px 7px rgba(74, 46, 99, 0.22));
  transition: filter 0.16s ease;
}

.card.ready .card-frame { filter: drop-shadow(0 7px 7px rgba(74, 46, 99, 0.22)) drop-shadow(0 0 8px rgba(47, 191, 166, 0.24)); }

.card-content {
  position: absolute;
  inset: 8% 7% 8% 8%;
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.62vw, 11px);
}

.card-icon {
  flex: 0 0 auto;
  width: clamp(24px, 2.1vw, 36px);
  height: clamp(24px, 2.1vw, 36px);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 2px 2px rgba(74, 46, 99, 0.22));
}

.card-icon svg { width: 100%; height: 100%; display: block; }

.card-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.card-name {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 0.92vw, 15px);
  line-height: 1.12;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-effect {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(8.5px, 0.68vw, 11px);
  line-height: 1.15;
  color: var(--plum);
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-pips {
  display: flex;
  gap: 3px;
  margin-top: 2px;
}

.card-pips i {
  display: block;
  width: clamp(4px, 0.34vw, 5px);
  height: clamp(4px, 0.34vw, 5px);
  border-radius: 50%;
  background: rgba(30, 24, 48, 0.16);
  box-shadow: inset 0 1px 1px rgba(30, 24, 48, 0.14);
}

.card-pips i.on { background: var(--mint); box-shadow: 0 0 4px rgba(47, 191, 166, 0.65); }

.card-price {
  flex: 0 0 auto;
  min-width: clamp(46px, 4.2vw, 66px);
  height: clamp(26px, 2.2vw, 34px);
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 8px;
  border: 2px solid var(--brass);
  background: var(--cream);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 2px 0 rgba(74, 46, 99, 0.2);
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(10px, 0.84vw, 13px);
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.card.ready .card-price {
  background: var(--mint);
  border-color: var(--mint-deep);
  color: #07352e;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 2px 0 rgba(19, 127, 110, 0.4);
}

.card.short .card-price {
  background: rgba(255, 246, 230, 0.32);
  border-style: dashed;
  border-color: rgba(30, 24, 48, 0.32);
  box-shadow: none;
  color: rgba(30, 24, 48, 0.6);
}

.card.max .card-price {
  background: var(--plum);
  border-color: var(--plum-deep);
  color: var(--cream);
}

.card.flash .card-frame { animation: card-flash 0.45s ease; }

@keyframes card-flash {
  0% { filter: drop-shadow(0 7px 7px rgba(74, 46, 99, 0.22)) brightness(1); }
  40% { filter: drop-shadow(0 7px 7px rgba(74, 46, 99, 0.22)) brightness(1.18) drop-shadow(0 0 16px rgba(47, 191, 166, 0.8)); }
  100% { filter: drop-shadow(0 7px 7px rgba(74, 46, 99, 0.22)) brightness(1); }
}

.card.nope { animation: card-nope 0.32s ease; }

@keyframes card-nope {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-0.4deg); }
  65% { transform: translateX(4px) rotate(0.4deg); }
}

.left-rail {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter);
  width: clamp(250px, 22vw, 384px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 0.8vh, 10px);
  pointer-events: none;
}

.left-rail > * { pointer-events: auto; }

.plot-panel {
  width: 100%;
  padding: clamp(7px, 0.72vw, 11px) clamp(8px, 0.82vw, 13px) clamp(8px, 0.8vw, 12px);
  border: 2px solid var(--brass);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 238, 0.96), rgba(247, 229, 200, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.plot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.plot-title {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 0.66vw, 10px);
  letter-spacing: 0.16em;
  color: var(--plum);
}

.plot-open {
  border: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--plum);
  color: var(--cream);
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(7px, 0.6vw, 9px);
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(30, 24, 48, 0.3);
}

.plot-open:hover { background: var(--plum-deep); }

.plot-actions { display: flex; align-items: center; gap: 4px; }

.plot-open.daily {
  background: var(--mint);
  color: #07352e;
  border: 2px solid var(--mint-deep);
}

.plot-open.daily:hover { background: #25a58f; }

.floor-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 5px;
}

.floor-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 3px 2px;
  border: 2px solid rgba(30, 24, 48, 0.2);
  border-radius: 7px;
  background: rgba(255, 246, 230, 0.6);
  color: var(--ink);
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(8px, 0.64vw, 10px);
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.floor-tab.current {
  background: var(--plum);
  border-color: var(--plum-deep);
  color: var(--cream);
}

.floor-tab.locked {
  border-style: dashed;
  color: rgba(30, 24, 48, 0.55);
}

.floor-tab.locked:hover { border-color: var(--mint-deep); color: var(--mint-deep); }

.bay-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.bay-chip {
  position: relative;
  min-width: 0;
  padding: 4px 3px;
  border: 2px solid rgba(30, 24, 48, 0.18);
  border-radius: 8px;
  background: rgba(255, 246, 230, 0.55);
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, background 0.14s ease, border-color 0.14s ease;
}

.bay-chip:hover { transform: translateY(-1px); }
.bay-chip:active { transform: translateY(1px); }

.bay-chip .bay-dot {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: var(--brass);
  margin-bottom: 3px;
}

.bay-chip .bay-name {
  display: block;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(7px, 0.56vw, 9px);
  line-height: 1.15;
  letter-spacing: 0.03em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bay-chip .bay-sub {
  display: block;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(6.5px, 0.52vw, 8.5px);
  line-height: 1.2;
  color: var(--plum);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bay-chip.active {
  border-color: var(--mint-deep);
  background: rgba(47, 191, 166, 0.18);
  box-shadow: inset 0 0 0 1px rgba(47, 191, 166, 0.4);
}

.bay-chip.empty {
  border-style: dashed;
  background: rgba(255, 246, 230, 0.32);
}

.bay-chip.empty .bay-name { color: rgba(30, 24, 48, 0.6); }

.bay-chip.locked-floor { opacity: 0.55; }

.nameplate-cluster {
  position: relative;
  width: 100%;
  pointer-events: auto;
}

.vip-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 5px;
  padding: 3px 8px;
  border: 2px solid var(--brass);
  border-radius: 999px;
  background: var(--plum);
  color: var(--cream);
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(7.5px, 0.62vw, 9.5px);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 0 rgba(30, 24, 48, 0.24);
}

.vip-tag[hidden] { display: none; }

.nameplate {
  position: relative;
  width: 100%;
  aspect-ratio: 690 / 158;
}

.plate-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 8px 9px rgba(74, 46, 99, 0.24));
}

.plate-tier {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 8%;
  font-family: "Bagel Fat One", sans-serif;
  font-weight: 400;
  font-size: clamp(20px, 1.55vw, 27px);
  line-height: 1;
  color: var(--ink);
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.tier-notches {
  display: flex;
  justify-content: center;
  gap: clamp(3px, 0.36vw, 6px);
  margin-top: -2.2%;
  padding: 0 2%;
}

.notch {
  display: block;
  width: 12%;
  max-width: 38px;
  opacity: 0.48;
  filter: grayscale(0.55) brightness(0.9);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.notch img { width: 100%; height: auto; display: block; }

.notch.lit {
  opacity: 1;
  filter: hue-rotate(112deg) saturate(1.25) brightness(1.1) drop-shadow(0 0 5px rgba(47, 191, 166, 0.85));
}

.tier-caption {
  margin-top: 1%;
  text-align: center;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(7px, 0.6vw, 9px);
  letter-spacing: 0.18em;
  color: rgba(255, 246, 230, 0.82);
  text-shadow: 0 1px 3px rgba(30, 24, 48, 0.55);
}

.controls {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 5;
  display: flex;
  align-items: flex-end;
  gap: clamp(8px, 1.05vw, 16px);
  pointer-events: auto;
}

.control-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.auto-toggle {
  position: relative;
  width: clamp(82px, 7.1vw, 126px);
  aspect-ratio: 392 / 311;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 7px rgba(74, 46, 99, 0.28)) grayscale(0.25) brightness(0.94);
  transition: filter 0.18s ease, transform 0.12s ease;
}

.auto-toggle.on { filter: drop-shadow(0 6px 8px rgba(74, 46, 99, 0.28)) drop-shadow(0 0 10px rgba(47, 191, 166, 0.35)); }

.auto-toggle:active { transform: translateY(2px) scale(0.98); }
.auto-toggle.tick { animation: auto-tick 0.16s ease; }

@keyframes auto-tick {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(-2.4deg); }
  100% { transform: rotate(0deg); }
}

.toggle-frame { width: 100%; height: 100%; display: block; }

.state-dot {
  position: absolute;
  right: 10%;
  top: 9%;
  width: 15%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(30, 24, 48, 0.4);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.auto-toggle.on .state-dot {
  background: var(--mint);
  box-shadow: 0 0 7px rgba(47, 191, 166, 0.95), inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

.speed-dial {
  width: clamp(62px, 5.4vw, 98px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 7px rgba(74, 46, 99, 0.28));
  transition: transform 0.16s ease;
}

.speed-dial:hover { transform: translateY(-2px); }
.speed-dial:active { transform: translateY(2px) scale(0.98); }

.dial-frame {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(0deg);
  transition: transform 0.45s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.control-label {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(8px, 0.68vw, 11px);
  letter-spacing: 0.14em;
  color: rgba(255, 246, 230, 0.94);
  text-shadow: 0 1px 3px rgba(30, 24, 48, 0.7);
  white-space: nowrap;
}

.dial-read {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--brass);
}

.drop-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.drop-button {
  width: clamp(92px, 8.2vw, 136px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 12px 12px rgba(74, 46, 99, 0.38));
  transition: transform 0.08s ease, filter 0.08s ease;
}

.drop-button:hover { filter: drop-shadow(0 12px 14px rgba(74, 46, 99, 0.44)) brightness(1.04); }
.drop-button:active { transform: translateY(3px) scale(0.975); }
.drop-button.pulse { animation: drop-pulse 0.5s ease; }

@keyframes drop-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.drop-frame { width: 100%; height: 100%; display: block; }

.drop-word {
  font-family: "Bagel Fat One", sans-serif;
  font-weight: 400;
  font-size: clamp(20px, 1.35vw, 22px);
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(74, 46, 99, 0.8), 0 0 10px rgba(232, 65, 46, 0.55);
  white-space: nowrap;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: clamp(10px, 1.4vh, 18px);
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 14px;
  border: 2px solid var(--brass);
  border-radius: 999px;
  background: rgba(255, 246, 230, 0.9);
  box-shadow: 0 3px 0 rgba(74, 46, 99, 0.18);
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  font-size: clamp(10px, 0.78vw, 12px);
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
}

.big-win {
  position: fixed;
  left: 50%;
  top: 39%;
  transform: translate(-50%, -50%) scale(0.72);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.3s cubic-bezier(0.18, 1.6, 0.4, 1);
  text-align: center;
}

.big-win.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.big-win-title {
  font-family: "Bagel Fat One", sans-serif;
  font-weight: 400;
  font-size: clamp(38px, 5.6vw, 86px);
  line-height: 0.94;
  color: var(--cream);
  text-shadow:
    0 4px 0 var(--cherry),
    0 8px 0 var(--plum-deep),
    0 14px 26px rgba(30, 24, 48, 0.5);
  letter-spacing: 0.02em;
}

.big-win-amount {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(18px, 2vw, 32px);
  color: var(--brass);
  text-shadow: 0 3px 0 var(--plum-deep), 0 6px 16px rgba(30, 24, 48, 0.5);
}

.burst-layer,
.float-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.burst-piece {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform, opacity;
}

.float-value {
  position: fixed;
  z-index: 6;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(14px, 1.2vw, 20px);
  color: var(--cream);
  text-shadow: 0 2px 0 var(--plum-deep), 0 3px 8px rgba(30, 24, 48, 0.6);
  pointer-events: none;
  animation: float-up 0.95s cubic-bezier(0.16, 0.8, 0.3, 1) forwards;
  white-space: nowrap;
}

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(0.94); }
}

.toast {
  position: fixed;
  left: 50%;
  top: 17%;
  transform: translate(-50%, -6px);
  z-index: 12;
  padding: 9px 16px;
  border: 2px solid var(--brass);
  border-radius: 11px;
  background: var(--plum);
  color: var(--cream);
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(12px, 0.9vw, 14px);
  box-shadow: 0 8px 20px rgba(30, 24, 48, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.shake-stage { animation: stage-shake 0.3s ease; }

@keyframes stage-shake {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(-4px, 2px); }
  38% { transform: translate(3px, -2px); }
  62% { transform: translate(-2px, 1px); }
  82% { transform: translate(1px, -1px); }
}

.shake-panel { animation: panel-shake 0.28s ease; }

@keyframes panel-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(3px) rotate(0.15deg); }
  58% { transform: translateX(-2px) rotate(-0.1deg); }
  82% { transform: translateX(1px); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 24, 48, 0.52);
  backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] { display: none; }

.modal-panel {
  position: relative;
  width: min(560px, 94vw);
  max-height: 92svh;
  aspect-ratio: 555 / 387;
  filter: drop-shadow(0 18px 30px rgba(30, 24, 48, 0.5));
}

.tycoon-panel {
  width: min(620px, 94vw);
  aspect-ratio: auto;
  height: min(780px, 94svh);
}

.modal-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.modal-content {
  position: absolute;
  inset: 9% 8.5%;
  overflow-y: auto;
  padding: 4px 6px 8px;
  scrollbar-width: thin;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-head h2 {
  margin: 0;
  font-family: "Bagel Fat One", sans-serif;
  font-weight: 400;
  font-size: clamp(25px, 3.4vw, 36px);
  line-height: 1;
  color: var(--ink);
}

.close-btn {
  width: 32px;
  height: 32px;
  border: 2px solid var(--brass);
  border-radius: 50%;
  background: var(--cream);
  color: var(--plum);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(74, 46, 99, 0.18);
  flex: 0 0 auto;
}

.close-btn svg { width: 15px; height: 15px; }
.close-btn:hover { background: #fffdf6; }

.help h3 {
  margin: 12px 0 4px;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--plum);
}

.help p {
  margin: 0 0 6px;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  font-size: clamp(11px, 1.1vw, 13.5px);
  line-height: 1.42;
  color: rgba(30, 24, 48, 0.86);
}

.setting-rows {
  margin-top: 6px;
  border-top: 1px dashed rgba(74, 46, 99, 0.24);
}

.setting-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px dashed rgba(74, 46, 99, 0.2);
  background: transparent;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 1.05vw, 13px);
  color: var(--ink);
  text-align: left;
}

button.setting-row { cursor: pointer; }
button.setting-row:hover { color: var(--plum); }

.setting-value {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(10px, 0.95vw, 12px);
  color: var(--mint-deep);
  text-align: right;
}

.reset-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 2px dashed rgba(74, 46, 99, 0.4);
  border-radius: 9px;
  background: rgba(255, 246, 230, 0.45);
  color: var(--plum);
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.reset-btn:hover { background: rgba(255, 246, 230, 0.8); }
.reset-btn.armed { border-color: var(--cherry); color: var(--cherry); background: rgba(232, 65, 46, 0.08); }

.no-script {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--cream);
  color: var(--ink);
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
}

.tycoon-btn {
  width: clamp(34px, 2.8vw, 50px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--plum);
  background: linear-gradient(180deg, #fffdf4, #f1dcc0 60%, #e9cfa8);
  border: 3px solid var(--brass);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), inset 0 -3px 0 rgba(185, 111, 30, 0.25), 0 4px 7px rgba(74, 46, 99, 0.24);
  margin-top: 3px;
}

.tycoon-btn svg { width: 62%; height: 62%; display: block; }

.ball-stack { gap: 3px; }

.ball-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ball-chip {
  min-width: clamp(40px, 3.4vw, 54px);
  padding: 3px 5px;
  border: 2px solid rgba(30, 24, 48, 0.24);
  border-radius: 7px;
  background: rgba(255, 246, 230, 0.78);
  color: var(--ink);
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(7px, 0.56vw, 9px);
  line-height: 1.1;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(74, 46, 99, 0.16);
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.ball-chip[data-ball="golden"] { border-color: rgba(233, 196, 106, 0.85); }
.ball-chip[data-ball="diamond"] { border-color: rgba(47, 191, 166, 0.75); }

.ball-chip.is-on {
  background: var(--brass);
  border-color: var(--wood-deep);
  color: var(--ink);
}

.ball-chip[data-ball="diamond"].is-on {
  background: var(--mint);
  border-color: var(--mint-deep);
  color: #07352e;
}

.ball-chip.locked {
  border-style: dashed;
  color: rgba(30, 24, 48, 0.42);
  background: rgba(255, 246, 230, 0.34);
  box-shadow: none;
}

.ball-chip.locked.is-on { background: rgba(255, 246, 230, 0.5); }

.ball-read {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--brass);
}

.tycoon-tabs {
  display: flex;
  gap: 5px;
  margin: 8px 0 4px;
  border-bottom: 2px solid rgba(74, 46, 99, 0.18);
  padding-bottom: 5px;
}.tycoon-tab {
  flex: 1 1 0;
  padding: 5px 4px;
  border: 2px solid rgba(30, 24, 48, 0.18);
  border-radius: 8px;
  background: rgba(255, 246, 230, 0.55);
  color: var(--ink);
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 0.8vw, 11px);
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tycoon-tab.current {
  background: var(--plum);
  border-color: var(--plum-deep);
  color: var(--cream);
}

.tycoon-body {
  padding: 4px 0 8px;
}

.tycoon-section { margin-bottom: 7px; }

.tycoon-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 1.02vw, 13px);
  color: var(--ink);
  border-bottom: 1px dashed rgba(74, 46, 99, 0.16);
}

.tycoon-line:last-child { border-bottom: 0; }

.tycoon-line .val {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--plum);
  text-align: right;
  white-space: nowrap;
}

.tycoon-note {
  margin: 3px 0 6px;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  font-size: clamp(10px, 0.94vw, 12px);
  line-height: 1.4;
  color: rgba(30, 24, 48, 0.78);
}

.machine-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.machine-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 2px solid rgba(30, 24, 48, 0.18);
  border-radius: 10px;
  background: rgba(255, 246, 230, 0.6);
}

.machine-card.active {
  border-color: var(--mint-deep);
  background: rgba(47, 191, 166, 0.14);
}

.machine-card.empty {
  border-style: dashed;
  background: rgba(255, 246, 230, 0.35);
}

.machine-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 34px;
  border-radius: 6px;
  border: 2px solid rgba(30, 24, 48, 0.22);
  background: var(--brass);
}

.machine-copy { flex: 1 1 auto; min-width: 0; }

.machine-name {
  display: block;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1vw, 13px);
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-sub {
  display: block;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(8.5px, 0.76vw, 10px);
  line-height: 1.25;
  color: var(--plum);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mini-btn {
  border: 2px solid var(--brass);
  border-radius: 7px;
  padding: 3px 7px;
  background: var(--cream);
  color: var(--ink);
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(8px, 0.7vw, 9.5px);
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(74, 46, 99, 0.16);
}

.mini-btn.buy {
  background: var(--mint);
  border-color: var(--mint-deep);
  color: #07352e;
}

.mini-btn.gold {
  background: var(--brass);
  border-color: var(--wood-deep);
}

.tycoon-section > .mini-btn {
  width: 100%;
  padding: 8px 10px;
  font-size: clamp(9px, 0.78vw, 11px);
}

.mini-btn:disabled {
  border-style: dashed;
  background: rgba(255, 246, 230, 0.4);
  color: rgba(30, 24, 48, 0.45);
  box-shadow: none;
  cursor: default;
}

.pet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.pet-card {
  padding: 6px 7px;
  border: 2px solid rgba(30, 24, 48, 0.18);
  border-radius: 10px;
  background: rgba(255, 246, 230, 0.6);
}

.pet-card.owned {
  border-color: var(--mint-deep);
  background: rgba(47, 191, 166, 0.14);
}

.pet-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pet-orb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(30, 24, 48, 0.28);
  background: var(--mint);
  flex: 0 0 auto;
}

.pet-name {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 0.9vw, 12px);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pet-rarity {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  font-size: clamp(7px, 0.62vw, 9px);
  color: var(--plum);
  letter-spacing: 0.03em;
}

.pet-bonus {
  margin: 2px 0 4px;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  font-size: clamp(9px, 0.8vw, 10.5px);
  line-height: 1.3;
  color: rgba(30, 24, 48, 0.76);
}

.pet-card .mini-btn { width: 100%; padding: 4px 6px; }

.rebirth-bar {
  width: 100%;
  height: 14px;
  border: 2px solid var(--plum);
  border-radius: 99px;
  background: rgba(255, 246, 230, 0.7);
  overflow: hidden;
  margin: 6px 0 3px;
}

.rebirth-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brass), var(--cherry));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.world-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border: 2px solid rgba(30, 24, 48, 0.18);
  border-radius: 10px;
  background: rgba(255, 246, 230, 0.55);
}

.world-row.current {
  border-color: var(--mint-deep);
  background: rgba(47, 191, 166, 0.14);
}

.world-name {
  display: block;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1vw, 13px);
  color: var(--ink);
}

.world-sub {
  display: block;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  font-size: clamp(9px, 0.78vw, 10.5px);
  color: rgba(30, 24, 48, 0.66);
}

.lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: clamp(10px, 0.9vw, 12px);
  color: var(--ink);
  border-bottom: 1px dashed rgba(74, 46, 99, 0.16);
}

.lead-row a { color: var(--plum); text-decoration: underline; }
.lead-row .val { font-family: "Chivo Mono", monospace; font-weight: 700; color: var(--plum); }


@media (max-width: 1240px) {
  .rebirth-door { display: none; }
}

@media (max-width: 1100px) {
  .brand-crest { display: none; }
}

@media (max-height: 560px) {
  .hint, .brand-crest { display: none; }
}

@media (max-width: 900px) and (orientation: portrait) {
  body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  }

  .rebirth-door { display: none; }

  .hud-top {
    position: relative;
    grid-row: 1;
    padding: 10px 12px 6px;
    gap: 8px;
  }

  .cash-cluster {
    width: clamp(178px, 52vw, 240px);
    aspect-ratio: 572 / 320;
  }

  .coin { left: -3%; }

  .cash-amount {
    font-size: clamp(19px, 5.6vw, 26px);
  }

  .per-sec {
    font-size: clamp(10px, 3vw, 13px);
  }

  .top-right { gap: 5px; }

  .level-chip { width: clamp(42px, 12vw, 54px); }
  .level-num { font-size: clamp(15px, 4.4vw, 20px); }
  .level-label { font-size: 6.5px; }
  .level-progress { height: 6px; }

  .cog-btn { width: clamp(34px, 10vw, 44px); }
  .sound-btn { width: clamp(28px, 8.4vw, 38px); border-width: 2px; }

  .stage-wrap {
    position: relative;
    inset: auto;
    grid-row: 2;
    min-height: 0;
    pointer-events: none;
  }

  .nameplate-cluster {
    position: relative;
    inset: auto;
    width: auto;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .left-rail {
    position: relative;
    inset: auto;
    grid-row: 3;
    width: auto;
    margin: 0 12px;
    gap: 4px;
  }

  .tycoon-tab { font-size: 8px; padding: 4px 2px; letter-spacing: 0; }
  .plot-panel { padding: 5px 8px 6px; border-radius: 10px; }
  .plot-head { margin-bottom: 3px; }
  .plot-title { font-size: 8px; }
  .floor-tabs { margin-bottom: 3px; gap: 3px; }
  .floor-tab { font-size: 8px; padding: 2px 1px; }
  .bay-row { gap: 3px; }
  .bay-chip { padding: 3px 2px; }
  .bay-chip .bay-name { font-size: 7.5px; }
  .bay-chip .bay-sub { font-size: 7px; }
  .bay-chip .bay-dot { height: 4px; margin-bottom: 2px; }

  .nameplate { width: min(250px, 64vw); flex: 0 0 auto; }

  .plate-tier {
    font-size: clamp(20px, 4.2vw, 22px);
    padding: 0 12%;
  }

  .tier-notches {
    flex: 0 0 auto;
    width: min(250px, 64vw);
    justify-content: space-between;
    margin-top: 1px;
    padding: 0;
    gap: 2px;
  }

  .notch { width: clamp(24px, 6.5vw, 32px); flex: 0 0 auto; max-width: 32px; opacity: 0.4; }
  .tier-caption { display: none; }

  .upgrade-column {
    position: relative;
    inset: auto;
    grid-row: 4;
    width: auto;
    max-height: none;
    margin: 4px 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-right: 0;
    padding-bottom: 3px;
  }

  .upgrade-list {
    display: flex;
    flex-direction: row;
    gap: 7px;
    scroll-snap-type: x proximity;
  }

  .card {
    flex: 0 0 clamp(148px, 43vw, 188px);
    height: clamp(74px, 10.2vh, 92px);
    scroll-snap-align: start;
  }

  .card-content { inset: 9% 7% 9% 7%; gap: 5px; }
  .card-icon { width: 20px; height: 20px; }
  .card-name { font-size: clamp(10px, 2.9vw, 12px); }
  .card-effect { font-size: clamp(8px, 2.4vw, 10px); white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.12; }
  .card-price { min-width: 44px; height: 24px; font-size: clamp(9px, 2.5vw, 11px); }
  .card-pips { display: none; }

  .controls {
    position: relative;
    inset: auto;
    grid-row: 5;
    right: auto;
    bottom: auto;
    margin: 4px 12px max(8px, env(safe-area-inset-bottom));
    gap: 10px;
    justify-content: flex-end;
    align-items: flex-end;
  }

  .auto-toggle { width: clamp(72px, 21vw, 100px); }
  .speed-dial { width: clamp(54px, 15vw, 74px); }
  .drop-button { width: clamp(78px, 23vw, 110px); }
  .drop-word { font-size: 20px; }
  .control-label { font-size: clamp(7px, 2.1vw, 9px); }

  .hint { display: none; }

  .big-win { top: 34%; }

  .toast {
    top: 13%;
    max-width: 88vw;
    white-space: normal;
    text-align: center;
  }

  .modal-panel { aspect-ratio: auto; width: min(520px, 94vw); }
  .modal-content { position: relative; inset: auto; margin: 10% 9%; max-height: 74svh; }
  .modal-frame { height: 100%; }
}

@media (max-width: 900px) and (orientation: portrait) and (max-height: 740px) {
  .hud-top { padding: 6px 10px 4px; }
  .cash-cluster { width: clamp(150px, 47vw, 200px); }
  .cash-amount { font-size: clamp(17px, 4.8vw, 22px); }
  .per-sec { font-size: clamp(9px, 2.6vw, 11px); }
  .level-chip { width: 38px; }
  .level-num { font-size: 16px; }
  .level-label { font-size: 6px; }
  .sound-btn { width: 26px; }
  .cog-btn { width: 32px; }
  .nameplate-cluster { margin: 0 10px; }
  .nameplate { width: min(230px, 60vw); }
  .plate-tier { font-size: 20px; }
  .tier-notches { width: min(230px, 60vw); }
  .upgrade-column { margin: 2px 10px 0; }
  .upgrade-list { gap: 5px; }
  .card { flex-basis: clamp(140px, 44vw, 175px); height: 64px; }
  .card-content { inset: 8% 6% 8% 7%; gap: 4px; }
  .card-icon { width: 17px; height: 17px; }
  .card-name { font-size: 9.5px; }
  .card-effect { font-size: 7.5px; }
  .card-price { min-width: 40px; height: 21px; font-size: 8.5px; }
  .controls { margin: 3px 10px max(6px, env(safe-area-inset-bottom)); gap: 8px; }
  .auto-toggle { width: 66px; }
  .speed-dial { width: 48px; }
  .drop-button { width: 72px; }
  .drop-word { font-size: 20px; }
  .control-label { font-size: 6.5px; }
}

@media (max-width: 520px) {
  .level-progress { display: none; }
  .cash-cluster { width: clamp(168px, 50vw, 210px); }
  .card-name { font-size: 10.5px; }
}

@media (max-height: 620px) and (min-width: 901px) {
  .upgrade-column { top: 78px; max-height: calc(100svh - 170px); }
  .card { height: 92px; }
  .nameplate-cluster { width: 230px; }
  .drop-button { width: 86px; }
  .auto-toggle { width: 78px; }
  .speed-dial { width: 58px; }
  .brand-crest { display: none; }
}

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