:root {
  color-scheme: dark;
  --ink: #151329;
  --paper: #fff4ed;
  --pink: #ff8dbb;
  --cyan: #79f8ee;
  --amber: #ffa858;
  --purple: #352349;
  --deck: #131024;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #090913;
  color: var(--paper);
  font-family: 'Courier New', monospace;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  font: 700 14px 'Courier New', monospace;
  letter-spacing: .04em;
  color: inherit;
  border: 1px solid #ffffff4a;
  background: #24203b;
  cursor: pointer;
  min-height: 44px;
  padding: 12px 18px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}

button:hover {
  background: #3c3156;
  border-color: var(--pink);
}

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

button:disabled {
  opacity: .35;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.primary {
  background: var(--pink);
  color: #25132a;
  border: 0;
  box-shadow: 4px 4px 0 #733654;
}

.primary:hover {
  background: #ffbad5;
}

button:active, button.down {
  transform: translateY(2px) scale(0.97);
}

[hidden] {
  display: none !important;
}

/* ==========================================================
   DEFAULT / DESKTOP LAYOUT (16:9 Arcade Cabinet)
   ========================================================== */

#game-container {
  position: relative;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
  background: #090913;
}

#screen-viewport {
  position: relative;
  width: min(100vw, 177.7778vh);
  height: min(100vh, 56.25vw);
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.screen {
  position: absolute;
  inset: 0;
}

/* ==========================================================
   FULLSCREEN TITLE SCREEN (Always full height, never clipped!)
   ========================================================== */

#title-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: linear-gradient(90deg, rgba(10, 8, 20, 0.94) 0%, rgba(13, 10, 26, 0.88) 42%, rgba(16, 12, 32, 0.28) 72%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  overflow-y: auto;
  overflow-x: hidden;
}

.title-split-layout {
  width: 100%;
  max-width: 1220px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  position: relative;
}

/* ==========================================================
   LEFT PANEL: PREMIUM ACTION & BRANDING MENU
   ========================================================== */

