:root {
  --bg: #07040a;
  --text: #ece2dc;
  --sub: #6b5a62;
  --dim: #33262c;
  --accent: #ff1f3d;
  --accent-2: #ff7a45;
  --err: #ff2b45;
  --panel: rgba(12, 6, 10, 0.72);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--dim);
  color: var(--text);
}

#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.78) 100%);
}
body.critical #vignette { animation: critical 0.9s ease-in-out infinite; }
@keyframes critical {
  0%, 100% { box-shadow: inset 0 0 120px 20px rgba(255, 0, 30, 0.22); }
  50% { box-shadow: inset 0 0 220px 70px rgba(255, 0, 30, 0.55); }
}

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px;
  transition: opacity 0.4s;
}
body.playing #topbar { opacity: 0.12; }
body.playing #topbar:hover { opacity: 1; }

.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.5px; }
.logo .mark { font-family: var(--serif); color: var(--accent); font-size: 30px; text-shadow: 0 0 14px rgba(255, 30, 60, 0.7); }
.logo b { color: var(--accent); }

#config { display: flex; flex-wrap: wrap; gap: 6px; background: var(--panel); padding: 6px 10px; border-radius: 10px; }
#config .group { display: flex; gap: 2px; padding-right: 8px; margin-right: 4px; border-right: 2px solid var(--dim); }
#config button {
  background: none; border: 0; color: var(--sub); font: inherit; font-size: 13px;
  padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: color 0.15s;
}
#config button:hover { color: var(--text); }
#config button.active { color: var(--accent); }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 80px; left: 28px; z-index: 4; }
#hearts { display: flex; gap: 8px; }
.heart { position: relative; width: 34px; height: 34px; }
.heart span { position: absolute; inset: 0; }
.heart svg { width: 100%; height: 100%; display: block; }
.heart .ghost svg { fill: none; stroke: #4a2630; stroke-width: 1.6; }
.heart .half svg { fill: var(--accent); filter: drop-shadow(0 0 6px rgba(255, 30, 60, 0.75)); }
.heart .half { transition: transform 0.75s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.75s; }
.heart .l { clip-path: inset(0 50% 0 0); }
.heart .r { clip-path: inset(0 0 0 50%); }
.heart.broken .l { transform: translate(-16px, 34px) rotate(-40deg); opacity: 0; }
.heart.broken .r { transform: translate(16px, 38px) rotate(45deg); opacity: 0; }
.heart.broken { animation: heartHit 0.35s; }
@keyframes heartHit { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
body.critical .heart:not(.broken) .half svg { animation: beat 0.9s infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } }

#live { display: flex; gap: 18px; margin-top: 12px; color: var(--sub); font-size: 12px; }
#live div { display: flex; align-items: baseline; gap: 5px; }
#live b { color: var(--accent); font-size: 22px; font-weight: 800; }

#meter { position: fixed; top: 80px; right: 28px; z-index: 4; text-align: right; }
#rank {
  font-family: var(--serif); font-weight: 900; font-size: 78px; line-height: 1;
  background: linear-gradient(180deg, #8f8288 0%, #4b3d44 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: inline-block; transform-origin: 70% 60%;
}
#rank[data-r="1"] { background-image: linear-gradient(180deg, #e9d8d0 0%, #8a5d63 100%); }
#rank[data-r="2"] { background-image: linear-gradient(180deg, #ffd0d6 0%, #d43a52 100%); }
#rank[data-r="3"] { background-image: linear-gradient(180deg, #fff 0%, #ff3d5a 50%, #8a0016 100%); filter: drop-shadow(0 0 10px rgba(255, 20, 50, 0.5)); }
#rank[data-r="4"], #rank[data-r="5"], #rank[data-r="6"] {
  background-image: linear-gradient(180deg, #fff6d8 0%, #ffb02e 35%, #ff1f3d 70%, #6a0010 100%);
  filter: drop-shadow(0 0 16px rgba(255, 40, 40, 0.75));
}
#rank.pop { animation: rankPop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
#rank.drop { animation: rankDrop 0.45s ease-out; }
@keyframes rankPop { 0% { transform: scale(2.2) rotate(-12deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes rankDrop { 0% { transform: translateY(0); opacity: 1; filter: blur(0); } 40% { transform: translateY(14px) skewX(-15deg); opacity: 0.3; filter: blur(2px); } 100% { transform: none; opacity: 1; } }
#rank-name { font-size: 11px; letter-spacing: 4px; text-transform: uppercase; color: var(--accent); margin-top: 2px; }
#combo { font-size: 26px; font-weight: 800; margin-top: 6px; }
#score { font-size: 13px; color: var(--sub); }

/* ---------- boss bar ---------- */
#bossbar {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 4;
  width: min(560px, 46vw); text-align: center; opacity: 0; transition: opacity 0.4s; pointer-events: none;
}
#bossbar.show { opacity: 1; }
#boss-name { font-family: var(--serif); font-weight: 900; letter-spacing: 6px; font-size: 18px; color: #ffd0d6; text-shadow: 0 0 12px #f00; margin-bottom: 8px; }
#bossbar .bar { position: relative; height: 10px; background: rgba(40, 0, 8, 0.85); border: 1px solid #5a0a18; overflow: hidden; }
#boss-fill, #boss-lag { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; }
#boss-lag { background: #ffe1e5; transition: width 0.6s 0.25s; }
#boss-fill { background: linear-gradient(90deg, #6a0010, #ff1f3d); transition: width 0.12s; }

/* ---------- title ---------- */
#title {
  position: fixed; left: 50%; top: 27vh; transform: translate(-50%, -50%); z-index: 2;
  text-align: center; pointer-events: none; transition: opacity 0.6s, transform 0.6s;
}
#title h1 {
  font-family: var(--serif); font-weight: 900; font-size: clamp(46px, 9vw, 124px); letter-spacing: 0.04em; line-height: 1;
  color: #f4e6df; text-shadow: 0 0 30px rgba(255, 0, 40, 0.45), 0 6px 0 #300008;
}
#title h1 span { color: var(--accent); }
#title p { margin-top: 10px; letter-spacing: 0.6em; color: #c9a9ae; font-size: clamp(11px, 1.4vw, 15px); }
body.playing #title, body.dead #title { opacity: 0; transform: translate(-50%, -70%); }

/* ---------- typing area ---------- */
#typing {
  position: fixed; left: 50%; top: 65vh; transform: translateX(-50%); z-index: 3;
  width: min(1050px, 92vw);
}
#hint { text-align: center; color: var(--sub); font-size: 12px; margin-bottom: 16px; transition: opacity 0.4s; }
body.playing #hint, body.dead #hint { opacity: 0; }
#caps {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%); padding: 4px 10px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
#caps.show { opacity: 1; }

