:root {
    --bg-color: #0b0f19;
    --bg-grid: rgba(148, 163, 184, 0.05);
    --text-main: #f8fafc;
    --text-muted: #64748b;
    --accent-gold: #fbbf24;
    --blood-red: #ef4444;
    --steel-white: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 50px 50px;
    color: var(--text-main);
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; overflow: hidden;
}

body.in-game .fixed-ui { display: none !important; }
.hidden { display: none !important; }
.app-container { width: 100%; max-width: 600px; padding: 2rem; z-index: 10; position: relative; }

/* --- SIDE PANELS (Fills Empty Space) --- */
.side-panel { position: fixed; top: 50%; transform: translateY(-50%); z-index: 5; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
body.in-game .side-panel.left-panel { opacity: 1; pointer-events: auto; }

.left-panel { left: 3rem; width: 250px; }
.panel-header { font-size: 0.8rem; font-weight: 800; letter-spacing: 3px; color: var(--text-muted); margin-bottom: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 0.5rem; }

.achievement-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.ach-item { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); padding: 1rem; border-radius: 8px; transition: all 0.3s; display: flex; flex-direction: column; opacity: 0.5; filter: grayscale(1); }
.ach-item.unlocked { opacity: 1; filter: grayscale(0); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.05); }
.ach-title { font-size: 0.9rem; font-weight: 800; color: var(--text-main); margin-bottom: 0.2rem; }
.ach-item.unlocked .ach-title { color: var(--accent-gold); }
.ach-desc { font-size: 0.75rem; color: var(--text-muted); }

/* Kanji Dynamic Pop Effect */
.right-panel { right: 4rem; text-align: center; }
.atmospheric-kanji {
    font-size: 8rem; font-weight: 900; line-height: 1;
    opacity: 0; /* Fully hidden by default */
    transform: translateY(-50%) scale(0.9);
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.1s ease;
}

/* The state added when you strike */
.atmospheric-kanji.reveal { opacity: 0.8; transform: translateY(-50%) scale(1.05); }

