:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  --cream: #f5e3b4;
  --gold: #f1b839;
  --orange: #e56a24;
  --red: #c72e27;
  --blue: #3998c7;
  --wood: #4b2d1b;
  --ink: #0b0908;
  --panel: rgba(18, 13, 10, 0.96);
  --green: #9ad247;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--cream);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 8%, rgba(197, 48, 39, 0.30), transparent 27%),
    radial-gradient(circle at 86% 10%, rgba(44, 130, 178, 0.25), transparent 28%),
    linear-gradient(180deg, #17110d 0%, #080706 64%, #020202 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.13) 0 2px, transparent 2px 7px);
  mix-blend-mode: overlay;
}

.game-shell {
  width: min(97vw, 944px);
  position: relative;
  padding: 18px;
  border: 2px solid #815027;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(63, 37, 22, 0.90), rgba(14, 10, 8, 0.98)),
    #110c09;
  box-shadow:
    0 32px 90px rgba(0, 0, 0, 0.76),
    inset 0 0 0 4px rgba(24, 13, 8, 0.92),
    inset 0 0 0 6px rgba(184, 111, 44, 0.17);
}

.brand { text-align: center; margin-bottom: 11px; }
.brand-kicker {
  margin: 0 0 3px;
  color: #c7b89b;
  font-size: clamp(0.62rem, 1.7vw, 0.83rem);
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--cream);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.05rem, 6.3vw, 4.25rem);
  line-height: 0.92;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  text-shadow: 0 4px 0 #4b1a15, 0 0 18px rgba(255, 211, 104, 0.16);
}

h1 .hot {
  color: #dd3b2f;
  text-shadow: 0 4px 0 #681d18, 0 0 18px rgba(221, 59, 47, 0.30);
}

h1 .beer {
  color: #f4b735;
  text-shadow: 0 4px 0 #7f4a0f, 0 0 18px rgba(244, 183, 53, 0.28);
}

