:root {
  --bg: #0d1014;
  --panel: #151a1f;
  --panel-deep: #0b1015;
  --text: #d8d3c6;
  --accent: #d5b164;
  --accent-strong: #f0cf88;
  --danger: #d96c63;
  --border: #3a342b;
  --border-soft: #5b4d33;
  --shadow: rgba(0, 0, 0, 0.42);
  --ui-font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display-font: "Russo One", "Trebuchet MS", sans-serif;
  --mono-font: "IBM Plex Mono", "Consolas", monospace;
  --app-width: 100vw;
  --app-height: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at top, rgba(72, 62, 36, 0.22), transparent 42%),
    linear-gradient(180deg, #08090b, #050607 62%, #040404);
}

@supports (height: 100dvh) {
  html, body {
    height: 100dvh;
    min-height: 100dvh;
  }
}

body {
  color: var(--text);
  font-family: var(--ui-font);
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Desktop: canvas + panel centred, fills height */
.wrap {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 18%),
    linear-gradient(180deg, #101419, #0a0d10);
  border: none;
  height: 100vh;
  /* width is set by JS (canvas size + panel width) */
  box-shadow: 0 20px 50px var(--shadow);
}

canvas {
  display: block;
  flex-shrink: 0;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

/* Side stats panel */
.ui {
  width: 220px;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 14%),
    linear-gradient(180deg, var(--panel), var(--panel-deep));
  border-left: 2px solid var(--border-soft);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.4;
  align-self: stretch;
  overflow-y: auto;
  box-shadow: inset 1px 0 0 rgba(255,255,255,0.04);
}

.ui h1 {
  font: 400 17px/1 var(--display-font);
  color: var(--accent-strong);
  letter-spacing: 1.2px;
  border-bottom: 1px solid rgba(213, 177, 100, 0.28);
  padding: 0 0 6px;
  margin-bottom: 3px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.45);
}

.block {
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  padding: 6px 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 38%),
    #101419;
}

.block-label {
  font-size: 9px;
  color: #83755d;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  margin-bottom: 3px;
  font-family: var(--mono-font);
}

.msg {
  color: #f0d49a;
  font-size: 10px;
  line-height: 1.45;
  min-height: 30px;
  font-style: normal;
  font-family: var(--ui-font);
  display: flex;
  align-items: center;
}

.danger { color: var(--danger); }

.music-btn {
  width: 100%;
  border: 1px solid #45403a;
  background: linear-gradient(180deg, #1b2127, #13181d);
  color: #d0c7b2;
  padding: 5px 6px;
  font-family: var(--mono-font);
  font-size: 10px;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: 0.4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.music-btn:hover { background: linear-gradient(180deg, #252c33, #171d22); }

.ui-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.vol-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 3px 0;
}
.vol-label {
  font-size: 9px;
  color: #83755d;
  font-family: var(--mono-font);
  white-space: nowrap;
  min-width: 52px;
}
.vol-val {
  font-size: 9px;
  color: #ad9160;
  font-family: var(--mono-font);
  min-width: 20px;
  text-align: right;
}
.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: #2a2520;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid #7a6436;
  cursor: pointer;
}
.vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid #7a6436;
  cursor: pointer;
}

.bonus-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-top: 3px;
}

.bonus-item {
  border: 1px solid #4b3f2a;
  background: linear-gradient(180deg, rgba(213, 177, 100, 0.12), rgba(213, 177, 100, 0.04));
  color: #ad9160;
  padding: 4px 5px;
  text-align: center;
  font-family: var(--mono-font);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-height: 38px;
}

.bonus-name {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bonus-desc {
  font-size: 7px;
  color: rgba(230, 219, 198, 0.78);
  line-height: 1.2;
}

#stats {
  font-size: 10px;
  line-height: 1.45;
  font-family: var(--mono-font);
}

#stats hr {
  border: none;
  border-top: 1px solid #222;
  margin: 2px 0;
}

#stats .stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

#stats .stat-label {
  color: #8f836d;
  font-size: 9px;
  letter-spacing: 0.7px;
  min-width: 46px;
}

#stats .stat-main {
  flex: 1;
  color: #ddd6c9;
}

#stats .stat-sub {
  color: #756b59;
  font-size: 9px;
  white-space: nowrap;
}