/* Random Color Themes */
.color-red { color: var(--blood-red); text-shadow: 0 0 40px rgba(239, 68, 68, 0.6); }
.color-gold { color: var(--accent-gold); text-shadow: 0 0 40px rgba(251, 191, 36, 0.6); }
.color-silver { color: #94a3b8; text-shadow: 0 0 40px rgba(148, 163, 184, 0.6); }
.color-white { color: #ffffff; text-shadow: 0 0 40px rgba(255, 255, 255, 0.6); }

.kanji-sub { display: block; font-size: 1rem; font-weight: 800; letter-spacing: 10px; margin-top: 1rem; opacity: 0.8; color: var(--text-main); text-shadow: none; }

@media (max-width: 1200px) { .side-panel { display: none !important; } }

/* --- TOAST NOTIFICATIONS --- */
#toast-container { position: fixed; top: 2rem; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 1rem; pointer-events: none; }
.toast { background: #1e293b; border-left: 4px solid var(--accent-gold); padding: 1rem 1.5rem; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); animation: toastSlide 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.toast-title { font-size: 0.8rem; font-weight: 800; letter-spacing: 2px; color: var(--accent-gold); margin-bottom: 0.25rem; text-transform: uppercase; }
.toast-desc { font-size: 1rem; font-weight: 600; color: var(--steel-white); }
@keyframes toastSlide { 0% { opacity: 0; transform: translateY(-20px); } 100% { opacity: 1; transform: translateY(0); } }

/* --- FIXED GLOBAL UI & LOBBY --- */
.fixed-top-right { position: fixed; top: 2rem; right: 2rem; z-index: 50; background: none; border: none; color: var(--text-muted); font-family: 'Outfit'; font-weight: 800; font-size: 0.9rem; letter-spacing: 2px; cursor: pointer; transition: color 0.2s; text-transform: uppercase; }
.fixed-top-right:hover { color: var(--text-main); }
.fixed-bottom-right { position: fixed; bottom: 2rem; right: 2rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; text-align: right; }
.lobby-footer a { color: rgba(100, 116, 139, 0.6); font-size: 0.8rem; font-weight: 800; letter-spacing: 2px; text-decoration: none; transition: color 0.2s; text-transform: uppercase; }
.lobby-footer a:hover { color: var(--accent-gold); }

/* --- ABOUT MODAL --- */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(11, 15, 25, 0.9); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 1; transition: opacity 0.2s ease; }
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-content { background: #1e293b; padding: 2.5rem; border-radius: 16px; border: 1px solid var(--accent-gold); max-width: 400px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.8); }
.modal-content h2 { font-size: 2rem; color: var(--accent-gold); margin-bottom: 1rem; letter-spacing: -1px; }
.modal-content p { color: var(--steel-white); margin-bottom: 2rem; line-height: 1.6; font-size: 1.1rem; }

/* --- LOBBY STYLES --- */
#lobby-view { text-align: center; animation: fadeIn 0.5s ease; }
.lobby-header h1 { font-size: 3.5rem; font-weight: 900; letter-spacing: -2px; margin-bottom: 0; }
.lobby-header h1 .highlight { color: var(--blood-red); }
.lobby-header p { font-size: 1.2rem; color: var(--accent-gold); letter-spacing: 4px; text-transform: uppercase; margin-bottom: 1.5rem; }
.best-score-display { background: rgba(255,255,255,0.05); display: inline-block; padding: 0.5rem 1.5rem; border-radius: 20px; font-weight: 800; color: var(--steel-white); margin-bottom: 3rem; }
.mode-selection { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }
.mode-btn { background: rgba(255,255,255,0.03); border: 2px solid rgba(255,255,255,0.1); padding: 1.5rem; border-radius: 12px; cursor: pointer; text-align: left; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.mode-btn h3 { font-family: 'Outfit'; font-size: 1.5rem; color: var(--text-main); font-weight: 800; margin-bottom: 0.25rem; }
.mode-btn p { font-family: 'Outfit'; font-size: 0.9rem; color: var(--text-muted); }
.mode-btn:hover { transform: translateY(-3px); border-color: var(--accent-gold); background: rgba(251, 191, 36, 0.05); }
.mode-btn.hard:hover { border-color: var(--blood-red); background: rgba(239, 68, 68, 0.05); }
.instructions { background: rgba(239, 68, 68, 0.05); border-left: 4px solid var(--blood-red); padding: 1rem 1.5rem; border-radius: 0 8px 8px 0; color: var(--steel-white); font-size: 0.9rem; line-height: 1.6; text-align: left; }
.instructions strong { color: var(--accent-gold); }
.instructions .highlight-red { color: var(--blood-red); font-weight: bold; }

/* --- GAME VIEW STYLES --- */
.top-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.current-path { font-size: 0.9rem; font-weight: 800; letter-spacing: 3px; color: var(--text-muted); text-transform: uppercase; }
.ui-btn { background: transparent; color: var(--text-muted); border: 2px solid var(--text-muted); padding: 0.5rem 1rem; font-family: 'Outfit'; font-weight: 800; cursor: pointer; border-radius: 8px; transition: all 0.2s; text-transform: uppercase; }
.ui-btn:hover { color: var(--bg-color); background: var(--text-muted); }

.stat-box.mini { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); }
.stat-value { font-size: 1.5rem; font-weight: 900; }
.streak-value { color: var(--accent-gold); }

#game-pad { width: 100%; min-height: 400px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; cursor: crosshair; border-radius: 16px; position: relative; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); }
.samurai-face { display: flex; gap: 20px; margin-bottom: 20px; transition: all 0.3s ease; }
.eye { width: 40px; height: 10px; background: var(--text-muted); border-radius: 50%; box-shadow: 0 0 10px rgba(0,0,0,0); transition: all 0.1s ease; }
.state-idle .eye { background: var(--text-muted); transform: scaleY(0.2); }
.state-waiting .eye { background: var(--accent-gold); box-shadow: 0 0 15px var(--accent-gold); transform: scaleY(0.5) rotate(-5deg); }
.state-waiting .right-eye { transform: scaleY(0.5) rotate(5deg); }
.state-feint .eye { background: var(--steel-white); box-shadow: 0 0 20px var(--steel-white); transform: scaleY(1.2) translateY(-5px); }
.state-ready .eye { background: var(--blood-red); box-shadow: 0 0 30px var(--blood-red); transform: scaleY(1.5) rotate(-10deg); }
.state-ready .right-eye { transform: scaleY(1.5) rotate(10deg); }
.state-dead .eye { background: #111; box-shadow: none; transform: scaleY(0.1) translateY(10px); }

.pad-content { z-index: 2; pointer-events: none; display: flex; flex-direction: column; align-items: center; }
h2#main-text { font-size: 3.5rem; font-weight: 900; margin-bottom: 0.5rem; letter-spacing: -2px; text-transform: uppercase; transition: color 0.2s; }
p#sub-text { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 4px; }
.state-idle #main-text { color: var(--text-main); }
.state-waiting #main-text { color: var(--text-muted); }
.state-feint #main-text { color: var(--accent-gold); transform: translateX(5px); }
.state-ready #main-text { color: var(--blood-red); text-shadow: 0 0 30px rgba(239, 68, 68, 0.6); font-size: 6rem; }
.state-dead #main-text { color: #475569; text-decoration: line-through; }

.action-btn { pointer-events: auto; margin-top: 1.5rem; background: rgba(239, 68, 68, 0.1); color: var(--blood-red); border: 2px solid var(--blood-red); padding: 0.75rem 1.5rem; font-family: 'Outfit'; font-weight: 800; font-size: 1rem; cursor: pointer; border-radius: 8px; transition: all 0.2s; text-transform: uppercase; }
.action-btn:hover { background: var(--blood-red); color: var(--text-main); }

#flash-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: white; opacity: 0; pointer-events: none; z-index: 900; }
.flash-active { animation: flashAnim 0.3s ease-out forwards; }
.blood-flash { background: var(--blood-red) !important; animation: flashAnim 0.5s ease-out forwards; }
#slash-line { position: fixed; top: 50%; left: 0; width: 100%; height: 6px; background: var(--accent-gold); box-shadow: 0 0 20px var(--accent-gold); transform: scaleX(0) rotate(-3deg) translateY(-50%); transform-origin: center; opacity: 0; pointer-events: none; z-index: 1000; }
.slash-active { animation: sliceAnim 0.25s cubic-bezier(0.1, 1, 0.2, 1) forwards; }
.shake-heavy { animation: shakeHeavy 0.3s cubic-bezier(.36,.07,.19,.97) both; }
.shake-violent { animation: shakeViolent 0.4s cubic-bezier(.36,.07,.19,.97) both; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flashAnim { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sliceAnim { 0% { transform: scaleX(0) rotate(-3deg); opacity: 1; } 100% { transform: scaleX(1) rotate(-3deg); opacity: 0; } }
@keyframes shakeHeavy { 0%, 100% { transform: translate3d(0,0,0); } 20% { transform: translate3d(-6px, 4px, 0); } 40% { transform: translate3d(6px, -4px, 0); } 60% { transform: translate3d(-4px, -6px, 0); } }
@keyframes shakeViolent { 0%, 100% { transform: translate3d(0,0,0); } 10% { transform: translate3d(-15px, 10px, 0); } 30% { transform: translate3d(15px, -10px, 0); } 50% { transform: translate3d(-10px, -15px, 0); } }