.title-left-panel {
  flex: 0 0 min(540px, 48vw);
  max-width: 540px;
  background: linear-gradient(145deg, rgba(22, 17, 39, 0.88) 0%, rgba(13, 10, 25, 0.94) 100%);
  border: 1px solid rgba(255, 141, 187, 0.25);
  border-radius: 24px;
  padding: 30px 34px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 0 35px rgba(121, 248, 238, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  animation: titlePanelSlide 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes titlePanelSlide {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: rgba(255, 141, 187, 0.12);
  border: 1px solid rgba(255, 141, 187, 0.35);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--pink);
  width: fit-content;
  box-shadow: 0 0 15px rgba(255, 141, 187, 0.2);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 10px var(--pink);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.title-brand-group {
  margin: 14px 0 10px;
}

.premium-logo {
  font-family: Impact, 'Arial Black', sans-serif;
  font-size: clamp(42px, 5.5vw, 68px);
  line-height: 0.86;
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 25px rgba(255, 141, 187, 0.4), 3px 3px 0 #3a1b32;
}

.premium-logo > span {
  color: var(--pink);
  text-shadow: 0 0 25px rgba(255, 141, 187, 0.6), 3px 3px 0 #3a1b32;
}

.cross {
  font-family: monospace;
  font-size: 0.6em;
  vertical-align: top;
  display: inline-block;
  padding-top: 4px;
  margin-left: 6px;
  color: var(--cyan);
  text-shadow: 0 0 18px var(--cyan);
}

.premium-sub {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-top: 6px;
  text-shadow: 0 0 10px rgba(121, 248, 238, 0.4);
}

.premium-synopsis {
  font-size: 13px;
  line-height: 1.5;
  color: #c7bed8;
  margin: 8px 0 20px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Premium Action Button Deck */
.title-actions-deck {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-premium {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  cursor: pointer;
  border: 0;
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-flare {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-25deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.btn-premium:hover .btn-flare {
  left: 150%;
}

.btn-flex-content {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
}

.btn-icon {
  font-size: 22px;
  line-height: 1;
}

.btn-text-block {
  display: flex;
  flex-direction: column;
}

.btn-label-primary {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.15;
}

.btn-label-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.85;
  margin-top: 2px;
}

/* Hero Start Story Button */
.btn-hero-start {
  min-height: 62px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #ff8dbb 0%, #ee5192 60%, #c4276b 100%);
  color: #1a0d20;
  box-shadow: 0 8px 25px rgba(255, 141, 187, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.btn-hero-start:hover {
  background: linear-gradient(135deg, #ffa8cc 0%, #ff62a3 60%, #d8317c 100%);
  box-shadow: 0 12px 35px rgba(255, 141, 187, 0.7);
  transform: translateY(-2px);
}

.btn-hero-start:active {
  transform: translateY(2px) scale(0.98);
}

/* Quick Play Arcade Button */
.btn-hero-quick {
  min-height: 54px;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(32, 25, 54, 0.95), rgba(18, 35, 52, 0.95));
  border: 2px solid var(--cyan);
  color: #fff;
  box-shadow: 0 4px 18px rgba(121, 248, 238, 0.25);
}

.btn-hero-quick .btn-icon {
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
}

.btn-hero-quick:hover {
  background: linear-gradient(135deg, rgba(42, 33, 72, 0.95), rgba(24, 48, 72, 0.95));
  border-color: #fff;
  box-shadow: 0 8px 28px rgba(121, 248, 238, 0.45);
  transform: translateY(-2px);
}

.btn-hero-quick:active {
  transform: translateY(2px) scale(0.98);
}

/* Secondary Actions Subrow */
.title-button-subrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.btn-sub-how, .btn-sub-sound {
  min-height: 42px;
  padding: 8px 12px;
  background: rgba(30, 24, 52, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #d6ccdf;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-sub-how:hover, .btn-sub-sound:hover {
  background: rgba(46, 36, 78, 0.92);
  border-color: var(--pink);
  color: #fff;
  transform: translateY(-1px);
}

/* Footer Score & Meta Row */
.title-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: #a49cb5;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.05em;
}

.score-pill strong {
  color: #fff;
}

.lore-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--pink);
  opacity: 0.85;
}

#load-status {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 11px;
  color: var(--cyan);
  font-weight: 800;
}

/* ==========================================================
   RIGHT PANEL: FLOATING CHARACTER STAGE BADGES
   ========================================================== */

.title-right-panel {
  flex: 1;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 24px 10px;
  box-sizing: border-box;
}

.stage-floating-badge {
  background: rgba(16, 13, 30, 0.72);
  border: 1px solid rgba(121, 248, 238, 0.35);
  border-radius: 14px;
  padding: 10px 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(121, 248, 238, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: badgeFloat 4s ease-in-out infinite alternate;
}

.stage-badge-top {
  border-color: rgba(255, 141, 187, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 141, 187, 0.15);
}

.stage-badge-bottom {
  animation-delay: -2s;
}

@keyframes badgeFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.badge-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 12px var(--pink);
}

.badge-status-dot.pulse-cyan {
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.badge-content {
  display: flex;
  flex-direction: column;
}

.badge-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fff;
}

.badge-detail {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
}

.stage-badge-top .badge-detail {
  color: var(--pink);
}

/* ==========================================================
   RESPONSIVE OVERRIDES FOR TITLE SCREEN
   ========================================================== */

@media (max-width: 900px) {
  .title-split-layout {
    flex-direction: column;
    justify-content: center;
    gap: 16px;
  }

  .title-left-panel {
    flex: 1;
    max-width: 100%;
    width: 100%;
    padding: 20px;
  }

  .title-right-panel {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .title-left-panel {
    padding: 16px 22px;
  }

  .premium-synopsis {
    display: none;
  }

  .premium-logo {
    font-size: 40px;
  }

  .btn-hero-start {
    min-height: 48px;
    padding: 8px 16px;
  }

  .btn-hero-quick {
    min-height: 44px;
    padding: 8px 14px;
  }

  .btn-sub-how, .btn-sub-sound {
    min-height: 36px;
  }

  .title-footer-row {
    margin-top: 10px;
    padding-top: 8px;
  }
}

/* ==========================================================
   TOP BAR TOOLS
   ========================================================== */

#top-tools {
  position: absolute;
  right: 12px;
  top: 10px;
  display: flex;
  gap: 8px;
  z-index: 15;
}

#top-tools button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 11px;
  background: #151329d9;
  backdrop-filter: blur(8px);
  border: 1px solid #ffffff30;
  border-radius: 8px;
}

/* ==========================================================
   DIALOGUE OVERLAY
   ========================================================== */

.dialogue {
  position: absolute;
  bottom: 14px;
  left: 16px;
  right: 16px;
  background: linear-gradient(135deg, rgba(25, 20, 44, 0.96) 0%, rgba(16, 12, 30, 0.98) 100%);
  border: 1.5px solid rgba(255, 141, 187, 0.45);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 141, 187, 0.12), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  z-index: 30;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.dialogue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #eed6ec;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
}

.dialogue-heading button {
  padding: 4px 12px;
  min-height: 28px;
  background: rgba(255, 141, 187, 0.12);
  border: 1px solid rgba(255, 141, 187, 0.35);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--pink);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dialogue-heading button:hover {
  background: rgba(255, 141, 187, 0.25);
  transform: translateY(-1px);
}

.dialogue-content {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 20px;
  min-height: 124px;
}

#portrait {
  border: 2px solid rgba(255, 141, 187, 0.5);
  image-rendering: auto;
  background: #251c36;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.4);
}

#speaker {
  color: var(--pink);
  letter-spacing: .08em;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(255, 141, 187, 0.3);
}

