:root {
  --gold: #c9a86a;
  --gold-dim: #7d6740;
  --hp: #9c1c18;
  --hp-hi: #c8352c;
  --st: #2f7d4a;
  --ink: #e8e0d0;
  --panel: rgba(8, 7, 7, 0.78);
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--ink); font-family: 'Georgia', 'Batang', serif; user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
.bar { position: relative; height: 10px; background: rgba(10, 8, 8, 0.75); border: 1px solid rgba(201, 168, 106, 0.55); box-shadow: 0 0 6px rgba(0,0,0,0.8); overflow: hidden; }
.bar .fill, .bar .ghost { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left center; }
.bar.hp .fill { background: linear-gradient(#c33a2f, #7d1410); }
.bar.hp .ghost, .bar.boss .ghost { background: #d9b46a; opacity: 0.75; }
.bar.st .fill { background: linear-gradient(#4aa868, #23633a); }
#p-bars { position: absolute; left: 42px; top: 36px; width: 380px; }
#p-bars .bar.hp { width: 100%; height: 12px; }
#p-bars .bar.st { width: 72%; margin-top: 6px; height: 8px; }
#flasks { margin-top: 12px; display: flex; align-items: center; gap: 8px; font-size: 18px; color: var(--ink); text-shadow: 0 1px 3px #000; }
.flask-icon { width: 14px; height: 22px; border-radius: 3px 3px 7px 7px; background: radial-gradient(circle at 50% 70%, #ffb347, #b5551a 70%); box-shadow: 0 0 8px rgba(255, 150, 60, 0.7); }
#boss-ui { position: absolute; left: 50%; bottom: 64px; width: min(820px, 70vw); transform: translateX(-50%); }
#boss-name { font-size: 17px; letter-spacing: 1px; margin: 0 0 5px 2px; text-shadow: 0 1px 3px #000; }
#boss-ui .bar.boss { height: 11px; }
#boss-ui .bar.boss .fill { background: linear-gradient(#b42a24, #6e100c); }
#boss-dmg { position: absolute; right: 2px; top: 2px; font-size: 15px; color: #f0e0c0; text-shadow: 0 1px 2px #000; opacity: 0; transition: opacity 0.4s; }
/* posture bars grow from the centre (Sekiro): boss at the top, player at the bottom centre */
.posture-bar { position: absolute; left: 50%; transform: translateX(-50%); height: 7px; background: rgba(10, 8, 8, 0.6); border: 1px solid rgba(201, 168, 106, 0.4); opacity: 0; transition: opacity 0.3s; }
.posture-bar .lfill, .posture-bar .rfill { position: absolute; top: 0; bottom: 0; width: 50%; background: linear-gradient(#f2c45a, #c27d1c); }
.posture-bar .lfill { right: 50%; transform-origin: right center; }
.posture-bar .rfill { left: 50%; transform-origin: left center; }
.posture-bar .mark { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff2c8; opacity: 0.8; }
.posture-bar.hot .lfill, .posture-bar.hot .rfill { background: linear-gradient(#ff8040, #c22a10); box-shadow: 0 0 10px #ff5020; }
#posture { top: 34px; width: min(560px, 40vw); }
#p-posture { bottom: 148px; width: min(420px, 30vw); height: 6px; }
#p-posture .lfill, #p-posture .rfill { background: linear-gradient(#f5d27a, #c8902c); }
#perilous { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%) scale(0.8); font-size: 96px; font-weight: bold; color: #e01010; text-shadow: 0 0 18px #ff1a00, 0 0 4px #000; opacity: 0; font-family: 'Batang', 'Malgun Gothic', serif; transition: opacity 0.12s, transform 0.12s; }
#perilous.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#perilous.blue { color: #3d8bff; text-shadow: 0 0 18px #1a66ff, 0 0 30px #66aaff, 0 0 4px #000; }
#callout { position: absolute; left: 50%; top: 31%; transform: translate(-50%, -50%) scale(0.9); font-size: 30px; letter-spacing: 6px; color: #fff4d8; text-shadow: 0 0 14px #ffcc66, 0 2px 3px #000; opacity: 0; transition: opacity 0.1s, transform 0.18s; pointer-events: none; }
#callout.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#callout.mikiri { color: #e8f4ff; text-shadow: 0 0 16px #66b3ff, 0 2px 3px #000; }
#lock-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: radial-gradient(#fff, #f7d68a 50%, transparent 70%); box-shadow: 0 0 8px #f7d68a; opacity: 0; }
#prompt { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); font-size: 18px; color: #f2e2c0; text-shadow: 0 0 8px #000; opacity: 0; transition: opacity 0.2s; }
#prompt.on { opacity: 1; }

#banner { position: fixed; left: 0; right: 0; top: 40%; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1.4s; }
#banner.on { opacity: 1; }
#banner .text { display: inline-block; font-size: 72px; letter-spacing: 6px; padding: 18px 80px; background: linear-gradient(90deg, transparent, rgba(0,0,0,0.78) 25%, rgba(0,0,0,0.78) 75%, transparent); }
#banner.lose .text { color: #a8140e; text-shadow: 0 0 22px rgba(160, 0, 0, 0.6); }
#banner.win .text { color: var(--gold); text-shadow: 0 0 22px rgba(255, 200, 100, 0.4); }
#banner .sub { margin-top: 18px; font-size: 18px; color: #d8ccb8; text-shadow: 0 1px 3px #000; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20, 14, 12, 0.55), rgba(0, 0, 0, 0.88)); }
.logo { font-size: 84px; letter-spacing: 14px; color: var(--gold); text-shadow: 0 0 30px rgba(255, 170, 80, 0.35), 0 2px 4px #000; }
.logo.small { font-size: 40px; letter-spacing: 8px; margin-bottom: 18px; }
.tagline { font-size: 22px; letter-spacing: 8px; color: #b9a98d; margin: 6px 0 40px; }
.menu { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.menu button { min-width: 300px; padding: 11px 24px; font: inherit; font-size: 19px; color: var(--ink); background: rgba(12, 10, 9, 0.7); border: 1px solid var(--gold-dim); cursor: pointer; letter-spacing: 2px; }
.menu button:hover, .menu button:focus { border-color: var(--gold); background: rgba(60, 44, 24, 0.7); outline: none; }
.menu button:disabled { opacity: 0.4; cursor: default; }
#load-status { margin-top: 26px; color: #9b8e78; font-size: 14px; min-height: 18px; }
#credits { position: absolute; bottom: 14px; left: 16px; right: 16px; text-align: center; color: #6f6656; font-size: 11px; line-height: 1.6; }
table.keys { border-collapse: collapse; font-size: 17px; margin-bottom: 14px; }
table.keys td { padding: 6px 22px; border-bottom: 1px solid rgba(201, 168, 106, 0.2); }
table.keys td:first-child { color: #b9a98d; }
.note { max-width: 680px; text-align: center; color: #a89a84; font-size: 14px; margin: 6px 0; line-height: 1.5; }
.setting { display: flex; align-items: center; gap: 14px; margin: 7px 0; font-size: 17px; }
.setting label { width: 140px; text-align: right; color: #b9a98d; }
.setting input[type=range] { width: 260px; accent-color: var(--gold); }
.setting span { width: 60px; }
.setting select { font: inherit; background: #111; color: var(--ink); border: 1px solid var(--gold-dim); padding: 3px 8px; }
#debug { position: fixed; left: 8px; bottom: 8px; font: 12px/1.35 Consolas, monospace; color: #cfe; background: rgba(0,0,0,0.6); padding: 6px 8px; white-space: pre; pointer-events: none; max-width: 46vw; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.6s ease-out; }
#fade.on { opacity: 1; transition: none; }
.screen { z-index: 20; }
#banner { z-index: 10; }
#fade { z-index: 30; }

#glint { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 6; mix-blend-mode: screen; }

#ki { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-family: 'Batang', 'Malgun Gothic', serif; }
#ki .ki-label { color: #d9c08a; font-size: 15px; letter-spacing: 2px; text-shadow: 0 0 4px #000; }
#ki .ki-pips { display: flex; gap: 4px; }
#ki .ki-pips i { width: 16px; height: 9px; transform: skewX(-20deg); background: rgba(20, 16, 10, 0.75); border: 1px solid #6b5630; }
#ki .ki-pips i.on { background: linear-gradient(#fff3b0, #e8b440); border-color: #f5d27a; box-shadow: 0 0 6px #f0c050; }
#ki .ki-hint { color: #fff1b8; font-size: 14px; opacity: 0; text-shadow: 0 0 8px #ffcc44, 0 1px 2px #000; transition: opacity 0.2s; }
#ki.full .ki-hint { opacity: 1; animation: kiPulse 0.9s ease-in-out infinite; }
#ki.full .ki-pips i.on { box-shadow: 0 0 10px #ffe080; }
@keyframes kiPulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

#press-v { position: absolute; left: 50%; bottom: 182px; transform: translateX(-50%); font: 600 22px 'Georgia', serif; letter-spacing: 6px; color: #fff4c8; text-shadow: 0 0 12px #ffc840, 0 0 26px #ff9a20, 0 2px 2px #000; opacity: 0; pointer-events: none; transition: opacity 0.2s; white-space: nowrap; }
#press-v b { display: inline-block; min-width: 1.3em; padding: 0 0.25em; border: 2px solid #ffe08a; border-radius: 6px; color: #fff; box-shadow: 0 0 12px #ffc840 inset, 0 0 12px #ffc840; }
#press-v.on { opacity: 1; animation: pressPulse 0.8s ease-in-out infinite; }
@keyframes pressPulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.07); } }
#cutin { position: fixed; inset: 0; pointer-events: none; z-index: 20; display: none; }
#cutin.on { display: block; }
#cutin .band { position: absolute; left: -5%; width: 110%; top: 26%; height: 38vh; overflow: hidden; transform: skewY(-7deg) scaleY(0); transform-origin: 50% 50%;
  background: linear-gradient(90deg, #0a0000 0%, #3a0505 35%, #1a0000 70%, #000 100%); border-top: 4px solid #ffd76a; border-bottom: 4px solid #ffd76a; box-shadow: 0 0 40px #000; will-change: transform, opacity; }
#cutin.on .band { animation: cutBand 1.25s cubic-bezier(.2,.9,.3,1) forwards; }
@keyframes cutBand { 0% { transform: skewY(-7deg) scaleY(0); opacity: 1; } 9% { transform: skewY(-7deg) scaleY(1.08); } 14% { transform: skewY(-7deg) scaleY(1); } 82% { transform: skewY(-7deg) scaleY(1); opacity: 1; } 100% { transform: skewY(-7deg) scaleY(0.02); opacity: 0; } }
#cutin .lines { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% + 90px); background: repeating-linear-gradient(90deg, rgba(255,230,160,0) 0 30px, rgba(255,255,255,0.22) 30px 31px, rgba(255,230,160,0) 31px 46px, rgba(255,230,160,0.5) 46px 49px, rgba(255,230,160,0) 49px 90px); will-change: transform; animation: speedLines 0.18s linear infinite; }
@keyframes speedLines { from { transform: translateX(0); } to { transform: translateX(-90px); } }
#cutin .face { position: absolute; top: 50%; left: 50%; height: 125%; transform: translate(10%, -50%) skewY(7deg); will-change: transform; }
#cutin.on .face { animation: faceSlide 1.25s cubic-bezier(.15,.85,.25,1) forwards; }
@keyframes faceSlide { 0% { transform: translate(70%, -50%) skewY(7deg) scale(1.15); } 22% { transform: translate(-30%, -50%) skewY(7deg) scale(1.05); } 80% { transform: translate(-42%, -50%) skewY(7deg) scale(1.0); } 100% { transform: translate(-60%, -50%) skewY(7deg) scale(1.0); } }
#cutin .slash { position: absolute; top: 48%; left: -10%; width: 120%; height: 6px; background: linear-gradient(90deg, transparent, #fff 40%, #ffe08a 60%, transparent); box-shadow: 0 0 18px #fff, 0 0 40px #ffd060; transform: scaleX(0); transform-origin: 100% 50%; }
#cutin.on .slash { animation: slashLine 1.25s ease-out forwards; }
@keyframes slashLine { 0%, 55% { transform: scaleX(0); opacity: 1; } 66% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
#cutin .kanji { position: absolute; top: 50%; left: 12%; transform: translateY(-50%) skewY(7deg) scale(2.4); font: bold 15vh 'Batang', 'Malgun Gothic', serif; color: #fff7d6; letter-spacing: 0.08em; text-shadow: 0 0 18px #ffcc40, 0 0 40px #ff6a00, 4px 4px 0 #300; opacity: 0; }
#cutin.on .kanji { animation: kanjiPunch 1.25s ease-out forwards; }
@keyframes kanjiPunch { 0%, 12% { opacity: 0; transform: translateY(-50%) skewY(7deg) scale(2.6); } 22% { opacity: 1; transform: translateY(-50%) skewY(7deg) scale(0.95); } 28% { transform: translateY(-50%) skewY(7deg) scale(1.03); } 80% { opacity: 1; transform: translateY(-50%) skewY(7deg) scale(1); } 100% { opacity: 0; transform: translateY(-50%) skewY(7deg) scale(1.1); } }
#cutin .cry { position: absolute; right: 9%; bottom: 10%; transform: skewY(7deg) rotate(-4deg); font: italic 900 6vh 'Georgia', serif; color: #ffe08a; text-shadow: 3px 3px 0 #500, 0 0 16px #ff8a00; opacity: 0; }
#cutin.on .cry { animation: cryPop 1.25s ease-out forwards; }
@keyframes cryPop { 0%, 18% { opacity: 0; transform: skewY(7deg) rotate(-4deg) scale(1.8); } 26% { opacity: 1; transform: skewY(7deg) rotate(-4deg) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---- 수련서 (tutorial) ---- */
#tutorial { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 18, 10, 0.92), rgba(5, 3, 2, 0.97)); font-family: 'Malgun Gothic', sans-serif; }
#tutorial.hidden { display: none; }
#tutorial .tut-frame { width: min(1200px, 95vw); max-height: 94vh; display: flex; flex-direction: column; border: 1px solid #8a6a32;
  background: linear-gradient(#1b130c, #0e0a07); box-shadow: 0 0 60px #000, inset 0 0 40px rgba(0, 0, 0, 0.8); padding: 14px 20px; }
#tutorial .tut-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #5a4422; padding-bottom: 8px; }
#tutorial .tut-book { font: 600 18px 'Batang', 'Malgun Gothic', serif; color: #e9cf8e; letter-spacing: 4px; }
#tutorial .tut-sep { color: #6b5630; }
#tutorial .tut-title { font: 700 20px 'Malgun Gothic', sans-serif; color: #f0e2c2; }
#tutorial .tut-dots { display: flex; gap: 7px; margin-left: auto; }
#tutorial .tut-dots i { width: 26px; height: 6px; background: #3a2c18; border: 1px solid #6b5630; cursor: pointer; transform: skewX(-20deg); }
#tutorial .tut-dots i.on { background: linear-gradient(#fff3b0, #e8b440); border-color: #f5d27a; box-shadow: 0 0 6px #f0c050; }
#tutorial .tut-x { background: none; border: none; color: #b8a27a; font-size: 20px; cursor: pointer; padding: 0 4px; }
#tutorial .tut-content { padding: 16px 0 12px; overflow-y: auto; min-height: 0; }
#tutorial .key { display: inline-block; padding: 0 7px; margin: 0 2px; border: 1px solid #c9a24f; border-radius: 4px; background: #2a1e10; color: #fff3cf; font: 600 14px 'Malgun Gothic', sans-serif; line-height: 24px; box-shadow: 0 2px 0 #5a4422; }
#tutorial .sep { color: #b8a27a; margin: 0 2px; }
#tutorial b { color: #ffd76a; }
/* page 1: keys */
#tutorial .tut-keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 36px; max-width: 900px; margin: 6px auto 0; }
#tutorial .kr { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px dashed #3d2e1a; padding: 6px 4px; }
#tutorial .kn { color: #e6dcc6; font-size: 17px; }
#tutorial .kk { white-space: nowrap; }
#tutorial .tut-pad { text-align: center; color: #8f7b58; font-size: 13px; margin-top: 18px; }
/* page 2: cards */
#tutorial .tut-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: calc(3 * (47vh - 172px) * 16 / 9 + 70px); margin: 0 auto; }
#tutorial .card { background: rgba(0, 0, 0, 0.35); border: 1px solid #5a4422; padding: 8px 8px 10px; }
#tutorial .card img { width: 100%; aspect-ratio: 16 / 9; display: block; border: 1px solid #8a6a32; background: #000; }
#tutorial .card .ct { font: 700 17px 'Malgun Gothic', sans-serif; color: #f3dfaa; margin: 8px 0 4px; }
#tutorial .card.red .ct { color: #ff5a46; text-shadow: 0 0 10px rgba(255, 30, 0, 0.5); }
#tutorial .card.blue .ct { color: #6eaaff; text-shadow: 0 0 10px rgba(30, 100, 255, 0.5); }
#tutorial .card ul { list-style: none; margin: 0; padding: 0; color: #e6dcc6; font-size: 14px; line-height: 1.55; }
#tutorial .card li { position: relative; padding-left: 13px; }
#tutorial .card li::before { content: '◆'; position: absolute; left: 0; top: 1px; font-size: 8px; color: #c9a24f; }
#tutorial .card .key { font-size: 12px; line-height: 19px; padding: 0 5px; }
#tutorial .tut-foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid #5a4422; padding-top: 10px; }
#tutorial .tut-foot button { background: linear-gradient(#3a2a16, #22180c); border: 1px solid #8a6a32; color: #f0e2c2; padding: 7px 18px; font: 600 15px 'Malgun Gothic', sans-serif; cursor: pointer; }
#tutorial .tut-foot button:hover:not(:disabled) { border-color: #f5d27a; color: #fff; box-shadow: 0 0 10px rgba(240, 192, 80, 0.4); }
#tutorial .tut-foot button:disabled { opacity: 0.35; cursor: default; }
#tutorial .tut-keys { color: #8f7b58; font-size: 13px; margin-left: auto; }
#tutorial .tut-skip { background: none !important; border-color: #5a4422 !important; color: #b8a27a !important; }
@media (max-width: 900px) { #tutorial .tut-cards { grid-template-columns: 1fr 1fr; } #tutorial .tut-keys-grid { grid-template-columns: 1fr; } }