.subtitle {
  margin: 7px 0 0;
  color: #bba98e;
  font-size: clamp(0.68rem, 1.8vw, 0.9rem);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.hud {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 7px;
}

.hud-item {
  min-width: 0;
  padding: 7px 5px 6px;
  border: 1px solid rgba(238, 172, 70, 0.27);
  border-radius: 7px;
  color: #b9a78b;
  background: linear-gradient(180deg, rgba(45, 29, 20, 0.98), rgba(18, 13, 10, 0.98));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  text-align: center;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-item strong {
  display: block;
  min-height: 1.2em;
  margin-top: 2px;
  overflow: hidden;
  color: #fff4d3;
  font-size: clamp(0.78rem, 2vw, 1rem);
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lives-item strong { color: #e65a43; letter-spacing: 0.12em; }

.route-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(0, 2.2fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 9px;
  padding: 7px 10px;
  border: 1px solid rgba(212, 139, 52, 0.25);
  border-radius: 8px;
  background: rgba(9, 7, 6, 0.78);
}

.route-copy { min-width: 0; }
.route-copy strong,
.route-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-copy strong {
  color: #ead7ad;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.route-copy span {
  margin-top: 2px;
  color: #90816d;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.route-stop {
  position: relative;
  min-width: 0;
  padding: 4px 3px 4px 24px;
  border: 1px solid #3e2c20;
  border-radius: 4px;
  background: #15100d;
  color: #6f6252;
  line-height: 1;
}

.route-stop i {
  position: absolute;
  top: 50%;
  left: 5px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #332419;
  color: #9d896e;
  font: 900 8px Arial, sans-serif;
}

.route-stop b {
  display: block;
  overflow: hidden;
  font: 800 7px Arial, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-stop.complete { border-color: #657d35; color: #b9cc86; }
.route-stop.complete i { background: #5b762d; color: #f1f6d2; }
.route-stop.active {
  border-color: #d09434;
  color: #f1d69e;
  background: #2b1b11;
  box-shadow: 0 0 10px rgba(241,184,57,0.12);
}
.route-stop.active i { background: #d09434; color: #23130a; }

.canvas-frame {
  position: relative;
  overflow: hidden;
  border: 5px solid #4f2e1c;
  border-radius: 11px;
  background: #100b08;
  box-shadow:
    0 0 0 2px #a9672b,
    0 0 0 5px #1b100b,
    0 18px 42px rgba(0, 0, 0, 0.62),
    0 0 28px rgba(221, 58, 42, 0.12);
}

.canvas-frame::before,
.canvas-frame::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #f0c17d 0 18%, #704321 42%, #25150d 78%);
  box-shadow: 0 0 0 1px #140b07;
}
.canvas-frame::before { left: 7px; }
.canvas-frame::after { right: 7px; }

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #17100b;
  cursor: default;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
}

button {
  min-height: 40px;
  border: 1px solid #b87531;
  border-radius: 7px;
  padding: 8px 14px;
  color: #25150b;
  background: linear-gradient(180deg, #f2c15a, #c87c25);
  box-shadow: 0 4px 0 #754019, inset 0 1px 0 rgba(255,255,255,0.55);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 3px solid #fff3b5; outline-offset: 3px; }
button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #754019, inset 0 1px 0 rgba(255,255,255,0.45);
}
button.secondary {
  border-color: #805934;
  color: #f3e0b5;
  background: linear-gradient(180deg, #584337, #2a1c15);
  box-shadow: 0 4px 0 #170e09, inset 0 1px 0 rgba(255,255,255,0.08);
}
button:disabled {
  opacity: 0.43;
  cursor: not-allowed;
  filter: grayscale(0.4);
}


.audio-panel {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(120px, 1fr)) minmax(110px, auto);
  gap: 10px;
  align-items: center;
  margin-top: 11px;
  padding: 9px 11px;
  border: 1px solid rgba(212, 139, 52, 0.25);
  border-radius: 8px;
  background: rgba(9, 7, 6, 0.78);
}
.audio-panel label {
  display: grid;
  grid-template-columns: auto minmax(62px, 1fr);
  gap: 7px;
  align-items: center;
  color: #c6b391;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.audio-panel input[type="range"] {
  width: 100%;
  accent-color: #e1a238;
  cursor: pointer;
}
.audio-panel .audio-mute { min-height: 34px; padding: 6px 10px; }
.audio-track-status {
  overflow: hidden;
  color: #857765;
  font-size: 0.62rem;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.help {
  max-width: 780px;
  margin: 11px auto 0;
  color: #9f917d;
  text-align: center;
  font-size: 0.77rem;
  line-height: 1.45;
}
.help strong { color: #e6cc98; }

.dpad {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 46px);
  gap: 6px;
  width: max-content;
  margin: 15px auto 0;
  user-select: none;
}
.dpad button { min-height: 0; padding: 0; font-size: 1.16rem; }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }

.selftest-output {
  width: min(900px, 95vw);
  margin: 20px auto;
  padding: 18px;
  white-space: pre-wrap;
  border: 1px solid #6c9f45;
  border-radius: 8px;
  background: #071008;
  color: #c8f2a8;
  font: 14px/1.5 Consolas, monospace;
}

body.asset-mode { display: block; padding: 0; background: #080604; }
body.asset-mode .game-shell {
  width: 100%; max-width: none; min-height: 100vh; padding: 0;
  border: 0; border-radius: 0; background: #080604; box-shadow: none;
}
body.asset-mode .brand,
body.asset-mode .hud,
body.asset-mode .route-panel,
body.asset-mode .controls-row,
body.asset-mode .audio-panel,
body.asset-mode .dpad,
body.asset-mode .help { display: none; }
body.asset-mode .canvas-frame { border: 0; border-radius: 0; box-shadow: none; }
body.asset-mode .canvas-frame::before,
body.asset-mode .canvas-frame::after { display: none; }

@media (max-width: 840px), (pointer: coarse) {
  body { padding: 10px; }
  .game-shell { padding: 13px; }
  .dpad { display: grid; }
}

@media (max-width: 720px) {
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-panel { grid-template-columns: 1fr; gap: 6px; }
  .route-copy { text-align: center; }
}

@media (max-width: 520px) {
  body { padding: 5px; }
  .game-shell { padding: 9px; border-radius: 12px; }
  .brand-kicker { letter-spacing: 0.12em; }
  .subtitle { letter-spacing: 0.05em; }
  .hud { gap: 4px; }
  .hud-item { font-size: 0.55rem; letter-spacing: 0.035em; }
  .route-stop { padding-left: 20px; }
  .route-stop b { display: none; }
  .route-stop i { left: 50%; transform: translate(-50%, -50%); }
  .controls-row { gap: 6px; }
  button { padding: 8px 9px; font-size: 0.68rem; }
  .help { font-size: 0.68rem; }
}


@media (max-width: 760px) {
  .audio-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audio-panel .audio-mute { grid-column: 1; }
  .audio-track-status { grid-column: 2; text-align: right; }
}
@media (max-width: 520px) {
  .audio-panel { grid-template-columns: 1fr; }
  .audio-panel label { grid-template-columns: 58px minmax(0, 1fr); }
  .audio-track-status { grid-column: auto; text-align: center; }
}


/* Phase 7 */
.controller-status {
  display: block;
  margin-top: 4px;
  color: #6f9f70;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}
.controller-status.connected { color: #b7dd4a; }
/* Fullscreen fix: the game-shell itself is the fullscreen element. */
.game-shell:fullscreen,
.game-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  background: #080706;
  box-shadow: none;
}

.game-shell:fullscreen .brand,
.game-shell:fullscreen .controls-row,
.game-shell:fullscreen .audio-panel,
.game-shell:fullscreen .help,
.game-shell:fullscreen .release-version,
.game-shell:-webkit-full-screen .brand,
.game-shell:-webkit-full-screen .controls-row,
.game-shell:-webkit-full-screen .audio-panel,
.game-shell:-webkit-full-screen .help,
.game-shell:-webkit-full-screen .release-version {
  display: none !important;
}

.game-shell:fullscreen .hud,
.game-shell:fullscreen .route-panel,
.game-shell:-webkit-full-screen .hud,
.game-shell:-webkit-full-screen .route-panel {
  width: min(100%, 944px);
  margin: 0;
  flex: 0 0 auto;
}

.game-shell:fullscreen .canvas-frame,
.game-shell:-webkit-full-screen .canvas-frame {
  width: min(100%, calc((100vh - 138px) * 1.4));
  max-width: 100%;
  max-height: calc(100vh - 138px);
  margin: auto 0;
  flex: 0 1 auto;
}

.game-shell:fullscreen canvas,
.game-shell:-webkit-full-screen canvas {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 138px);
}

@media (max-height: 620px) {
  .game-shell:fullscreen .route-panel,
  .game-shell:-webkit-full-screen .route-panel {
    display: none;
  }
  .game-shell:fullscreen .canvas-frame,
  .game-shell:-webkit-full-screen .canvas-frame {
    width: min(100%, calc((100vh - 72px) * 1.4));
    max-height: calc(100vh - 72px);
  }
  .game-shell:fullscreen canvas,
  .game-shell:-webkit-full-screen canvas {
    max-height: calc(100vh - 72px);
  }
}

[hidden] { display: none !important; }
.release-version {
  margin: 10px 0 0;
  text-align: center;
  color: #7f715f;
  font: 700 0.65rem/1.2 Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Version 1.1.2 mobile controls layout */
.hud-label { display: block; }
.mobile-actions,
.mobile-input-panel,
.rotate-overlay,
.swipe-hint { display: none; }

.dpad button.is-active,
.mobile-actions button.is-active {
  filter: brightness(1.22);
  transform: translateY(3px);
  box-shadow: 0 1px 0 #754019, inset 0 1px 0 rgba(255,255,255,0.45);
}

/*
  Mobile layout is controlled by viewport classes applied in game.js rather
  than CSS orientation queries. Some mobile browsers and embedded previews
  report orientation late or incorrectly after rotation.
*/
html.mobile-landscape,
html.mobile-landscape body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

html.mobile-landscape body {
  display: block;
  padding: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #080706;
}

html.mobile-landscape body::before { opacity: 0.08; }

html.mobile-landscape .game-shell,
html.mobile-landscape .game-shell:fullscreen,
html.mobile-landscape .game-shell:-webkit-full-screen {
  width: 100vw;
  height: var(--app-height, 100dvh);
  max-width: none;
  min-height: 0;
  margin: 0;
  padding:
    max(4px, env(safe-area-inset-top))
    max(6px, env(safe-area-inset-right))
    max(4px, env(safe-area-inset-bottom))
    max(6px, env(safe-area-inset-left));
  overflow: hidden;
  border: 0;
  border-radius: 0;
  visibility: visible;
  pointer-events: auto;
  display: grid;
  grid-template-columns: clamp(108px, 18vw, 164px) minmax(0, 1fr) clamp(88px, 15vw, 132px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "hud hud hud"
    "input game actions";
  gap: 5px 7px;
  align-items: center;
  justify-content: stretch;
  background: #080706;
  box-shadow: none;
}

html.mobile-landscape .brand,
html.mobile-landscape .route-panel,
html.mobile-landscape .controls-row,
html.mobile-landscape .audio-panel,
html.mobile-landscape .help,
html.mobile-landscape .release-version {
  display: none !important;
}

html.mobile-landscape .hud,
html.mobile-landscape .game-shell:fullscreen .hud,
html.mobile-landscape .game-shell:-webkit-full-screen .hud {
  grid-area: hud;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
}

html.mobile-landscape .hud-item {
  min-height: 31px;
  padding: 3px 3px 2px;
  border-radius: 5px;
  font-size: clamp(0.42rem, 1.15vw, 0.57rem);
  letter-spacing: 0.025em;
  line-height: 1;
}

html.mobile-landscape .hud-item strong {
  min-height: 0;
  margin-top: 1px;
  font-size: clamp(0.66rem, 1.85vw, 0.92rem);
  line-height: 1;
}

html.mobile-landscape .canvas-frame,
html.mobile-landscape .game-shell:fullscreen .canvas-frame,
html.mobile-landscape .game-shell:-webkit-full-screen .canvas-frame {
  grid-area: game;
  position: relative;
  align-self: center;
  justify-self: center;
  width: min(100%, calc((var(--app-height, 100dvh) - 45px) * 1.4));
  max-width: 100%;
  max-height: calc(var(--app-height, 100dvh) - 45px);
  aspect-ratio: 7 / 5;
  margin: 0;
  border-width: 3px;
  border-radius: 7px;
  box-shadow: 0 0 0 1px #a9672b, 0 0 0 3px #1b100b, 0 8px 22px rgba(0,0,0,0.68);
}

html.mobile-landscape .canvas-frame::before,
html.mobile-landscape .canvas-frame::after { display: none; }

html.mobile-landscape canvas,
html.mobile-landscape .game-shell:fullscreen canvas,
html.mobile-landscape .game-shell:-webkit-full-screen canvas {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  touch-action: none;
}

html.mobile-landscape .swipe-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 5px;
  display: block;
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 1px solid rgba(241,184,57,0.34);
  border-radius: 999px;
  color: rgba(245,227,180,0.78);
  background: rgba(8,7,6,0.72);
  font-size: clamp(0.46rem, 1.2vw, 0.62rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

html.mobile-landscape .swipe-hint.visible { opacity: 1; }

html.mobile-landscape .mobile-input-panel {
  grid-area: input;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
  width: min(100%, 164px);
  min-height: 0;
  margin: 0;
  align-self: center;
  justify-self: center;
  touch-action: none;
}

html.mobile-landscape .dpad {
  display: none;
  grid-template-columns: repeat(3, minmax(34px, 1fr));
  grid-template-rows: repeat(2, clamp(43px, 13vh, 62px));
  gap: 5px;
  width: 100%;
  margin: 0;
  align-self: center;
  justify-self: center;
  touch-action: none;
}

html.mobile-landscape.control-mode-arrows .dpad,
html.mobile-landscape .control-mode-arrows .dpad,
html.control-mode-arrows.mobile-landscape .dpad {
  display: grid;
}

html.mobile-landscape .dpad button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 10px;
  font-size: clamp(1.05rem, 4vw, 1.55rem);
  touch-action: none;
}

html.mobile-landscape .swipe-pad {
  position: relative;
  display: none;
  width: 100%;
  min-height: clamp(94px, 27vh, 145px);
  overflow: hidden;
  border: 2px solid #76502f;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 50%, rgba(241,184,57,0.15) 0 23%, transparent 24%),
    linear-gradient(145deg, rgba(72,43,25,0.92), rgba(20,13,9,0.96));
  box-shadow: 0 5px 0 #43250f, inset 0 0 0 3px rgba(14,9,6,0.72), inset 0 0 28px rgba(0,0,0,0.38);
  touch-action: none;
}

html.control-mode-swipe.mobile-landscape .swipe-pad { display: block; }

html.mobile-landscape .swipe-pad::before,
html.mobile-landscape .swipe-pad::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  opacity: 0.22;
}

html.mobile-landscape .swipe-pad::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  border-left: 1px solid #c38a42;
}

html.mobile-landscape .swipe-pad::after {
  top: 50%;
  left: 8%;
  right: 8%;
  border-top: 1px solid #c38a42;
}

html.mobile-landscape .swipe-direction {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: rgba(242,218,166,0.56);
  font: 900 clamp(1.05rem, 3.5vw, 1.5rem)/1 Arial, sans-serif;
  transition: color 90ms ease, transform 90ms ease, text-shadow 90ms ease;
  pointer-events: none;
}

html.mobile-landscape .swipe-up { left: 50%; top: 3px; transform: translateX(-50%); }
html.mobile-landscape .swipe-down { left: 50%; bottom: 3px; transform: translateX(-50%); }
html.mobile-landscape .swipe-left { left: 3px; top: 50%; transform: translateY(-50%); }
html.mobile-landscape .swipe-right { right: 3px; top: 50%; transform: translateY(-50%); }

html.mobile-landscape .swipe-pad[data-active-direction="up"] .swipe-up,
html.mobile-landscape .swipe-pad[data-active-direction="down"] .swipe-down,
html.mobile-landscape .swipe-pad[data-active-direction="left"] .swipe-left,
html.mobile-landscape .swipe-pad[data-active-direction="right"] .swipe-right {
  color: #ffe39b;
  text-shadow: 0 0 10px rgba(241,184,57,0.95);
}

html.mobile-landscape .swipe-pad[data-active-direction="up"] .swipe-up { transform: translateX(-50%) scale(1.2); }
html.mobile-landscape .swipe-pad[data-active-direction="down"] .swipe-down { transform: translateX(-50%) scale(1.2); }
html.mobile-landscape .swipe-pad[data-active-direction="left"] .swipe-left { transform: translateY(-50%) scale(1.2); }
html.mobile-landscape .swipe-pad[data-active-direction="right"] .swipe-right { transform: translateY(-50%) scale(1.2); }

html.mobile-landscape .swipe-pad-center {
  position: absolute;
  z-index: 1;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 1px;
  transform: translate(-50%, -50%);
  color: #e9cf93;
  text-align: center;
  font-family: Consolas, monospace;
  line-height: 1;
  letter-spacing: 0.08em;
  pointer-events: none;
}

html.mobile-landscape .swipe-pad-center strong { font-size: clamp(0.56rem, 1.7vw, 0.76rem); }
html.mobile-landscape .swipe-pad-center span { color: #9c896a; font-size: clamp(0.38rem, 1.15vw, 0.52rem); }

html.mobile-landscape .swipe-thumb {
  --thumb-x: 50%;
  --thumb-y: 50%;
  position: absolute;
  z-index: 3;
  left: var(--thumb-x);
  top: var(--thumb-y);
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255,227,155,0.9);
  border-radius: 50%;
  background: rgba(241,184,57,0.28);
  box-shadow: 0 0 14px rgba(241,184,57,0.62);
  transform: translate(-50%, -50%) scale(0.65);
  opacity: 0;
  transition: opacity 80ms ease, transform 80ms ease;
  pointer-events: none;
}

html.mobile-landscape .swipe-thumb.is-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

html.mobile-landscape .control-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 100%;
  padding: 3px;
  border: 1px solid #6e4829;
  border-radius: 8px;
  background: #130d09;
  touch-action: manipulation;
}

html.mobile-landscape .control-mode-switch button {
  min-width: 0;
  min-height: 25px;
  padding: 3px 2px;
  border: 0;
  border-radius: 5px;
  color: #9f8b6b;
  background: transparent;
  box-shadow: none;
  font-size: clamp(0.46rem, 1.25vw, 0.6rem);
  letter-spacing: 0.035em;
  touch-action: manipulation;
}

html.mobile-landscape .control-mode-switch button.is-selected {
  color: #241407;
  background: linear-gradient(#f7d67f, #d7932d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.48);
}

html.mobile-landscape .mobile-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  width: 100%;
  align-self: center;
  justify-self: stretch;
  touch-action: none;
}

html.mobile-landscape .mobile-actions button {
  width: 100%;
  min-height: clamp(36px, 10vh, 54px);
  padding: 5px 4px;
  border-radius: 8px;
  font-size: clamp(0.55rem, 1.55vw, 0.74rem);
  line-height: 1.05;
  touch-action: manipulation;
}

@media (max-width: 740px) {
  html.mobile-landscape .game-shell,
  html.mobile-landscape .game-shell:fullscreen,
  html.mobile-landscape .game-shell:-webkit-full-screen {
    grid-template-columns: clamp(132px, 24vw, 150px) minmax(0, 1fr) clamp(82px, 15vw, 100px);
    gap: 3px 5px;
  }

  html.mobile-landscape .hud { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html.mobile-landscape .character-hud { display: none; }
  html.mobile-landscape .hud-item { min-height: 28px; }
  html.mobile-landscape .dpad { grid-template-rows: repeat(2, clamp(39px, 12vh, 52px)); gap: 4px; }
  html.mobile-landscape .swipe-pad { min-height: clamp(88px, 26vh, 126px); }
  html.mobile-landscape .mobile-input-panel { gap: 3px; }
  html.mobile-landscape .control-mode-switch button { min-height: 22px; }
  html.mobile-landscape .mobile-actions { gap: 4px; }
  html.mobile-landscape .mobile-actions button { min-height: clamp(32px, 9.5vh, 46px); }
}

@media (max-height: 350px) {
  html.mobile-landscape .hud-item { min-height: 27px; padding: 2px; }
  html.mobile-landscape .hud-label { display: block; font-size: 0.38rem; }
  html.mobile-landscape .hud-item strong { margin-top: 1px; font-size: clamp(0.62rem, 1.9vw, 0.78rem); }
  html.mobile-landscape .canvas-frame,
  html.mobile-landscape .game-shell:fullscreen .canvas-frame,
  html.mobile-landscape .game-shell:-webkit-full-screen .canvas-frame {
    width: min(100%, calc((var(--app-height, 100dvh) - 34px) * 1.4));
    max-height: calc(var(--app-height, 100dvh) - 34px);
  }
}

html.mobile-portrait,
html.mobile-portrait body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

html.mobile-portrait body { padding: 0; background: #080706; }
html.mobile-portrait .game-shell { visibility: hidden; pointer-events: none; }

html.mobile-portrait .rotate-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 22%, rgba(199,46,39,0.28), transparent 34%),
    linear-gradient(180deg, #17110d, #050403);
  text-align: center;
}

.rotate-card {
  width: min(92vw, 420px);
  padding: 28px 22px;
  border: 2px solid #815027;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(63,37,22,0.95), rgba(14,10,8,0.99));
  box-shadow: 0 24px 70px rgba(0,0,0,0.72), inset 0 0 0 4px rgba(24,13,8,0.92);
}

.rotate-phone {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 4.5rem;
  line-height: 1;
  animation: mobile-rotate-nudge 1.8s ease-in-out infinite;
}

.rotate-card h2 {
  margin: 0;
  color: #f3d38b;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2rem, 9vw, 3.2rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rotate-card p {
  margin: 12px 0 0;
  color: #c7b89b;
  font-size: 1rem;
  font-weight: 800;
}

.rotate-continue {
  margin-top: 18px;
  min-width: 170px;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 0.78rem;
}

html.mobile-landscape .rotate-overlay { display: none !important; }

@keyframes mobile-rotate-nudge {
  0%, 100% { transform: rotate(-16deg); }
  50% { transform: rotate(16deg); }
}