#stats .stat-alert { color: #ffcc66; }
#stats .stat-good { color: #7ed48a; }
#stats .stat-danger { color: #ff8173; }
#stats .stat-boss { color: #ff8c74; }

/* Start menu */
.start-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 20%, rgba(213, 177, 100, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(6, 8, 11, 0.9), rgba(2, 3, 5, 0.94));
  backdrop-filter: blur(4px);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
}
.start-menu.is-hidden { display: none; }

.start-card {
  position: relative;
  width: min(540px, calc(100vw - 32px));
  max-height: min(92vh, 860px);
  overflow: auto;
  border: 1px solid #5c4c31;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.05),
    0 26px 60px rgba(0,0,0,0.55);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 12%),
    linear-gradient(180deg, #11161b, #090c10);
  padding: 24px 24px 18px;
}

.start-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.start-kicker {
  color: #8e7e61;
  font: 500 11px/1.1 var(--mono-font);
  letter-spacing: 1.9px;
}

.start-logo {
  color: var(--accent-strong);
  font: 400 30px/1 var(--display-font);
  letter-spacing: 1.6px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.55);
}

.start-subtitle {
  color: #a99c87;
  font-size: 13px;
  line-height: 1.45;
  max-width: 44ch;
}

.start-progress {
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid rgba(213, 177, 100, 0.22);
  background: rgba(213, 177, 100, 0.08);
  color: #e1d4b8;
  font: 500 11px/1.4 var(--mono-font);
}

.start-view {
  display: none;
}

.start-view.is-active {
  display: block;
}

.start-actions,
.start-inline-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.start-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.start-action-half {
  width: 100%;
  text-align: center;
}

.start-action-full {
  grid-column: 1 / -1;
}

.start-inline-actions {
  flex-direction: row;
}

.start-action,
.mobile-menu-toggle,
.player-card,
.segment-btn,
.segment-toggle {
  border: 1px solid #5a4c35;
  background: linear-gradient(180deg, #1c2228, #15191f);
  color: #d6ccb7;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.start-action {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  text-align: left;
  font: 700 14px/1.1 var(--mono-font);
  letter-spacing: 1px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

.start-action-primary {
  border-color: #7a6436;
  background: linear-gradient(180deg, #45331a, #24190d);
  color: #f6e2b2;
}

.start-action:hover:not(:disabled),
.player-card:hover:not(:disabled),
.segment-btn:hover:not(:disabled),
.segment-toggle:hover:not(:disabled),
.mobile-menu-toggle:hover {
  filter: brightness(1.14);
}

.start-action:active:not(:disabled),
.player-card:active:not(:disabled),
.segment-btn:active:not(:disabled),
.segment-toggle:active:not(:disabled),
.mobile-menu-toggle:active {
  transform: translateY(1px) scale(0.995);
}

.start-action:disabled,
.player-card:disabled {
  opacity: 0.46;
  cursor: default;
}

.start-action.is-focused,
.player-card.is-focused,
.segment-btn.is-focused,
.segment-toggle.is-focused,
.option-slider.is-focused {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(240, 207, 136, 0.45);
}

.start-section-title {
  margin-bottom: 12px;
  color: var(--accent-strong);
  font: 400 19px/1 var(--display-font);
  letter-spacing: 1.2px;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.player-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 122px;
  padding: 14px 14px 13px;
  text-align: left;
}

.player-card.is-active,
.segment-btn.is-active,
.segment-toggle.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: linear-gradient(180deg, #2d2414, #1a150d);
}

.player-card.is-disabled {
  opacity: 0.5;
}

.player-card-icon {
  color: #f3c149;
  font: 700 18px/1 var(--mono-font);
}

.player-card-name {
  color: #e4dac5;
  font: 700 14px/1.2 var(--ui-font);
}

.player-card-desc {
  color: #9a8c74;
  font-size: 11px;
  line-height: 1.45;
}

.hint {
  margin-bottom: 14px;
  color: #90806a;
  font-size: 12px;
  line-height: 1.55;
}

.option-group {
  border: 1px solid #332a1d;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  padding: 12px 12px 10px;
}

.option-group + .option-group {
  margin-top: 12px;
}

.option-group-title {
  margin-bottom: 10px;
  color: #d7c7a7;
  font: 600 12px/1 var(--ui-font);
  letter-spacing: 0.8px;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.7fr) 36px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.option-row + .option-row {
  margin-top: 8px;
}

.option-label,
.segment-label {
  color: #c8beaa;
  font-size: 12px;
  line-height: 1.3;
}

.option-value {
  color: #f0cf88;
  text-align: right;
  font: 700 11px/1 var(--mono-font);
}

.option-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #2a2520;
  cursor: pointer;
}

.option-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 1px solid #7a6436;
}

.option-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 1px solid #7a6436;
}