#words-wrap { position: relative; font-size: clamp(18px, 2.4vw, 30px); }
#words {
  position: relative; display: flex; flex-wrap: wrap; align-content: flex-start;
  height: 4.8em; overflow: hidden; user-select: none; transition: filter 0.2s, opacity 0.2s;
}
.word { position: relative; margin: 0 0.3em; height: 1.6em; line-height: 1.6em; color: var(--sub); }
.word span { display: inline-block; transition: color 0.08s; }
.word span.ok { color: var(--text); }
.word.boss span { color: #7d2b38; }
.word.boss span.ok { color: #ffb8c1; }
.word.error { box-shadow: inset 0 -2px 0 var(--err); }
.word.killed::after {
  content: ''; position: absolute; left: -6%; top: 52%; width: 112%; height: 2px;
  background: var(--accent); box-shadow: 0 0 6px var(--accent);
  transform: rotate(-9deg) scaleX(0); transform-origin: left center;
  animation: cutWord 0.16s ease-out forwards;
}
@keyframes cutWord { to { transform: rotate(-9deg) scaleX(1); } }
.word span.miss { animation: miss 0.32s ease-out; }
@keyframes miss { 0% { color: var(--err); text-shadow: 0 0 12px var(--err); transform: translateY(-4px) scale(1.25); } 100% { transform: none; } }

#caret {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: 0.09em; height: 1.15em; margin-top: 0.22em; margin-left: -0.04em;
  background: var(--accent); border-radius: 2px; box-shadow: 0 0 10px var(--accent);
  transition: transform 0.085s ease-out; animation: blink 1s step-end infinite;
}
body.playing #caret { animation: none; }
@keyframes blink { 50% { opacity: 0; } }

.ghost-char {
  position: absolute; z-index: 3; pointer-events: none; line-height: 1.6em;
  color: var(--err); font-weight: 800; text-shadow: 0 0 10px var(--err);
  animation: ghostFall 0.65s cubic-bezier(0.3, 0, 0.8, 0.6) forwards;
}
@keyframes ghostFall {
  0% { transform: translate(0, -6px) scale(1.5) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), 70px) scale(0.9) rotate(var(--rot)); opacity: 0; }
}

