/* ============================================================
   給愛麗絲 — style.css  v4  (1280×720, mobile landscape)
   ============================================================ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
  --bg:        #07070e;
  --surface:   #0d0d1a;
  --border:    #252538;
  --border-hi: #3d3d5c;
  --text:      #ddd6f8;
  --text-dim:  #9990bb;
  --accent:    #9b7fff;
  --red:       #ff3366;
  --green:     #44ffaa;
  --yellow:    #ffdd44;
  --orange:    #ff9944;
}

html, body {
  background: #000;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  touch-action: none;
}

/* ── GAME WRAPPER (handles scaling) ───────────────────────── */
#game-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

/* ── GAME CONTAINER ─────────────────────────────────────────── */
#game-container {
  position: fixed;
  top: 0; left: 0;
  width: 1280px;
  height: 720px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 0 80px rgba(155,127,255,0.06), 0 0 200px rgba(0,0,0,0.9);
  transform-origin: top left;  /* JS sets scale + top/left for centering */
}

/* Scanlines */
#game-container::before {
  content:''; position:absolute; inset:0; pointer-events:none; z-index:50;
  background: repeating-linear-gradient(0deg,transparent,transparent 3px,rgba(0,0,0,0.06) 3px,rgba(0,0,0,0.06) 4px);
}
/* Vignette */
#game-container::after {
  content:''; position:absolute; inset:0; pointer-events:none; z-index:51;
  background: radial-gradient(ellipse at center,transparent 55%,rgba(0,0,0,0.5) 100%);
}

/* Distortion CSS */
#game-container.distorting #gameCanvas { animation: distort-flicker 0.14s steps(1) infinite; }
#game-container.distorting #ui-overlay { animation: ui-shake 0.09s ease-in-out infinite alternate; }
@keyframes distort-flicker {
  0%  { filter:none; }
  25% { filter:hue-rotate(40deg) saturate(1.6) brightness(1.08); }
  60% { filter:none; }
  85% { filter:invert(0.03) saturate(1.2); }
}
@keyframes ui-shake {
  from { transform:translate(0,0); }
  to   { transform:translate(1px,-1px); }
}

/* ── CANVAS ─────────────────────────────────────────────────── */
#gameCanvas { display:block; width:1280px; height:720px; }

/* Custom in-game cursor */
#game-container,
#game-container * {
  cursor: url("cursor_rabbit.png") 2 2, auto;
}

#game-container .battle-btn:disabled {
  cursor: not-allowed;
}

/* ── LOADING SCREEN ─────────────────────────────────────────── */
#loading-screen {
  position:absolute; inset:0; z-index:200;
  background:var(--bg);
  display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:20px;
  transition: opacity 0.8s ease;
}
#loading-screen.fade-out { opacity:0; pointer-events:none; }
.loading-title { font-size:32px; color:var(--accent); letter-spacing:0.3em; }
.loading-bar-wrap {
  width:320px; height:6px;
  background:var(--surface); border:1px solid var(--border);
}
#loading-bar { height:100%; width:0%; background:var(--accent); transition:width 0.2s ease; }
#loading-text { font-size:13px; color:var(--text-dim); letter-spacing:0.15em; }

/* ── FADE OVERLAY ────────────────────────────────────────────── */
#fade-overlay {
  position:absolute; inset:0; z-index:150;
  background:#000; opacity:0; pointer-events:none;
  transition: opacity 0.35s ease;
}
#fade-overlay.fade-in { opacity:1; pointer-events:all; }

/* ── UI OVERLAY ─────────────────────────────────────────────── */
#ui-overlay { position:absolute; inset:0; pointer-events:none; z-index:70; }

/* ── STATS BAR ──────────────────────────────────────────────── */
#stats-bar {
  position:absolute; top:14px; left:50%; transform:translateX(-50%);
  display:flex; align-items:center; gap:24px;
  background:rgba(4,4,12,0.97); border:1px solid var(--border-hi);
  border-top:1px solid var(--border-hi);
  padding:10px 28px;
  pointer-events:none;
}
.stat { display:flex; align-items:center; gap:9px; }
.stat-icon { width:28px; height:28px; object-fit:contain; image-rendering:pixelated; }
.stat-bar-bg {
  width:100px; height:10px;
  background:url(ui_bar_bg.png) no-repeat center / 100% 100%;
  overflow:hidden; padding:1px 3px;
}
.stat-fill {
  height:100%; width:0%; transition:width 0.35s ease;
  background-size:auto 100%; background-repeat:repeat-x;
}
#belief-fill  { background-image:url(ui_bar_belief_fill.png); }
#stress-fill  { background-image:url(ui_bar_stress_fill.png); }
#clarity-fill { background-image:url(ui_bar_clarity_fill.png); }
.stat-val { color:var(--text); min-width:28px; font-size:15px; }
#chapter-label {
  color:var(--text-dim); font-size:13px; letter-spacing:0.15em;
  padding-left:18px; border-left:1px solid var(--border);
}
#save-indicator {
  font-size:10px; color:var(--green); opacity:0;
  transition:opacity 0.4s ease; min-width:32px; text-align:center;
}
#save-indicator.show { opacity:1; }