.option-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.segment-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segment-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segment-btn,
.segment-toggle {
  min-height: 38px;
  padding: 9px 12px;
  font: 700 11px/1 var(--mono-font);
  letter-spacing: 0.7px;
}

.segment-toggle {
  min-width: 88px;
}

.confirm-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm-text {
  color: #bcae96;
  font-size: 13px;
  line-height: 1.5;
}

.start-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(213, 177, 100, 0.16);
}

.start-status {
  color: #7f735f;
  font: 500 10px/1.45 var(--mono-font);
}

.rotate-lock {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding:
    max(16px, var(--safe-top))
    max(16px, var(--safe-right))
    max(16px, var(--safe-bottom))
    max(16px, var(--safe-left));
  background:
    radial-gradient(circle at 50% 18%, rgba(213, 177, 100, 0.16), transparent 30%),
    rgba(4, 6, 9, 0.94);
  backdrop-filter: blur(10px);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
}

.rotate-lock[hidden] {
  display: none !important;
}

.rotate-lock.on {
  display: flex !important;
}

.rotate-card {
  width: min(520px, calc(100vw - 28px));
  border-radius: 20px;
  border: 1px solid rgba(213, 177, 100, 0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 14%),
    linear-gradient(180deg, #12171d, #090c10);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.05),
    0 24px 56px rgba(0,0,0,0.52);
  padding: 26px 22px 20px;
}

.rotate-card h2 {
  color: var(--accent-strong);
  font: 400 24px/1.05 var(--display-font);
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

.rotate-card p {
  color: #cfc3aa;
  font-size: 14px;
  line-height: 1.6;
}

.rotate-card p + p {
  margin-top: 10px;
  color: #9e9177;
}

.mobile-menu-toggle {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 43;
  width: 30px;
  height: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  font: 700 13px/1 var(--mono-font);
}

/* ═══ TOUCH STEERING (mobile only) ═══ */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-steer {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 62%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Visual feedback: anchor dot + ring */
/* steer-hint is positioned by JS via left/top (centre of joystick anchor) */
.steer-hint {
  position: absolute;
  width: 112px;
  height: 112px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.75;
  overflow: hidden;
}
.steer-hint.visible { opacity: 0.75; }

/* Ring stays centred inside hint via transform */
.steer-ring {
  position: absolute;
  width: 92px; height: 92px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.18);
}

/* Dot: JS sets left/top as % inside hint, transform centres it on that point */
.steer-dot {
  position: absolute;
  width: 34px; height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.26);
  transform: translate(-50%, -50%);
}

/* Right side: FIRE button at bottom + PAUSE above it */
.touch-actions {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 38%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  padding-right: 20px;
  padding-bottom: 20px;
  gap: 14px;
  pointer-events: none;
}

.touch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(22,22,22,0.9);
  color: rgba(255,255,255,0.9);
  font: 700 14px/1 var(--mono-font);
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.touch-fire {
  width: 108px; height: 108px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  background: rgba(160,40,40,0.8);
  border-color: rgba(210,70,70,0.55);
  color: #ff9c8b;
}
.touch-fire.is-active, .touch-fire:active {
  background: rgba(240,60,60,0.9);
}

.touch-pause {
  width: 78px; height: 44px;
  font-size: 13px;
}

/* Mobile class */
body.mobile .touch-controls { display: block; }
body.mobile .mobile-menu-toggle {
  display: flex;
  top: calc(8px + var(--safe-top));
  right: calc(8px + var(--safe-right));
  width: 44px;
  height: 44px;
  font-size: 16px;
}
body.mobile {
  position: fixed;
  inset: 0;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.mobile .wrap {
  position: fixed;
  inset: 0;
  flex-direction: column;
  border: none;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
  align-items: center;
  justify-content: flex-start;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
  touch-action: none;
}

body.mobile canvas {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(
    calc(var(--app-width, 100vw) - var(--safe-left) - var(--safe-right)),
    calc(var(--app-height, 100vh) - var(--safe-top) - var(--safe-bottom))
  ) !important;
  height: min(
    calc(var(--app-width, 100vw) - var(--safe-left) - var(--safe-right)),
    calc(var(--app-height, 100vh) - var(--safe-top) - var(--safe-bottom))
  ) !important;
  margin: 0 auto;
}

body.mobile #fullscreenToggle {
  display: none;
}

body.mobile .ui {
  position: fixed;
  right: var(--safe-right);
  top: 0;
  bottom: 0;
  width: min(250px, 78vw);
  border-left: 2px solid var(--border);
  border-top: none;
  overflow-y: auto;
  z-index: 34;
  transform: translateX(105%);
  transition: transform 0.22s ease;
  padding-top: calc(58px + var(--safe-top));
  padding-bottom: calc(14px + var(--safe-bottom));
  touch-action: pan-y;
  overscroll-behavior: contain;
}

body.mobile .touch-controls {
  inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

body.mobile .touch-actions {
  padding-right: calc(20px + var(--safe-right));
  padding-bottom: calc(20px + var(--safe-bottom));
}

body.mobile .touch-pause {
  width: 88px;
  height: 48px;
}

body.mobile .shop-overlay {
  padding:
    calc(10px + var(--safe-top))
    calc(12px + var(--safe-right))
    calc(12px + var(--safe-bottom))
    calc(12px + var(--safe-left));
}

body.mobile-portrait .touch-controls,
body.mobile-portrait .mobile-menu-toggle {
  opacity: 0;
  pointer-events: none;
}

body.mobile-portrait .ui {
  transform: translateX(105%);
}

body.mobile.menu-open .ui {
  transform: translateX(0);
}

body.start-open .mobile-menu-toggle,
body.start-open .touch-controls {
  opacity: 0;
  pointer-events: none;
}

body.start-open .ui {
  transform: translateX(105%);
}

body.mobile .start-menu {
  padding:
    calc(14px + var(--safe-top))
    calc(14px + var(--safe-right))
    calc(14px + var(--safe-bottom))
    calc(14px + var(--safe-left));
}

body.mobile .start-card {
  width: min(100%, 560px);
  max-height: calc(var(--app-height, 100vh) - var(--safe-top) - var(--safe-bottom) - 28px);
  padding: 20px 16px 14px;
}

body.mobile.mobile-landscape .start-card {
  max-height: calc(var(--app-height, 100vh) - var(--safe-top) - var(--safe-bottom) - 16px);
  padding: 14px 14px 10px;
}

body.mobile.mobile-landscape .start-brand {
  gap: 5px;
  margin-bottom: 10px;
}

body.mobile.mobile-landscape .start-kicker {
  font-size: 10px;
  letter-spacing: 1.5px;
}

body.mobile.mobile-landscape .start-logo {
  font-size: 22px;
}

body.mobile.mobile-landscape .start-subtitle {
  font-size: 11px;
  line-height: 1.3;
}

body.mobile.mobile-landscape .start-progress {
  margin-bottom: 10px;
  padding: 7px 10px;
  font-size: 10px;
}

body.mobile.mobile-landscape .start-actions,
body.mobile.mobile-landscape .start-inline-actions {
  gap: 8px;
}

body.mobile.mobile-landscape .start-action,
body.mobile.mobile-landscape .segment-btn,
body.mobile.mobile-landscape .segment-toggle,
body.mobile.mobile-landscape .player-card {
  min-height: 42px;
}

body.mobile.mobile-landscape .start-action {
  padding: 10px 12px;
  font-size: 12px;
}

body.mobile.mobile-landscape .start-section-title {
  margin-bottom: 10px;
  font-size: 16px;
}

body.mobile.mobile-landscape .option-group {
  margin-bottom: 10px;
}

body.mobile.mobile-landscape .option-stack {
  gap: 8px;
}

body.mobile.mobile-landscape .start-footer {
  margin-top: 10px;
  padding-top: 8px;
}

body.mobile.mobile-landscape .start-status {
  font-size: 9px;
  line-height: 1.3;
}

body.mobile .player-grid {
  grid-template-columns: 1fr;
}

body.mobile .start-inline-actions {
  flex-direction: column;
}

body.mobile .segment-control {
  flex-direction: column;
  align-items: stretch;
}

body.mobile .segment-buttons {
  justify-content: stretch;
}

body.mobile .segment-btn,
body.mobile .segment-toggle,
body.mobile .start-action,
body.mobile .player-card {
  min-height: 48px;
}

/* ── Shop overlay ── */
/* ════════════════ SHOP OVERLAY ════════════════ */
.shop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(5px);
  padding: 12px;
  overflow-y: auto;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
}
.shop-overlay.is-open { display: flex; }

.shop-card {
  width: 100%;
  max-width: 760px;
  max-height: min(calc(var(--app-height, 100vh) - 24px), 760px);
  border: 1px solid #8b6f3a;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.04),
    0 24px 56px rgba(0,0,0,0.56);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 16%),
    linear-gradient(180deg, #11151a, #090c10);
  font-family: var(--ui-font);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.shop-card.final-level {
  border-color: #cc4400;
  box-shadow: 0 0 24px rgba(200,60,0,0.25);
}
.shop-card.final-level .shop-header {
  background: linear-gradient(180deg, #200800, #0f0400);
  border-bottom-color: #661800;
}

/* Header strip */
.shop-header {
  background: linear-gradient(180deg, #262013, #12151a);
  border-bottom: 1px solid #594728;
  padding: 13px 16px 11px;
}

.shop-title {
  color: var(--accent-strong);
  font: 400 20px/1 var(--display-font);
  letter-spacing: 1.5px;
  margin-bottom: 2px;
}

.shop-next-level {
  font-size: 10px;
  color: #886622;
  letter-spacing: 0.8px;
}

/* Score bar */
.shop-score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #0f1318;
  border-bottom: 1px solid #2f2618;
}

.shop-score-label { color: #8b7b5d; font-size: 10px; font-family: var(--mono-font); }
.shop-score-value { color: var(--accent-strong); font-size: 15px; font-weight: 700; letter-spacing: 0.8px; font-family: var(--mono-font); }

/* Items */
.shop-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 14px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: #7b6131 #11161a;
}

.shop-items::-webkit-scrollbar { width: 8px; }
.shop-items::-webkit-scrollbar-track { background: #11161a; }
.shop-items::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6f5529, #44341a);
  border-radius: 999px;
}

.shop-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 8px;
  border: 1px solid #3b3226;
  background: linear-gradient(180deg, #131920, #0f1419);
  padding: 9px 10px;
  transition: background 0.12s;
  min-height: 78px;
}
.shop-item:hover { background: linear-gradient(180deg, #181f26, #11161c); }
.shop-item.is-owned { border-color: #1a3018; background: #090e08; }

.shop-item-icon {
  font-size: 17px;
  text-align: center;
  line-height: 1;
  margin-top: 2px;
}

.shop-item-info { min-width: 0; }
.shop-item-name {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.35px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono-font);
}
.shop-item-desc {
  color: #938670;
  font-size: 9px;
  line-height: 1.28;
  min-height: 23px;
}

#controlsInfo {
  color: #bcb3a1;
  font-size: 10px;
  line-height: 1.5;
}
.shop-item-tag {
  display: inline-block;
  font-size: 8px;
  padding: 1px 4px;
  border: 1px solid #443010;
  color: #886030;
  margin-top: 2px;
  letter-spacing: 0.35px;
}
.shop-item-tag.permanent { border-color: #1a4030; color: #4a9060; }

.shop-buy-btn {
  border: 1px solid #786131;
  background: linear-gradient(160deg, #3b3120, #1d2127);
  color: #f4deaa;
  padding: 7px 9px;
  font: 700 10px/1 var(--mono-font);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 68px;
  text-align: center;
  transition: filter 0.1s;
  align-self: center;
}
.shop-buy-btn:hover:not(:disabled):not(.owned) { filter: brightness(1.4); }
.shop-buy-btn:active:not(:disabled) { filter: brightness(0.9); }
.shop-buy-btn:disabled { opacity: 0.35; cursor: default; }
.shop-buy-btn.owned {
  border-color: #2a5a2a;
  color: #5a9a5a;
  background: #070e07;
  cursor: default;
  letter-spacing: 0.5px;
}

/* Message & footer */
.shop-msg {
  min-height: 18px;
  color: #f3c149;
  font-size: 10px;
  text-align: center;
  padding: 5px 16px 0;
  letter-spacing: 0.35px;
}

/* Player selector bar */
.shop-player-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #0a0800;
  border-bottom: 1px solid #2a2000;
}

.shop-player-btn {
  border: 1px solid #4a3800;
  background: linear-gradient(180deg, #1d2329, #151a20);
  color: #9c927f;
  padding: 4px 14px;
  font: 700 11px/1 var(--mono-font);
  cursor: pointer;
}
.shop-player-btn.is-active {
  border-color: #c8a840;
  color: #f3c149;
  background: #241c00;
}

.shop-footer {
  padding: 10px 14px 14px;
}

.shop-close {
  width: 100%;
  border: 1px solid #655230;
  background: linear-gradient(180deg, #2b2413, #171b21);
  color: var(--accent-strong);
  padding: 12px;
  font: 700 12px/1 var(--mono-font);
  cursor: pointer;
  letter-spacing: 2px;
  transition: filter 0.1s;
}
.shop-close:hover { filter: brightness(1.3); }
.shop-close:active { filter: brightness(0.9); }

/* ═══ VISUAL POLISH ═══ */
/* Smooth fade-in for start menu */
.start-menu {
  animation: menuFadeIn 0.35s ease-out;
}
@keyframes menuFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.start-card {
  animation: cardSlideIn 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Subtle pulsing glow on primary action buttons */
.start-action-primary {
  animation: btnGlow 2.4s ease-in-out infinite;
}
@keyframes btnGlow {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03), 0 0 8px rgba(213,177,100,0.08); }
  50% { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 0 14px rgba(213,177,100,0.18); }
}

/* Battle button accent */
.start-action-battle {
  border-color: #8b4430;
  background: linear-gradient(180deg, #3a1a10, #1e110a);
  color: #ffb89a;
}
.start-action-battle:hover:not(:disabled) {
  border-color: #bb5540;
}

/* Logo shimmer effect */
.start-logo {
  background: linear-gradient(90deg, var(--accent-strong) 0%, #ffe8b0 40%, var(--accent-strong) 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: logoShimmer 4s ease-in-out infinite;
}
@keyframes logoShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Shop overlay entrance */
.shop-overlay.is-open {
  animation: shopFadeIn 0.3s ease-out;
}
@keyframes shopFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.shop-overlay.is-open .shop-card {
  animation: shopCardIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes shopCardIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Shop item hover lift */
.shop-item {
  transition: background 0.12s, transform 0.12s ease, box-shadow 0.12s ease;
}
.shop-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

/* Smooth slider thumb transitions */
.vol-slider::-webkit-slider-thumb,
.option-slider::-webkit-slider-thumb {
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.vol-slider::-webkit-slider-thumb:hover,
.option-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 6px rgba(213,177,100,0.3);
}

/* Stat row hover highlight */
#stats .stat-row {
  transition: background 0.1s ease;
  padding: 2px 2px;
  margin: 0 -2px;
  border-radius: 2px;
}
#stats .stat-row:hover {
  background: rgba(213,177,100,0.06);
}

/* Side panel subtle divider gradient */
.ui h1 {
  background: linear-gradient(90deg, var(--accent-strong), rgba(213,177,100,0.6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Mobile: more compact ── */
@media (max-width: 500px), (max-height: 600px) {
  .shop-card { max-width: 100%; max-height: calc(100vh - 8px); }
  .shop-header { padding: 10px 12px 9px; }
  .shop-title { font-size: 15px; letter-spacing: 1.3px; }
  .shop-score-bar { padding: 7px 12px; }
  .shop-score-value { font-size: 13px; }
  .shop-items { grid-template-columns: 1fr; padding: 8px 8px 10px; gap: 6px; }
  .shop-item { padding: 8px 9px; gap: 7px; min-height: 70px; }
  .shop-item-icon { font-size: 16px; width: 24px; }
  .shop-item-name { font-size: 11px; }
  .shop-item-desc { font-size: 9px; }
  .shop-buy-btn { padding: 7px 8px; font-size: 10px; min-width: 64px; }
  .shop-msg { font-size: 9px; padding: 4px 12px 0; }
  .shop-footer { padding: 8px 8px 10px; }
  .shop-close { padding: 11px; font-size: 12px; }
}