#focus {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
body.blurred #focus { opacity: 1; }
body.blurred #words { filter: blur(5px); opacity: 0.35; }

body.hurt #words { animation: glitch 0.3s steps(3); }
body.hurt #hearts { animation: shake 0.3s; }
@keyframes glitch {
  0% { transform: translate(-5px, 2px); text-shadow: 3px 0 rgba(255, 0, 40, 0.9), -3px 0 rgba(0, 255, 255, 0.6); }
  33% { transform: translate(4px, -2px) skewX(-6deg); text-shadow: -4px 0 rgba(255, 0, 40, 0.9), 4px 0 rgba(0, 255, 255, 0.6); }
  66% { transform: translate(-2px, 1px); text-shadow: 2px 0 rgba(255, 0, 40, 0.9), -2px 0 rgba(0, 255, 255, 0.6); }
  100% { transform: none; text-shadow: none; }
}
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

#input { position: fixed; left: 50%; top: 70vh; width: 1px; height: 1px; opacity: 0; border: 0; pointer-events: none; }

/* ---------- results ---------- */
#result {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 0, 5, 0.55), rgba(0, 0, 0, 0.85));
  opacity: 0; pointer-events: none; transition: opacity 0.7s;
}
#result.show { opacity: 1; pointer-events: auto; }
#typing, #hud, #meter { transition: opacity 0.5s; }
body.results #typing, body.results #hud, body.results #meter { opacity: 0; }
.res-card { width: min(920px, 94vw); max-height: 94vh; overflow: auto; padding: 8px; transform: translateY(20px); transition: transform 0.7s; }
#result.show .res-card { transform: none; }
.res-head { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.res-kanji { font-family: var(--serif); font-size: 96px; line-height: 1; color: var(--accent); text-shadow: 0 0 30px rgba(255, 0, 30, 0.7); }
.res-head h2 { font-family: var(--serif); font-size: 40px; letter-spacing: 0.25em; text-transform: uppercase; }
#r-epitaph { color: #b49aa0; font-size: 14px; margin-top: 6px; }
.res-main { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: stretch; }
.res-big { display: flex; flex-direction: column; gap: 10px; }
label { display: block; color: var(--sub); font-size: 13px; text-transform: lowercase; }
.res-big b { display: block; font-size: 64px; line-height: 1; color: var(--accent); font-weight: 800; }
.res-chart { min-height: 170px; position: relative; }
#r-chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; margin-top: 24px; }
.res-grid b { font-size: 24px; font-weight: 800; color: var(--text); }
#r-best { margin-top: 18px; color: var(--accent-2); font-size: 13px; min-height: 1em; }
.res-actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; color: var(--sub); font-size: 13px; }
#again {
  font: inherit; font-weight: 800; font-size: 15px; letter-spacing: 0.08em; color: #fff; cursor: pointer;
  background: linear-gradient(180deg, #ff2b45, #a5001a); border: 0; padding: 12px 22px; border-radius: 8px;
  box-shadow: 0 0 20px rgba(255, 20, 50, 0.4);
}
#again:hover { filter: brightness(1.15); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  #topbar { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 6px; }
  #config button { font-size: 11px; padding: 3px 5px; }
  #hud { top: 132px; left: 12px; }
  .heart { width: 24px; height: 24px; }
  #live { gap: 10px; }
  #live b { font-size: 16px; }
  #meter { top: 132px; right: 12px; }
  #rank { font-size: 48px; }
  #combo { font-size: 18px; }
  #bossbar { top: 220px; width: 80vw; }
  #hint { font-size: 10px; }
  .res-main { grid-template-columns: 1fr; }
  .res-big { flex-direction: row; gap: 30px; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  .res-kanji { font-size: 64px; }
  .res-head h2 { font-size: 26px; }
}