#dialogue-text {
  line-height: 1.6;
  font-size: 16px;
  margin: 0;
  min-height: 44px;
  color: #f8fafc;
  font-weight: 500;
}

#next-dialogue {
  align-self: flex-end;
  background: linear-gradient(135deg, #79f8ee 0%, #38d6cb 100%);
  color: #0b2326;
  font-weight: 800;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.05em;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: 0 4px 16px rgba(121, 248, 238, 0.4);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#next-dialogue:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 22px rgba(121, 248, 238, 0.6);
}

#next-dialogue span {
  font-size: 16px;
  margin-left: 6px;
  font-weight: bold;
}

/* ==========================================================
   MODAL WINDOWS (Pause, Game Over, Help)
   ========================================================== */

.modal {
  display: grid;
  place-items: center;
  background: #080817d9;
  backdrop-filter: blur(10px);
  z-index: 60;
  padding: 16px;
}

.modal-card {
  background: #211b34;
  border: 2px solid #91789f;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9);
  border-radius: 14px;
  width: min(540px, 92vw);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px 20px;
}

.modal h2 {
  font-size: 28px;
  margin: 12px 0 8px;
  color: var(--paper);
  line-height: 1.1;
}

.modal p {
  font-size: 14px;
  color: #c9c1d7;
  line-height: 1.55;
}

.modal #modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.modal #modal-actions button {
  min-height: 46px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 10px;
}

.modal dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
  margin: 14px 0;
}

.modal dd {
  margin: 0;
  color: var(--cyan);
  text-align: right;
  font-weight: bold;
}

.modal dt {
  color: #ddd3e6;
}

.sr-only {
  position: absolute;
  clip: rect(0,0,0,0);
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ==========================================================
   TOUCH CONTROLS - BASE STYLING
   ========================================================== */

#touch-controls {
  pointer-events: none;
  z-index: 25;
}

.touch-left, .touch-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

#touch-controls button {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-family: inherit;
  font-weight: 900;
  letter-spacing: .03em;
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.45);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

/* ==========================================================
   MOBILE PORTRAIT: HANDHELD CONSOLE MODE
   ========================================================== */

