:root {
  --bg: #1a1c1e;
  --panel: #2a2e32;
  --ink: #e8eaed;
  --muted: #9aa0a6;
  --red: #c62828;
  --olive: #5a6b3a;
  --warn: #e53935;
  /* Stick lift above home indicator; keep modest so canvas can grow */
  --controls-lift: 52px;
  --controls-h: 120px;
  --controls-reserved: calc(var(--controls-h) + var(--controls-lift) + env(safe-area-inset-bottom, 0px));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: #050608;
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}
/* Full-bleed stage: canvas fills viewport above overlaid controls */
#play-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: block;
  background: #050608;
  z-index: 1;
  touch-action: none;
  overflow: hidden;
  padding: env(safe-area-inset-top, 0px) 0 0 0;
}
#game-wrap {
  position: absolute;
  left: 0; right: 0;
  top: env(safe-area-inset-top, 0px);
  bottom: var(--controls-reserved);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050608;
  touch-action: none;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  display: block;
  touch-action: none;
  /* JS resize() sets exact px; do not fight with width:100%/height:auto */
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  box-shadow: none;
}
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 8px 10px; pointer-events: none; z-index: 5;
}
.hud-chip {
  background: rgba(20,22,24,.85);
  border: 2px solid #444;
  padding: 6px 10px;
  font-size: 12px;
  max-width: 62%;
  line-height: 1.35;
}
.hud-chip.dim { opacity: .85; max-width: 48%; text-align: right; }
#interact-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); border: 2px solid #c62828;
  padding: 6px 12px; font-size: 13px; z-index: 6;
  pointer-events: none;
}
#interact-hint.hidden { display: none; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.72);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  touch-action: auto;
}
.overlay.active { display: flex; }
.overlay.lock-overlay {
  z-index: 100;
  background: #000;
  pointer-events: all;
  opacity: 0;
}
.overlay.lock-overlay.active.end-reveal {
  animation: endOverlayIn 2.6s ease-out forwards;
}
.overlay.lock-overlay .end-panel {
  background: transparent;
  border-color: #333;
  box-shadow: none;
}
.overlay.lock-overlay .end-title {
  opacity: 0;
  color: #111;
  text-shadow: none;
  animation: endTitleReveal 5.2s ease-out 0.8s forwards;
}
.overlay.lock-overlay .end-fade-eye {
  opacity: 0;
  animation: endFadeIn 2.8s ease-out 1.6s forwards;
}
.overlay.lock-overlay .end-fade-lead {
  opacity: 0;
  animation: endFadeIn 3.2s ease-out 3.2s forwards;
}
.overlay.lock-overlay .end-fade-credit {
  opacity: 0;
  animation: endFadeIn 2.8s ease-out 4.2s forwards;
}
.overlay.lock-overlay .end-fade-btn {
  opacity: 0;
  animation: endFadeIn 2.4s ease-out 5s forwards;
}
@keyframes endOverlayIn {
  0% { opacity: 0; background: #000; }
  40% { opacity: 1; background: #000; }
  100% { opacity: 1; background: rgba(0,0,0,.94); }
}
@keyframes endTitleReveal {
  0% { opacity: 0; color: #0a0a0a; letter-spacing: .2em; }
  35% { opacity: .35; color: #3a1515; }
  70% { opacity: .75; color: #a04040; }
  100% { opacity: 1; color: #e57373; letter-spacing: .12em; }
}
@keyframes endFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.end-modal-title {
  opacity: 0;
  color: #1a0a0a;
  animation: endTitleReveal 4.8s ease-out 0.2s forwards;
}

/* Title → black → apartment scene fade */
#scene-fade {
  position: fixed; inset: 0; z-index: 90;
  background: #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease-in-out;
  display: none;
}
#scene-fade.on { display: block; }
#scene-fade.in { opacity: 1; pointer-events: all; transition: opacity 1s ease-in; }
#scene-fade.out { opacity: 0; transition: opacity 1.4s ease-out; }

/* Dialogue dock: overlays bottom of game area, above stick — does not shrink canvas */
#ui-dock {
  position: absolute;
  left: 0; right: 0;
  bottom: var(--controls-reserved);
  width: 100%;
  max-height: 0;
  overflow: hidden;
  background: #121418;
  border-top: 0 solid #c62828;
  z-index: 8;
  transition: max-height .12s ease;
  pointer-events: none;
}
body.dock-open #ui-dock {
  max-height: min(36vh, 260px);
  overflow-y: auto;
  border-top-width: 3px;
  border-top-color: #c62828;
  box-shadow: inset 0 1px 0 #2a1010;
  pointer-events: auto;
}
#ui-dock .ui-dock-panel {
  display: none;
  width: 100%;
  pointer-events: auto;
  touch-action: auto;
}
#ui-dock .ui-dock-panel.active {
  display: block;
}
#dialogue .dialogue-box {
  width: 100%;
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: .65rem .9rem .7rem;
  max-height: none;
}
#modal .modal-panel {
  width: 100%;
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: .75rem .9rem .85rem;
  max-height: none;
}
#dialogue-text { min-height: 2.2em; }
#dialogue .choices { margin: .45rem 0 .3rem; }
#dialogue .choices button { font-size: .88rem; padding: 9px 11px; }