/* ================= boss: fase, regen, tangkisan ================= */
#bossbar .regen { height: 4px; margin-top: 4px; background: rgba(255, 255, 255, 0.06); opacity: 0; transition: opacity 0.3s; }
#bossbar .regen.on { opacity: 1; }
#boss-regen { height: 100%; width: 0; background: #ff5f9e; box-shadow: 0 0 8px #ff5f9e; }
#boss-phase { margin-top: 6px; font-size: 11px; letter-spacing: 0.3em; color: #ffb3bd; }
#boss-phase b { color: #fff; }
.word.boss.p1 span { color: #8a4a22; }
.word.boss.p1 span.ok { color: #ffc89a; }
.word.boss.p2 span { color: #5e3a86; }
.word.boss.p2 span.ok { color: #e0c0ff; }
.word.regen span { color: #a0306a; }
.word.heal span { color: #b08a2e; }
.word.heal span.ok { color: #ffe3a0; }
.heart.healed { animation: heartHeal 0.6s ease-out; }
.heart.healed .half svg { filter: drop-shadow(0 0 12px rgba(120, 255, 160, 0.9)); }
@keyframes heartHeal { 0% { transform: scale(0.2) rotate(-20deg); } 60% { transform: scale(1.4); } 100% { transform: none; } }
.word.regen { animation: regenIn 0.5s ease-out; }
@keyframes regenIn { 0% { transform: scale(1.6); filter: drop-shadow(0 0 10px #ff5f9e); } 100% { transform: none; } }

#qte {
  position: fixed; left: 50%; top: 46%; z-index: 9; transform: translate(-50%, -50%) scale(0.85);
  opacity: 0; pointer-events: none; transition: opacity 0.12s, transform 0.12s;
}
#qte.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.qte-card {
  min-width: min(380px, 88vw); padding: 18px 24px; border-radius: 14px; text-align: center;
  background: rgba(10, 2, 6, 0.9); border: 2px solid var(--accent);
  box-shadow: 0 0 40px rgba(255, 20, 50, 0.5), inset 0 0 30px rgba(255, 0, 40, 0.15);
  animation: qtePulse 0.45s ease-in-out infinite alternate;
}
@keyframes qtePulse { to { box-shadow: 0 0 70px rgba(255, 20, 50, 0.8), inset 0 0 40px rgba(255, 0, 40, 0.3); } }
.qte-label { font-family: var(--serif); font-weight: 900; letter-spacing: 0.3em; color: var(--accent); font-size: 18px; margin-bottom: 12px; }
#qte-word { font-size: clamp(28px, 4vw, 46px); font-weight: 800; color: #6b5a62; white-space: pre; }
#qte-word span { display: inline-block; }
#qte-word span.ok { color: #fff; text-shadow: 0 0 12px #ff2b45; }
#qte-word span.cur { border-bottom: 3px solid var(--accent); }
#qte-word.shake { animation: shake 0.25s; }
#qte-hint { color: #c9a9ae; font-size: 12px; margin-top: 10px; }
.qte-time { height: 6px; margin-top: 12px; border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, 0.1); }
#qte-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #ff2b45, #ffb02e); }
body.qte #words { filter: blur(3px); opacity: 0.35; }

/* ================= mode waktu ================= */
#secs-group, #timer { display: none; }
body.timed #secs-group { display: flex; }
body.timed #hearts { display: none; }
#timer {
  font-size: clamp(22px, 2.6vw, 32px); font-weight: 800; color: var(--accent);
  margin: 0 0 4px 0.3em; text-shadow: 0 0 12px rgba(255, 30, 60, 0.5);
}
body.timed #timer { display: block; }
body.timed:not(.playing) #timer { opacity: 0.5; }
#timer.low { animation: timerLow 0.5s ease-in-out infinite alternate; }
@keyframes timerLow { to { color: #fff; text-shadow: 0 0 20px var(--accent); } }

/* ================= revive & link halaman ================= */
#revive {
  position: fixed; inset: 0; z-index: 11; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40, 0, 8, 0.35), rgba(0, 0, 0, 0.7));
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#revive.show { opacity: 1; pointer-events: auto; }
.rv-card {
  width: min(400px, 90vw); padding: 24px; border-radius: 14px; text-align: center;
  background: rgba(14, 7, 11, 0.95); border: 1px solid #5a3a10; box-shadow: 0 0 60px rgba(255, 170, 40, 0.25);
}
.rv-kanji { font-family: var(--serif); font-size: 64px; line-height: 1; color: #ffd04a; text-shadow: 0 0 24px rgba(255, 190, 60, 0.7); }
.rv-card h2 { font-family: var(--serif); font-size: 28px; letter-spacing: 0.1em; margin: 6px 0; }
.rv-card p { color: #c9b4a0; font-size: 14px; margin-bottom: 16px; }
.rv-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#rv-yes {
  font: inherit; font-weight: 800; font-size: 15px; color: #2a1400; cursor: pointer; border: 0;
  padding: 12px 20px; border-radius: 8px; background: linear-gradient(180deg, #ffd56a, #e09a18);
  box-shadow: 0 0 22px rgba(255, 190, 60, 0.45);
}
#rv-yes:hover { filter: brightness(1.1); }
.rv-time { height: 4px; margin-top: 16px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
#rv-bar { height: 100%; width: 100%; background: #ffd04a; }

#site-links {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  font-size: 12px; color: var(--sub); white-space: nowrap; transition: opacity 0.4s;
}
#site-links a { color: var(--sub); text-decoration: none; }
#site-links a:hover { color: var(--text); }
body.playing #site-links, body.results #site-links, body.mp #site-links { opacity: 0; pointer-events: none; }

/* ================= share & leaderboard ================= */
#config button.lb-btn { color: #ffd04a; font-weight: 800; }
#r-lb { margin-top: 6px; color: #ffd04a; font-size: 13px; min-height: 1em; }
#r-lb a { color: #ffd04a; cursor: pointer; text-decoration: underline; }
#share-modal, #lb-modal {
  position: fixed; inset: 0; z-index: 21; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#share-modal.show, #lb-modal.show { opacity: 1; pointer-events: auto; }
.sh-card, .lbm-card {
  width: min(760px, 94vw); max-height: 92vh; overflow: auto; padding: 20px 22px; border-radius: 14px;
  background: #0e070b; border: 1px solid #3a1620; box-shadow: 0 0 60px rgba(255, 0, 40, 0.15);
}
.lbm-card { width: min(640px, 94vw); }
.sh-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sh-head h2 { font-family: var(--serif); font-size: 24px; letter-spacing: 0.06em; }
.sh-head .ghost-btn { padding: 6px 12px; }
#sh-img { display: block; width: 100%; border-radius: 10px; border: 1px solid #2a1218; aspect-ratio: 1200 / 630; background: #12050c; }
.sh-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sh-actions button, .sh-actions a {
  font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; text-decoration: none;
  padding: 10px 14px; border-radius: 8px; border: 1px solid #3a1620; background: #1a0d13; color: var(--text);
}
.sh-actions button:hover, .sh-actions a:hover { border-color: var(--accent); }
.sh-actions .sh-primary { background: linear-gradient(180deg, #ff2b45, #a5001a); border: 0; color: #fff; }
.lbm-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.lbm-tabs button {
  font: inherit; font-size: 13px; cursor: pointer; padding: 6px 12px; border-radius: 6px;
  border: 1px solid #2a1218; background: #140a0f; color: var(--sub);
}
.lbm-tabs button.on { color: #fff; border-color: var(--accent); background: #2a0c14; }
.lbm-tabs.small button { font-size: 12px; padding: 4px 10px; }
.lbm-row2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lbm-row2 .lbm-tabs { margin-bottom: 0; }
#lbm-filter { color: var(--sub); font-size: 12px; }
.lbm-name { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; }
.lbm-name label { margin: 0; white-space: nowrap; }
.lbm-name input {
  flex: 1; padding: 8px 10px; border-radius: 8px; outline: none; font: inherit; font-size: 14px;
  background: #1a0d13; border: 1px solid #3a1620; color: var(--text);
}
.lbm-name input:focus { border-color: var(--accent); }
#lbm-list { display: flex; flex-direction: column; gap: 2px; min-height: 120px; }
.lb-r {
  display: grid; grid-template-columns: 34px 1fr 64px 56px 70px; gap: 8px; align-items: baseline;
  padding: 7px 10px; border-radius: 6px; font-size: 14px; background: #120a0e;
}
.lb-r.head { background: none; color: var(--sub); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.lb-r .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-r .p { color: var(--sub); font-weight: 800; }
.lb-r.top1 .p { color: #ffd04a; }
.lb-r.top2 .p { color: #e6e6f0; }
.lb-r.top3 .p { color: #d98a4a; }
.lb-r b { color: var(--accent); }
.lb-r.me { outline: 1px solid var(--accent); background: #2a0c14; }
.lb-msg { color: var(--sub); font-size: 13px; padding: 24px 10px; text-align: center; }
#lbm-note { color: var(--sub); font-size: 12px; margin-top: 10px; }

/* ================= multiplayer ================= */
#config button.mp-btn { color: var(--accent-2); font-weight: 800; }
#config button.mp-btn:hover { color: #ffd0a0; }

#opp-hud, #race, #caret-opp, #r-vs, #leave { display: none; }
body.mp #opp-hud { display: flex; }
body.mp #race, body.mp #caret-opp { display: block; }
body.mp #r-vs { display: grid; }
body.mp #leave { display: inline-block; }
body.mp #title { display: none; }
body.mp #hud, body.mp #meter { top: calc(var(--panel-b, 300px) + 30px); }
body.mp .res-grid { display: none; }
body.mp #bossbar { top: calc(var(--panel-b, 300px) + 14px); }

#opp-hud {
  position: fixed; left: 12px; top: calc(var(--panel-t, 70px) + 8px); z-index: 4;
  align-items: center; gap: 12px; padding: 4px 10px; border-radius: 6px;
  font-size: 12px; color: #9fb4d8; background: rgba(5, 10, 25, 0.65);
}
.opp-tag { background: #2f6bff; color: #fff; font-weight: 800; padding: 1px 6px; border-radius: 4px; font-size: 10px; letter-spacing: 2px; }
#opp-name { color: #d8e6ff; }
#opp-hud b { color: #d8e6ff; }
#opp-hearts { color: #4a90ff; letter-spacing: 1px; }
#opp-hearts .lost { opacity: 0.18; }
#opp-rank { font-family: var(--serif); font-weight: 900; color: #5aa2ff; font-size: 16px; }

#race { position: fixed; left: 0; right: 0; top: calc(var(--panel-b, 300px) - 3px); height: 6px; z-index: 4; pointer-events: none; }
#race .track { position: relative; height: 100%; background: rgba(255, 255, 255, 0.07); }
#race .fill { position: absolute; left: 0; height: 3px; width: 0; transition: width 0.25s; }
#race .fill.me { top: 0; background: var(--accent); }
#race .fill.opp { bottom: 0; background: #2f7bff; }
#race .mk { position: absolute; top: -6px; width: 4px; height: 18px; border-radius: 2px; transform: translateX(-50%); transition: left 0.25s; left: 0; }
#race .mk.me { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#race .mk.opp { background: #4a90ff; box-shadow: 0 0 8px #4a90ff; }
#race .mk span { position: absolute; left: 50%; transform: translateX(-50%); font-size: 10px; white-space: nowrap; font-weight: 800; }
#race .mk.me span { top: 20px; color: #ff6b80; }
#race .mk.opp span { top: -16px; color: #8cbcff; }
#race .mk.dead { background: #6b5a62; box-shadow: none; }
#race .mk.dead span::after { content: ' ☠'; }
#race .flag { position: absolute; right: 8px; top: -11px; font-size: 16px; }

#toast {
  position: fixed; left: 50%; top: calc(var(--panel-b, 140px) + 70px); z-index: 7;
  transform: translate(-50%, -12px); padding: 10px 18px; border-radius: 8px;
  font-weight: 800; font-size: 14px; letter-spacing: 0.08em; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.in { background: rgba(120, 20, 200, 0.9); color: #fff; box-shadow: 0 0 28px rgba(170, 60, 255, 0.7); }
#toast.out { background: rgba(255, 170, 40, 0.92); color: #2a0600; box-shadow: 0 0 22px rgba(255, 170, 40, 0.5); }
#toast.info { background: rgba(30, 20, 26, 0.92); color: var(--text); }

.word.sab span { color: #6f3f9c; }
.word.sab span.ok { color: #e0c0ff; }

#caret-opp {
  position: absolute; left: 0; top: 0; z-index: 1;
  width: 0.09em; height: 1.15em; margin-top: 0.22em; margin-left: -0.04em;
  background: #3d8bff; border-radius: 2px; box-shadow: 0 0 8px #3d8bff; opacity: 0.8;
  transition: transform 0.12s ease-out, opacity 0.2s;
}
#caret-opp.off { opacity: 0; }

/* lobby */
#lobby {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.74); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#lobby.show { opacity: 1; pointer-events: auto; }
.lb-card {
  width: min(460px, 92vw); padding: 26px; border-radius: 14px;
  background: #0e070b; border: 1px solid #3a1620; box-shadow: 0 0 60px rgba(255, 0, 40, 0.15);
}
.lb-card h2 { font-family: var(--serif); font-size: 30px; letter-spacing: 0.1em; }
.lb-card h2 span { color: var(--accent); }
.lb-sub { color: var(--sub); font-size: 12px; margin: 6px 0 14px; line-height: 1.6; }
.lb-card label { margin: 12px 0 6px; }
.lb-card input {
  width: 100%; padding: 10px 12px; border-radius: 8px; outline: none;
  background: #1a0d13; border: 1px solid #3a1620; color: var(--text); font: inherit; font-size: 15px;
}
.lb-card input:focus { border-color: var(--accent); }
.lb-card button {
  font: inherit; font-weight: 800; cursor: pointer; border-radius: 8px; padding: 10px 16px;
  border: 1px solid #3a1620; background: #1a0d13; color: var(--text);
}
.lb-card button:hover { border-color: var(--accent); }
.lb-card button:disabled { opacity: 0.5; cursor: default; }
.lb-card .lb-primary { background: linear-gradient(180deg, #ff2b45, #a5001a); border: 0; color: #fff; }
#lb-pick { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.lb-join { display: flex; gap: 8px; }
.lb-join input { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
#lb-room { display: none; margin-top: 10px; }
#lobby.in-room #lb-room { display: block; }
#lobby.in-room #lb-pick { display: none; }
.lb-code-row { display: flex; gap: 10px; align-items: center; }
#lb-mycode { flex: 1; font-size: 40px; font-weight: 800; letter-spacing: 0.3em; color: var(--accent); }
#lb-players { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 10px; }
.lb-p { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; background: #160a10; font-size: 14px; }
.lb-p i { width: 10px; height: 10px; border-radius: 50%; }
.lb-p small { margin-left: auto; color: var(--sub); }
#lb-status { color: var(--sub); font-size: 13px; }
#lb-rules { color: #8a7880; font-size: 12px; margin-top: 6px; }
#lb-go { display: none; width: 100%; margin-top: 14px; }
#lobby.can-start #lb-go { display: block; }
#lb-error { color: var(--err); font-size: 13px; min-height: 1em; margin-top: 12px; }
.lb-card .lb-link { background: none; border: 0; color: var(--sub); font-weight: 400; padding: 6px 0; margin-top: 4px; }
.lb-card .lb-link:hover { color: var(--text); }

/* hasil versus */
#r-vs { grid-template-columns: 130px 1fr 1fr; gap: 6px 16px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--dim); align-items: baseline; }
#r-vs .vs-me { color: var(--accent); font-weight: 800; }
#r-vs .vs-opp { color: #5aa2ff; font-weight: 800; }
#r-vs .vs-v { font-size: 20px; font-weight: 800; }
#r-vs .vs-v.best::after { content: ' ★'; color: var(--accent-2); font-size: 13px; }
.res-kanji.win { color: #ffb02e; text-shadow: 0 0 30px rgba(255, 170, 40, 0.75); }
.ghost-btn {
  font: inherit; font-size: 14px; color: var(--sub); background: none; cursor: pointer;
  border: 1px solid var(--dim); padding: 11px 18px; border-radius: 8px;
}
.ghost-btn:hover { color: var(--text); border-color: var(--sub); }
#again:disabled { filter: grayscale(1); opacity: 0.55; cursor: default; }

@media (max-width: 760px) {
  #opp-hud { gap: 8px; font-size: 10px; }
  #r-vs { grid-template-columns: 90px 1fr 1fr; }
}