@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  #game-container {
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    background: #0d0b1a;
  }

  #screen-viewport {
    width: 100vw;
    width: 100dvw;
    max-width: 100vw;
    aspect-ratio: 16 / 9;
    height: auto;
    flex-shrink: 0;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7);
    border-bottom: 2px solid #2e2646;
  }

  #top-tools {
    top: 6px;
    right: 8px;
  }

  #top-tools button {
    padding: 5px 9px;
    min-height: 32px;
    font-size: 11px;
  }

  /* Dialogue in portrait */
  .dialogue {
    bottom: 6px;
    left: 6px;
    right: 6px;
    border-radius: 12px;
  }

  .dialogue-content {
    grid-template-columns: 60px 1fr;
    gap: 12px;
    padding: 10px 12px;
    min-height: 90px;
  }

  #portrait {
    width: 60px;
    height: 66px;
  }

  #speaker {
    font-size: 14px;
    margin-bottom: 4px;
  }

  #dialogue-text {
    font-size: 13.5px;
    line-height: 1.45;
    min-height: 36px;
    margin: 2px 0 6px;
  }

  #next-dialogue {
    grid-column: 2;
    justify-self: flex-end;
    min-height: 32px;
    padding: 6px 14px;
    font-size: 11.5px;
  }

  /* Dedicated Arcade Gamepad Deck */
  #touch-controls {
    position: relative;
    flex: 1;
    width: 100%;
    width: 100dvw;
    min-height: 220px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px 24px;
    background: radial-gradient(circle at 50% 25%, #221c3b 0%, #110e20 85%);
    border-top: 1px solid #ffffff18;
    box-shadow: inset 0 8px 20px rgba(0, 0, 0, 0.6);
  }

  .touch-left {
    gap: 14px;
  }

  .touch-right {
    gap: 12px;
  }

  /* Movement D-Pad buttons */
  .btn-dpad {
    width: 74px;
    height: 74px;
    font-size: 26px;
    background: linear-gradient(145deg, #2b2347, #19142b);
    border: 2px solid #8e7bb0bb;
    color: var(--paper);
    border-radius: 18px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.15);
  }

  .btn-dpad.down, .btn-dpad:active {
    background: linear-gradient(145deg, #3d3161, #271f45);
    border-color: var(--cyan);
    box-shadow: 0 0 18px var(--cyan), inset 0 2px 4px rgba(0, 0, 0, 0.4);
    transform: scale(0.93) translateY(2px);
  }

  /* Action Buttons */
  .btn-fire {
    width: 78px;
    height: 78px;
    font-size: 15px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(145deg, #a63666, #6b1d3f);
    border: 3px solid var(--pink);
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(255, 141, 187, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  }

  .btn-fire.down, .btn-fire:active {
    background: linear-gradient(145deg, #c44079, #86254f);
    border-color: #fff;
    box-shadow: 0 0 25px var(--pink), inset 0 3px 6px rgba(0, 0, 0, 0.5);
    transform: scale(0.92) translateY(3px);
  }

  .btn-jump {
    width: 70px;
    height: 70px;
    font-size: 14px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(145deg, #216979, #13424d);
    border: 3px solid var(--cyan);
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(121, 248, 238, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  }

  .btn-jump.down, .btn-jump:active {
    background: linear-gradient(145deg, #2a889c, #1a5664);
    border-color: #fff;
    box-shadow: 0 0 25px var(--cyan), inset 0 3px 6px rgba(0, 0, 0, 0.5);
    transform: scale(0.92) translateY(3px);
  }

  .btn-bomb {
    width: 58px;
    height: 58px;
    font-size: 12px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(145deg, #8a4e27, #532c12);
    border: 2px solid var(--amber);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(255, 168, 88, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.2);
  }

  .btn-bomb.down, .btn-bomb:active {
    background: linear-gradient(145deg, #a65e2f, #693817);
    border-color: #fff;
    box-shadow: 0 0 20px var(--amber), inset 0 3px 5px rgba(0, 0, 0, 0.5);
    transform: scale(0.92) translateY(2px);
  }
}

/* ==========================================================
   MOBILE LANDSCAPE: FULL-SCREEN OVERLAY MODE
   ========================================================== */

@media (orientation: landscape) and (max-height: 800px), (orientation: landscape) and (pointer: coarse) {
  #game-container {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  #screen-viewport {
    width: min(100vw, 177.7778vh);
    width: min(100dvw, 177.7778dvh);
    height: min(100vh, 56.25vw);
    height: min(100dvh, 56.25dvw);
    max-width: 100vw;
    max-height: 100vh;
    box-shadow: none;
  }

  #top-tools {
    top: max(8px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  #top-tools button {
    padding: 5px 9px;
    min-height: 32px;
    font-size: 11px;
    background: rgba(21, 19, 41, 0.85);
  }

  /* Overlay touch controls on phone edges */
  #touch-controls {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 25;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .touch-left {
    pointer-events: auto;
    gap: 12px;
  }

  .touch-right {
    pointer-events: auto;
    gap: 12px;
    align-items: flex-end;
  }

  .btn-dpad {
    width: 68px;
    height: 64px;
    font-size: 24px;
    background: rgba(27, 22, 45, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 2px solid #8e7bb0aa;
    color: var(--paper);
    border-radius: 14px;
  }

  .btn-dpad.down, .btn-dpad:active {
    background: rgba(55, 43, 85, 0.9);
    border-color: var(--cyan);
    box-shadow: 0 0 20px var(--cyan);
    transform: scale(0.92);
  }

  .btn-fire {
    width: 74px;
    height: 74px;
    font-size: 14px;
    font-weight: 900;
    color: #fff;
    background: rgba(150, 42, 85, 0.82);
    backdrop-filter: blur(8px);
    border: 3px solid var(--pink);
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(255, 141, 187, 0.4);
  }

  .btn-fire.down, .btn-fire:active {
    background: rgba(195, 55, 110, 0.95);
    border-color: #fff;
    box-shadow: 0 0 25px var(--pink);
    transform: scale(0.92);
  }

  .btn-jump {
    width: 66px;
    height: 66px;
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    background: rgba(25, 85, 96, 0.82);
    backdrop-filter: blur(8px);
    border: 3px solid var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(121, 248, 238, 0.35);
  }

  .btn-jump.down, .btn-jump:active {
    background: rgba(35, 115, 130, 0.95);
    border-color: #fff;
    box-shadow: 0 0 25px var(--cyan);
    transform: scale(0.92);
  }

  .btn-bomb {
    width: 56px;
    height: 56px;
    font-size: 11px;
    font-weight: 900;
    color: #fff;
    background: rgba(115, 58, 26, 0.82);
    backdrop-filter: blur(8px);
    border: 2px solid var(--amber);
    border-radius: 50%;
    box-shadow: 0 0 14px rgba(255, 168, 88, 0.35);
  }

  .btn-bomb.down, .btn-bomb:active {
    background: rgba(150, 75, 34, 0.95);
    border-color: #fff;
    box-shadow: 0 0 20px var(--amber);
    transform: scale(0.92);
  }

  .dialogue {
    bottom: 8px;
    left: 10px;
    right: 10px;
    border-radius: 12px;
  }

  .dialogue-content {
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    padding: 8px 14px;
    min-height: 85px;
  }

  #portrait {
    width: 60px;
    height: 66px;
  }

  #speaker {
    font-size: 14px;
    margin-bottom: 2px;
  }

  #dialogue-text {
    font-size: 13.5px;
    line-height: 1.4;
    margin: 2px 0 4px;
    min-height: 32px;
  }

  #next-dialogue {
    padding: 7px 14px;
    font-size: 12px;
  }
}

/* ==========================================================
   CINEMATIC GAMELOFT-STYLE SPLASH SCREEN
   ========================================================== */

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at center, #17132e 0%, #080612 65%, #000000 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s ease;
  user-select: none;
  cursor: pointer;
}

#splash-screen.splash-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.05);
}

.splash-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: splashZoomIn 2.6s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.splash-logo-wrap {
  position: relative;
  width: 190px;
  height: 190px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(121, 248, 238, 0.3), 0 0 90px rgba(255, 141, 187, 0.22);
  background: #000;
}

.splash-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Gameloft-style specular sheen/flare sweep across logo */
.splash-flare {
  position: absolute;
  top: -50%;
  left: -120%;
  width: 75%;
  height: 200%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 35%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(121, 248, 238, 0.6) 55%,
    transparent 70%
  );
  transform: rotate(22deg);
  animation: splashSweep 1.6s cubic-bezier(0.4, 0, 0.2, 1) 0.5s forwards;
  pointer-events: none;
}