/* ── DIALOGUE BOX ───────────────────────────────────────────── */
#dialogue-box {
  position:absolute; bottom:0; left:0; right:0;
  background:rgba(2,2,10,0.98); border-top:2px solid var(--border-hi);
  padding:22px 40px 24px; pointer-events:all;
  min-height:200px;
}
#dialogue-box.hidden { display:none; }
#dialogue-speaker {
  font-size:15px; color:var(--accent); letter-spacing:0.2em;
  text-transform:uppercase; margin-bottom:12px; display:none;
}
#dialogue-text {
  font-size:19px; color:var(--text); line-height:1.9;
  margin-bottom:14px; min-height:52px;
}
/* Typewriter cursor */
#dialogue-text::after {
  content:'▎'; color:var(--accent); opacity:0;
  animation:blink 0.8s step-end infinite;
}
#dialogue-text.typing::after { opacity:1; }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }

#dialogue-hint {
  font-size:13px; color:var(--text-dim);
  letter-spacing:0.1em; margin-bottom:10px;
  display:none;
}
#dialogue-hint.show { display:block; }
#dialogue-choices { display:flex; flex-wrap:wrap; gap:12px; }

.choice-btn {
  font-family:'Courier New',Courier,monospace;
  font-size:17px; color:#ede8ff;
  background:url(ui_choice_normal.png) no-repeat center / 100% 100%;
  border:none; padding:11px 30px; cursor:pointer;
  transition:filter 0.12s ease, transform 0.08s ease;
  pointer-events:all; letter-spacing:0.06em;
  min-width:200px; min-height:46px;
  text-shadow:0 1px 4px rgba(0,0,0,0.9);
}
.choice-btn:hover { background-image:url(ui_choice_hover.png); color:#fff; filter:brightness(1.2); transform:translateY(-1px); }
.choice-btn:active { transform:translateY(1px); }
.choice-btn.glitched { background-image:url(ui_choice_glitch.png); color:var(--red); animation:choice-shake 0.15s steps(1) infinite; }
.choice-btn.fake-choice { background-image:url(ui_fake_choice.png); color:transparent; min-width:150px; }
.choice-btn.keyboard-selected {
  background-image:url(ui_choice_hover.png) !important;
  color:#fff !important; filter:brightness(1.3);
}
.battle-btn.keyboard-selected {
  outline:2px solid rgba(155,127,255,0.95) !important;
  outline-offset:3px;
  box-shadow:0 0 20px rgba(155,127,255,0.45),
             inset 0 0 10px rgba(155,127,255,0.1) !important;
  color:#fff !important;
}
@keyframes choice-shake {
  0%{transform:translate(0,0);} 25%{transform:translate(-2px,1px);}
  50%{transform:translate(2px,-1px);} 75%{transform:translate(-1px,0);}
}

/* ── BATTLE UI ──────────────────────────────────────────────── */
#battle-ui {
  position:absolute; inset:0; display:flex;
  flex-direction:column; align-items:center; justify-content:flex-end;
  padding:0 50px 18px; pointer-events:all;
  background:rgba(4,4,10,0.55);
}
#battle-ui.hidden { display:none; }
#battle-top { position:absolute; top:80px; left:50%; transform:translateX(-50%); text-align:center; }
#enemy-name { font-size:22px; color:var(--red); letter-spacing:0.3em; text-transform:uppercase; margin-bottom:10px; }
#enemy-hp-bar { width:300px; height:10px; background:#1a1a2a; border:1px solid #5a2035; overflow:hidden; margin:0 auto; }
#enemy-hp-fill { height:100%; background:var(--red); box-shadow:0 0 6px var(--red); transition:width 0.4s ease; }
#enemy-hp-text { font-size:14px; color:var(--red); opacity:0.85; margin-top:6px; }
#battle-log {
  width:100%; max-width:620px; font-size:16px; color:var(--text);
  height:82px; overflow-y:auto; text-align:center; line-height:1.55;
  margin-bottom:10px;
  background:rgba(3,3,10,0.62);
  border:1px solid rgba(90,80,130,0.35);
  padding:8px 14px;
  text-shadow:0 0 8px rgba(0,0,0,0.85);
}
#battle-log div:last-child { color:#fff; }
#battle-log::-webkit-scrollbar { width:3px; }
#battle-log::-webkit-scrollbar-thumb { background:var(--border); }
#player-hp-bar-wrap { display:flex; align-items:center; gap:12px; margin-bottom:10px; }
#player-hp-label { font-size:15px; color:var(--text-dim); }
#player-hp-bar { width:240px; height:10px; background:#0e1a14; border:1px solid #1a4030; overflow:hidden; }
#player-hp-fill { height:100%; background:var(--green); transition:width 0.4s ease; }
#player-hp-val { font-size:15px; color:var(--green); min-width:30px; }
#battle-actions { display:flex; gap:12px; }
.battle-btn {
  font-family:'Courier New',Courier,monospace;
  background:rgba(7,7,14,0.92); border:1px solid;
  padding:10px 18px; cursor:pointer;
  transition:all 0.15s ease;
  display:flex; flex-direction:column; align-items:center; gap:4px;
  min-width:132px;
}
.btn-key { font-size:13px; opacity:0.5; letter-spacing:0.1em; }
.btn-title { font-size:18px; letter-spacing:0.1em; font-weight:bold; }
.btn-desc { font-size:13px; opacity:0.75; opacity:0.6; }
.battle-btn[data-action="believe"] { color:var(--orange); border-color:#5a3515; }
.battle-btn[data-action="believe"]:hover { background:rgba(255,153,68,0.15); border-color:var(--orange); box-shadow:0 0 14px rgba(255,153,68,0.25); }
.battle-btn[data-action="doubt"]   { color:var(--green);  border-color:#154030; }
.battle-btn[data-action="doubt"]:hover  { background:rgba(68,255,170,0.12); border-color:var(--green); box-shadow:0 0 14px rgba(68,255,170,0.25); }
.battle-btn[data-action="hesitate"] { color:#a8a0ff; border-color:#2a2845; }
.battle-btn[data-action="hesitate"]:hover { background:rgba(168,160,255,0.12); border-color:#a8a0ff; box-shadow:0 0 14px rgba(168,160,255,0.2); }
.battle-btn:disabled { opacity:0.25; cursor:not-allowed; pointer-events:none; }

/* ── HINT TEXT ──────────────────────────────────────────────── */
#hint-text {
  position:absolute; bottom:208px; left:50%; transform:translateX(-50%);
  font-size:15px; color:#bbb6d8; pointer-events:none; text-shadow:0 1px 6px rgba(0,0,0,0.9);
  white-space:nowrap; letter-spacing:0.06em;
}

/* ── VIRTUAL JOYSTICK ───────────────────────────────────────── */
#vjoystick-wrap {
  position:absolute; bottom:24px; left:24px;
  width:130px; height:130px;
  display:none; /* shown by JS on touch device */
  z-index:60; pointer-events:all;
}
#vjoystick-base {
  width:130px; height:130px; border-radius:50%;
  background:rgba(155,127,255,0.12);
  border:2px solid rgba(155,127,255,0.3);
  position:relative;
}
#vjoystick-knob {
  width:54px; height:54px; border-radius:50%;
  background:rgba(155,127,255,0.45);
  border:2px solid rgba(155,127,255,0.7);
  position:absolute;
  top:50%; left:50%;
  transform:translate(-50%,-50%);
  transition:transform 0.05s ease;
  pointer-events:none;
}
#vbuttons {
  position:absolute; bottom:24px; right:24px;
  display:none; z-index:60; pointer-events:all;
  gap:14px; flex-direction:column; align-items:center;
}
#vbtn-interact {
  font-family:'Courier New',Courier,monospace;
  width:80px; height:80px; border-radius:50%;
  background:rgba(155,127,255,0.18);
  border:2px solid rgba(155,127,255,0.5);
  color:var(--accent); font-size:14px; cursor:pointer;
  letter-spacing:0.05em;
}
#vbtn-interact:active { background:rgba(155,127,255,0.35); }