#controls-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--controls-lift) + env(safe-area-inset-bottom, 0px));
  height: var(--controls-h);
  min-height: 110px;
  z-index: 12;
  background: linear-gradient(180deg, transparent 0%, #0a0c10 28%);
  border-top: 1px solid #2a3036;
  touch-action: none;
}
.panel {
  background: var(--panel);
  border: 3px solid #555;
  max-width: 420px; width: 100%;
  padding: 1.25rem 1.35rem 1.5rem;
  box-shadow: 0 0 0 2px #111, 8px 8px 0 #000;
}
/* lock-end / generic boot panel (not the title screen) */
.boot-panel { text-align: center; }
.boot-panel h1, .boot-panel .end-title {
  margin: .5rem 0 .75rem;
  font-size: 1.6rem;
  letter-spacing: .08em;
  color: #fff;
}
.lead { font-size: .95rem; line-height: 1.7; color: var(--ink); margin: 0 0 .75rem; text-align: left; }
.credit { font-size: .78rem; color: var(--muted); line-height: 1.55; margin: 0 0 1rem; text-align: left; }
.field {
  display: block; text-align: left; font-size: .85rem; color: var(--muted); margin-bottom: 1rem;
}
.field input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; font-size: 1rem;
  background: #111; border: 2px solid #555; color: #fff;
  font-family: inherit;
  touch-action: auto;
}
.hint { font-size: .75rem; color: var(--muted); margin: 1rem 0 0; line-height: 1.5; }
.pixel-eye {
  width: 48px; height: 48px; margin: 0 auto;
  background:
    radial-gradient(circle at 50% 50%, #c62828 0 18%, #111 19% 42%, #ddd 43% 58%, #333 59% 100%);
  border: 3px solid #666;
  image-rendering: pixelated;
}

/* ========== GAME TITLE SCREEN (true full-viewport) ========== */
#boot.title-boot {
  z-index: 30;
  padding: 0 !important;
  margin: 0;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  background: #000;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}
#boot.title-boot .title-screen {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  text-align: center;
  overflow: hidden;
  image-rendering: pixelated;
  background: #000;
  border: none;
  box-shadow: none;
  border-radius: 0;
}
.title-crt {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 95% 70% at 50% 32%, #4a0808 0%, #180404 38%, #050202 72%, #000 100%),
    repeating-linear-gradient(0deg, #050505 0 2px, #020202 2px 4px);
}
.title-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 22%, rgba(220,30,30,.55) 0%, rgba(180,20,20,.28) 28%, transparent 52%),
    radial-gradient(circle at 50% 48%, rgba(120,0,0,.35) 0%, transparent 45%),
    radial-gradient(circle at 50% 78%, rgba(60,0,0,.35) 0%, transparent 55%);
  animation: title-pulse 2.6s ease-in-out infinite;
}
.title-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 1px,
    rgba(0,0,0,.38) 1px,
    rgba(0,0,0,.38) 2px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0) 3px,
    rgba(0,0,0,.22) 3px,
    rgba(0,0,0,.22) 4px
  );
  mix-blend-mode: multiply;
  opacity: .92;
}
.title-vignette {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 60px 40px #000, inset 0 0 140px 80px rgba(0,0,0,.88), inset 0 0 220px 40px rgba(40,0,0,.35);
  border: none;
}
.title-static {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: .58;
  mix-blend-mode: screen;
  pointer-events: none;
}
.title-noise {
  position: absolute; inset: -12%;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 96px 96px;
}
.title-noise-a {
  opacity: .38;
  mix-blend-mode: soft-light;
  animation: title-static-shift 0.14s steps(3) infinite, title-flicker 0.08s steps(2) infinite;
}
.title-noise-b {
  opacity: .32;
  mix-blend-mode: overlay;
  background-size: 48px 48px;
  animation: title-static-shift-rev 0.11s steps(4) infinite, title-flicker 0.06s steps(2) infinite;
  filter: contrast(1.9) brightness(1.35);
}
@keyframes title-pulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; }
}
@keyframes title-flicker {
  0% { opacity: .22; }
  50% { opacity: .48; }
  100% { opacity: .28; }
}
@keyframes title-static-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -4%); }
  75% { transform: translate(-1%, 3%); }
  100% { transform: translate(3%, -2%); }
}
@keyframes title-static-shift-rev {
  0% { transform: translate(2%, -2%) scale(1.05); }
  33% { transform: translate(-4%, 1%) scale(1.08); }
  66% { transform: translate(1%, 4%) scale(1.02); }
  100% { transform: translate(-2%, -3%) scale(1.06); }
}
@keyframes title-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes title-start-glow {
  0%, 100% { box-shadow: 4px 4px 0 #000, 0 0 0 2px #5a1010, 0 0 18px rgba(198,40,40,.35); }
  50% { box-shadow: 4px 4px 0 #000, 0 0 0 2px #8a2020, 0 0 28px rgba(255,80,60,.55); }
}
@keyframes title-eye-glow {
  0%, 100% { box-shadow: 0 0 0 4px #0a0404, 0 0 36px rgba(255,40,40,.55), 0 0 72px rgba(198,20,20,.35), inset 0 0 28px #000; }
  50% { box-shadow: 0 0 0 4px #0a0404, 0 0 52px rgba(255,50,50,.85), 0 0 100px rgba(220,20,20,.55), inset 0 0 28px #000; }
}
@keyframes title-lid-blink {
  0%, 88%, 100% { height: 0; }
  90%, 94% { height: 84%; }
  92% { height: 92%; }
}
@keyframes title-bb-oppress {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.03); filter: brightness(1.15); }
}

.title-poster, .title-mark, .title-slogans, .title-field, .title-start, .title-hint, .title-credit {
  position: relative; z-index: 2;
}

.title-poster {
  margin-bottom: .2rem;
  margin-top: -.4rem;
}
.title-eye-ring {
  width: clamp(108px, 28vw, 148px);
  height: clamp(108px, 28vw, 148px);
  margin: 0 auto;
  border: 5px solid #8a1818;
  box-shadow:
    0 0 0 4px #0a0404,
    0 0 36px rgba(255,40,40,.65),
    0 0 72px rgba(198,20,20,.45),
    0 0 120px rgba(120,0,0,.35),
    inset 0 0 28px #000;
  background: radial-gradient(circle at 50% 40%, #2a0808 0%, #0a0202 70%);
  display: flex; align-items: center; justify-content: center;
  image-rendering: pixelated;
  position: relative;
  animation: title-eye-glow 2.8s ease-in-out infinite;
}
.title-lid {
  position: absolute; left: 8%; right: 8%; top: 8%;
  height: 0;
  background: #0a0404;
  z-index: 3;
  pointer-events: none;
  animation: title-lid-blink 5.2s steps(1) infinite;
  box-shadow: 0 2px 0 #1a0808;
}
.title-eye {
  width: clamp(72px, 18vw, 100px);
  height: clamp(72px, 18vw, 100px);
  background:
    radial-gradient(circle at 50% 50%, #fff 0 8%, #e8eaed 9% 14%, #c62828 15% 28%, #1a0a0a 29% 52%, #d0d0d0 53% 68%, #1a1a1a 69% 100%);
  border: 4px solid #9a9a9a;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 3px #111, 0 0 20px rgba(255,60,60,.4);
}
.title-pupil {
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  background: #ff1a1a;
  box-shadow: 0 0 12px #ff3333, 0 0 24px #c62828, inset 0 0 4px #400000;
  border-radius: 1px;
  will-change: transform;
  transition: transform .08s linear;
}
.title-glint {
  position: absolute; left: 26%; top: 26%;
  width: 8px; height: 8px; background: #fff; opacity: .85;
  z-index: 2;
  pointer-events: none;
}
.title-bb-bar {
  margin-top: 12px;
  display: inline-block;
  padding: 6px 16px;
  font-size: clamp(12px, 3.2vw, 15px);
  font-weight: 900;
  letter-spacing: .42em;
  color: #ffd0d0;
  background: #1a0404;
  border: 3px solid #8a1010;
  text-indent: .42em;
  text-shadow: 0 0 10px rgba(255,40,40,.85), 0 0 24px rgba(198,40,40,.55), 2px 2px 0 #000;
  box-shadow: 0 0 20px rgba(198,40,40,.4), inset 0 0 12px #000;
  animation: title-bb-oppress 3.4s ease-in-out infinite;
}

.title-mark { margin: .55rem 0 .65rem; }
/* Brutal / angular 1984 — condensed blackletter-ish geometric, hard edges */
.title-1984 {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: .04em;
  font-family: Impact, Haettenschweiler, "Arial Narrow", "Franklin Gothic Heavy", "Arial Black", "Helvetica Neue Condensed Bold", sans-serif;
  font-weight: 900;
  font-size: clamp(4.8rem, 26vw, 8.6rem);
  line-height: .82;
  letter-spacing: -0.07em;
  color: #f5f5f5;
  transform: skewX(-9deg);
  filter: contrast(1.35) saturate(1.1);
  text-rendering: geometricPrecision;
}
.title-1984 span {
  display: inline-block;
  position: relative;
  padding: 0 .01em .08em;
  color: #f2f2f2;
  -webkit-text-fill-color: #f2f2f2;
  font-stretch: condensed;
  background: none;
  /* hard cut edges */
  clip-path: polygon(10% 0%, 100% 0%, 90% 100%, 0% 100%);
  -webkit-text-stroke: 0.5px #4a0000;
  text-shadow:
    5px 0 0 #6a0000,
    -3px 0 0 #1a0000,
    0 6px 0 #000,
    0 0 6px rgba(255,40,40,.9),
    0 0 22px rgba(220,20,20,.75),
    0 0 48px rgba(160,0,0,.55),
    0 0 90px rgba(120,0,0,.4);
  border-bottom: 5px solid #8a0000;
  transform: scaleY(1.12);
}
.title-1984 span:nth-child(2) { transform: scaleY(1.12) translateY(2px); }
.title-1984 span:nth-child(3) { transform: scaleY(1.14) translateY(-1px); }
.title-1984 span:nth-child(4) { transform: scaleY(1.12) translateY(1px); }
/* kept for safety if markup ever reappears — hidden */
.title-sub { display: none !important; }
.title-tag {
  margin-top: .35rem;
  font-family: "Courier New", monospace;
  font-size: 10px;
  letter-spacing: .35em;
  color: #7a8088;
}

.title-slogans {
  list-style: none;
  margin: .65rem auto .95rem;
  padding: 10px 14px;
  max-width: 22rem;
  border: 2px solid #5a2020;
  background: rgba(10, 4, 4, .72);
  box-shadow: inset 0 0 0 1px #2a1010, 0 0 20px rgba(198,40,40,.2);
}
.title-slogans li {
  margin: 0;
  padding: .28rem 0;
  font-size: clamp(.95rem, 3.6vw, 1.15rem);
  font-weight: 800;
  letter-spacing: .28em;
  text-indent: .28em;
  color: #e8d0d0;
  text-shadow: 0 0 10px rgba(198,40,40,.45), 1px 1px 0 #000;
  border-bottom: 1px solid rgba(120,40,40,.35);
}
.title-slogans li:last-child { border-bottom: none; }

.title-field {
  display: none !important;
  width: min(280px, 86vw);
  margin: 0 auto .95rem;
  font-size: .72rem;
  letter-spacing: .12em;
  color: #8a9098;
  text-align: left;
}
.title-field input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: "Courier New", monospace;
  background: #0a0a0a;
  border: 3px solid #4a2020;
  color: #e8eaed;
  box-shadow: inset 0 0 0 1px #1a0808, 0 0 12px rgba(198,40,40,.15);
  touch-action: auto;
  caret-color: #c62828;
}
.title-field input::placeholder { color: #444; }
.title-field input:focus {
  outline: none;
  border-color: #c62828;
  box-shadow: inset 0 0 0 1px #2a1010, 0 0 18px rgba(198,40,40,.35);
}

/* Mute on title (same storage as in-game) */
.title-music-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 5;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 6px 10px;
  color: #ffc8c8;
  background: rgba(90, 18, 18, .85);
  border: 2px solid #e8e8e8;
  box-shadow: 2px 2px 0 #000, 0 0 12px rgba(198,40,40,.35);
  image-rendering: pixelated;
}
.title-music-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}
.title-music-btn[aria-pressed="true"] {
  color: #9aa0a6;
  background: rgba(40, 40, 44, .9);
  border-color: #666;
  box-shadow: 2px 2px 0 #000;
}

.title-start {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: min(260px, 82vw);
  padding: 14px 22px 12px;
  background: #5a1212;
  color: #fff;
  border: 4px solid #e8e8e8;
  box-shadow: 4px 4px 0 #000, 0 0 0 2px #5a1010, 0 0 18px rgba(198,40,40,.35);
  animation: title-start-glow 1.6s ease-in-out infinite;
  image-rendering: pixelated;
}
.title-start:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #000, 0 0 0 2px #5a1010;
}
.title-start-bracket {
  display: none;
}
.title-start-label {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: .28em;
  text-indent: .28em;
  text-transform: none;
}
.title-start-blink {
  font-family: "Courier New", monospace;
  font-size: 11px;
  letter-spacing: .4em;
  text-indent: .4em;
  color: #ffc8c8;
  animation: title-blink 1.05s steps(1) infinite;
}

.title-hint {
  margin: 1.1rem 0 0;
  font-size: .7rem;
  line-height: 1.55;
  color: #6a7078;
}
.title-credit {
  margin: .55rem 0 0;
  font-size: .65rem;
  color: #505458;
  letter-spacing: .06em;
}

@media (max-height: 640px) {
  .title-1984 { font-size: clamp(3.2rem, 18vw, 5rem); }
  .title-eye-ring { width: 56px; height: 56px; }
  .title-eye { width: 36px; height: 36px; }
  .title-slogans { margin-bottom: .55rem; padding: 6px 10px; }
  .title-slogans li { font-size: .88rem; padding: .18rem 0; }
  .title-start { padding: 10px 16px 8px; }
}

.btn {
  appearance: none; border: 3px solid #888;
  background: #3a3f45; color: #fff;
  font-size: 1rem; font-weight: 700;
  padding: 10px 18px; cursor: pointer;
  font-family: inherit;
  box-shadow: 3px 3px 0 #000;
}
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 #000; }
.btn.small { font-size: .9rem; padding: 8px 14px; }
.btn.warn { border-color: var(--warn); background: #5a1a1a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.dead {
  border-color: #333; background: #1a1a1a; color: #555;
  box-shadow: none; cursor: default;
}
.dialogue-box {
  background: #1e2226;
  border: 3px solid #c62828;
  max-width: 480px; width: 100%;
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 6px 6px 0 #000;
}
.speaker { font-size: .75rem; color: #e57373; margin-bottom: .35rem; font-weight: 700; }
#dialogue-text { font-size: .95rem; line-height: 1.65; min-height: 2.6em; white-space: pre-wrap; }
.choices { display: flex; flex-direction: column; gap: 8px; margin: .75rem 0; }
.choices button {
  text-align: left; background: #2a3036; border: 2px solid #666;
  color: #fff; padding: 10px 12px; font-family: inherit; font-size: .9rem; cursor: pointer;
}
.choices button:hover { border-color: #c62828; }

.modal-panel { max-width: 460px; }
.modal-panel h2 { margin: 0 0 .75rem; font-size: 1.15rem; }
.modal-panel p { margin: 0 0 .75rem; line-height: 1.65; font-size: .92rem; }
.modal-panel textarea, .modal-panel input[type="text"] {
  width: 100%; background: #111; border: 2px solid #555; color: #fff;
  padding: 10px; font-family: inherit; font-size: .95rem; margin-bottom: .75rem;
  touch-action: auto;
}
.modal-panel textarea { min-height: 72px; resize: vertical; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: .5rem 0 1rem; }
.chip {
  background: #111; border: 2px solid #666; padding: 4px 8px; font-size: .8rem;
}
.chip.gone { text-decoration: line-through; opacity: .4; border-color: #333; }
.hate-timer {
  font-size: 2.4rem; font-weight: 800; text-align: center;
  color: var(--warn); margin: .5rem 0; font-variant-numeric: tabular-nums;
}
.hate-enemy {
  height: 80px; margin: .5rem auto 1rem;
  background: linear-gradient(180deg, #333, #111);
  border: 3px solid #555; position: relative; overflow: hidden;
}
.hate-enemy::after {
  content: ""; position: absolute; inset: 12px 30% 8px;
  background: #222; box-shadow: inset 0 0 0 3px #c62828;
  clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
}
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .5rem; }
.end-title {
  font-size: 1.4rem; font-weight: 800; text-align: center;
  color: #e57373; letter-spacing: .12em; margin: 1rem 0;
}
.end-dead { text-align: center; color: #666; font-size: .95rem; margin-top: 1.5rem; }

#toast {
  position: fixed; bottom: calc(var(--controls-reserved) + 12px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: #111; border: 2px solid #888; padding: 8px 14px;
  font-size: 13px; opacity: 0; transition: .2s; z-index: 40; pointer-events: none;
  max-width: 90%;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.touch {
  display: block;
  position: absolute; inset: 0; pointer-events: none; z-index: 10;
  transition: opacity .4s;
}
.touch.on { display: block; }
.touch.locked {
  opacity: .25;
  filter: grayscale(1);
  pointer-events: none !important;
}
.touch.locked * { pointer-events: none !important; }
.stick {
  position: absolute; left: 12px; bottom: 8px;
  width: 112px; height: 112px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.22);
  pointer-events: auto;
  touch-action: none;
}
.knob {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(200,50,50,.55);
  border: 2px solid rgba(255,255,255,.4);
  will-change: transform;
  touch-action: none;
}

.touch-btn {
  position: absolute; right: 14px; bottom: 16px;
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(198,40,40,.55);
  border: 3px solid rgba(255,255,255,.35); color: #fff;
  font-weight: 800; font-size: 14px;
  pointer-events: auto; font-family: inherit;
  touch-action: none;
  opacity: .85;
}
.touch-btn:active { background: rgba(198,40,40,.85); }

@media (max-width: 520px) {
  :root { --controls-h: 112px; --controls-lift: 44px; }
  #controls-bar { min-height: 100px; }
  .stick { width: 100px; height: 100px; left: 8px; }
  .touch-btn { width: 64px; height: 64px; right: 10px; font-size: 12px; }
  body.dock-open #ui-dock { max-height: min(38vh, 220px); }
  #dialogue-text { font-size: .88rem; }
}
@media (max-height: 480px) {
  :root { --controls-h: 96px; --controls-lift: 8px; }
  .stick { width: 88px; height: 88px; bottom: 4px; }
  .touch-btn { width: 56px; height: 56px; bottom: 10px; font-size: 11px; }
}

#hud .music-btn {
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  margin: 0;
  max-width: none;
  flex-shrink: 0;
  letter-spacing: .04em;
}
#hud .music-btn:active { background: rgba(198,40,40,.55); }
#hud .music-btn[aria-pressed="true"] {
  border-color: #666;
  color: var(--muted);
}

/* Landscape: shorter control strip so game canvas can grow */
@media (orientation: landscape) {
  :root {
    --controls-lift: 12px;
    --controls-h: 88px;
  }
  #controls-bar { min-height: 88px; }
  .stick { width: 96px; height: 96px; bottom: 4px; }
  .knob { width: 42px; height: 42px; }
  .touch-btn { width: 72px; height: 72px; font-size: 13px; bottom: 10px; }
}
/* VW_LAND landscape-controls */

/* Language picker — title */
.title-lang {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 8px;
  z-index: 5;
  margin: 2px 0 4px;
}
.lang-btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 6px 12px;
  color: #9aa0a6;
  background: rgba(40, 40, 44, .88);
  border: 2px solid #666;
  box-shadow: 2px 2px 0 #000;
  image-rendering: pixelated;
}
.lang-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}
.lang-btn.active,
.lang-btn[aria-pressed="true"] {
  color: #ffc8c8;
  background: rgba(90, 18, 18, .9);
  border-color: #e8e8e8;
  box-shadow: 2px 2px 0 #000, 0 0 10px rgba(198,40,40,.35);
}

/* Language chip — in-game HUD */
#hud .lang-chip {
  pointer-events: auto;
  cursor: pointer;
  appearance: none;
  font-family: inherit;
  color: #ffc8c8;
  background: rgba(90, 18, 18, .75);
  border: 2px solid #c62828;
}
#hud .lang-chip:active {
  background: rgba(198,40,40,.55);
}