.splash-glow {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(121, 248, 238, 0.26) 0%, rgba(255, 141, 187, 0.16) 45%, transparent 70%);
  filter: blur(28px);
  pointer-events: none;
  z-index: -1;
  animation: splashPulse 2.6s ease-in-out infinite alternate;
}

.splash-tagline {
  margin-top: 24px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: #fff4ed;
  text-shadow: 0 0 16px rgba(121, 248, 238, 0.6), 0 0 32px rgba(255, 141, 187, 0.4);
  text-transform: uppercase;
}

.splash-sub {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.45em;
  color: var(--pink);
  text-shadow: 0 0 12px var(--pink);
  opacity: 0.9;
}

.splash-skip-btn {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  right: max(22px, env(safe-area-inset-right));
  padding: 8px 18px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(21, 19, 41, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 20px;
  color: #d8c4e4;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  z-index: 10;
}

.splash-skip-btn:hover {
  background: rgba(255, 141, 187, 0.28);
  border-color: var(--pink);
  color: #fff;
}

@keyframes splashZoomIn {
  0% {
    transform: scale(0.82);
    opacity: 0;
    filter: brightness(0.6) blur(6px);
  }
  30% {
    opacity: 1;
    filter: brightness(1.2) blur(0px);
  }
  100% {
    transform: scale(1.02);
    opacity: 1;
    filter: brightness(1) blur(0px);
  }
}

@keyframes splashSweep {
  0% {
    left: -120%;
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    left: 200%;
    opacity: 0;
  }
}

@keyframes splashPulse {
  0% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

/* ==========================================================
   ROTATE PHONE OVERLAY (Mobile Portrait Only)
   ========================================================== */

#rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(8, 7, 16, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: auto;
}

/* Strictly enforce landscape on all mobile / handheld devices */
@media (orientation: portrait) and (max-width: 1024px),
       (orientation: portrait) and (pointer: coarse),
       (max-aspect-ratio: 1/1) and (pointer: coarse),
       (max-aspect-ratio: 1/1) and (max-width: 900px) {
  #rotate-overlay {
    display: flex !important;
  }

  body.is-portrait-blocked #game-container,
  #game-container {
    pointer-events: none !important;
  }

  #touch-controls {
    display: none !important;
  }
}