/* ── INTRO OVERLAY ──────────────────────────────────────────── */
#intro-overlay {
  position:absolute; inset:0; background:var(--bg);
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  z-index:80; pointer-events:all; transition:opacity 1s ease;
}
#intro-overlay.fade-out { opacity:0; pointer-events:none; }
.intro-title { font-size:42px; color:var(--accent); letter-spacing:0.3em; margin-bottom:14px; text-shadow:0 0 30px rgba(155,127,255,0.5); }
.intro-subtitle { font-size:16px; color:var(--text-dim); letter-spacing:0.2em; margin-bottom:50px; }
.intro-instructions { font-size:15px; color:var(--text-dim); line-height:2.2; text-align:center; letter-spacing:0.08em; }
.intro-instructions .key { color:var(--accent); }
.intro-start-btn {
  font-family:'Courier New',Courier,monospace; font-size:16px;
  color:var(--accent); background:transparent;
  border:1px solid var(--border-hi); padding:12px 40px;
  cursor:pointer; margin-top:36px; letter-spacing:0.2em; transition:all 0.15s;
}
.intro-start-btn:hover { background:rgba(155,127,255,0.1); border-color:var(--accent); }

/* ── EXPLORED MARK ──────────────────────────────────────────── */
/* Applied via JS: .explored class on object marker reduces dot opacity */