/* Hide rotate prompt in landscape orientation */
@media (orientation: landscape) and (min-aspect-ratio: 1.1/1) {
  #rotate-overlay {
    display: none !important;
  }
}

.rotate-card {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.rotate-phone-anim {
  position: relative;
  width: 90px;
  height: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
}

.phone-device {
  width: 44px;
  height: 76px;
  border: 3px solid var(--pink);
  border-radius: 9px;
  background: #19162f;
  box-shadow: 0 0 25px rgba(255, 141, 187, 0.45);
  position: relative;
  animation: phoneRotate 2.6s cubic-bezier(0.45, 0, 0.2, 1) infinite;
  transform-origin: center center;
}

.phone-screen {
  position: absolute;
  top: 8px;
  left: 4px;
  right: 4px;
  bottom: 12px;
  background: linear-gradient(135deg, rgba(121, 248, 238, 0.22), rgba(255, 141, 187, 0.22));
  border-radius: 4px;
}

.phone-button {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink);
}

.rotate-arrow {
  position: absolute;
  font-size: 38px;
  color: var(--cyan);
  text-shadow: 0 0 15px var(--cyan);
  opacity: 0.85;
  animation: arrowPulse 2.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes phoneRotate {
  0%, 20% {
    transform: rotate(0deg);
  }
  50%, 80% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes arrowPulse {
  0%, 100% {
    transform: scale(0.9);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.rotate-card h2 {
  font-size: 21px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.08em;
  margin: 0;
  text-shadow: 0 0 14px rgba(255, 141, 187, 0.5);
}

.rotate-sub {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(121, 248, 238, 0.4);
}

.rotate-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: #d4c2e2;
  margin: 0;
}

.btn-rotate-fullscreen {
  margin-top: 10px;
  padding: 12px 22px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #2b1f48, #181430);
  border: 2px solid var(--cyan);
  border-radius: 10px;
  color: #fff;
  box-shadow: 0 0 18px rgba(121, 248, 238, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-rotate-fullscreen:active,
.btn-rotate-fullscreen:hover {
  background: linear-gradient(135deg, #3d2c64, #261f4d);
  border-color: var(--pink);
  box-shadow: 0 0 25px rgba(255, 141, 187, 0.5);
  transform: scale(0.98);
}

.rotate-hint {
  font-size: 11.5px;
  color: #9f8eb2;
  margin-top: 4px;
}

