:root {
    --bg-base: #0f1115;
    --bg-surface: #1c1f26;
    --bg-surface-hover: #2a2e37;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --error: #ef4444;
    --font-ui: system-ui, -apple-system, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    width: 100%;
    max-width: 500px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.hidden { display: none !important; }

/* Typography */
h1.title { font-size: 2.5rem; font-weight: 800; line-height: 1.1; margin-bottom: 1rem; }
h2.subtitle { color: var(--primary); font-size: 1rem; letter-spacing: 2px; }
.description { color: var(--text-muted); margin-bottom: 2.5rem; }

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    gap: 0.5rem;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg-surface-hover); }
.btn.outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn.outline:hover { color: var(--text-main); border-color: var(--text-muted); }
.btn.small { padding: 0.6rem; font-size: 0.875rem; }
.btn.danger { color: var(--error); border-color: rgba(239, 68, 68, 0.3); }
.btn-icon { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

.menu-buttons { display: flex; flex-direction: column; gap: 1rem; flex-grow: 1; justify-content: center; }
.row { display: flex; gap: 1rem; }

footer { text-align: center; color: var(--text-muted); font-size: 0.875rem; margin-top: auto; }
footer .credits { opacity: 0.6; font-size: 0.75rem; }

/* Game Screen */
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.badge { background: var(--primary); padding: 0.2rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: bold; }
#timer { font-family: var(--font-mono); font-weight: bold; color: var(--text-muted); }

.target-container { text-align: center; background: var(--bg-surface); padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px dashed var(--border); }
.target-container .label { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 2px; }
#target-word { font-family: var(--font-mono); font-size: 2rem; letter-spacing: 8px; color: var(--success); }

.word-chain { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem 0; }
.chain-item {
    background: var(--bg-surface);
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: 4px;
    font-weight: bold;
    border: 1px solid var(--border);
    animation: popIn 0.3s ease;
}
.chain-item.changed { border-color: var(--primary); color: var(--primary); }
.chain-arrow { text-align: center; color: var(--text-muted); font-size: 0.875rem; }

.input-section { margin-top: auto; background: var(--bg-surface); padding: 1rem; border-radius: var(--radius); }
.moves-label { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: bold; }
#word-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
#word-input {
    flex-grow: 1;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 1.2rem;
    text-transform: uppercase;
    text-align: center;
    outline: none;
}
#word-input:focus { border-color: var(--primary); }
.game-actions { display: flex; gap: 0.5rem; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 100; padding: 1rem; animation: fadeIn 0.2s ease; }
.modal-content { background: var(--bg-base); width: 100%; max-width: 400px; border-radius: var(--radius); padding: 2rem; position: relative; border: 1px solid var(--border); max-height: 90vh; overflow-y: auto; }
.modal-content.center { text-align: center; }
.btn-close { position: absolute; top: 1rem; right: 1rem; background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.stat-box { background: var(--bg-surface); padding: 1rem; border-radius: var(--radius-sm); text-align: center; display: flex; flex-direction: column; }
.stat-box span { font-size: 1.5rem; font-weight: bold; }
.stat-box label { font-size: 0.75rem; color: var(--text-muted); }

/* Toasts */
#toast-container { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--text-main); color: var(--bg-base); padding: 0.8rem 1.5rem; border-radius: var(--radius-sm); font-weight: bold; font-size: 0.875rem; animation: slideDown 0.3s ease, fadeOut 0.3s ease 2.7s forwards; }

/* Utilities */
.highlight { color: var(--primary); }
.victory-icon { font-size: 4rem; margin-bottom: 0.5rem; }
.victory-target { font-family: var(--font-mono); font-size: 2.5rem; color: var(--success); letter-spacing: 4px; margin-bottom: 1.5rem; }
.score-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 2rem; }
.score-item { background: var(--bg-surface); padding: 0.8rem; border-radius: var(--radius-sm); }
.score-item label { display: block; font-size: 0.75rem; color: var(--text-muted); }
.score-item span { font-size: 1.2rem; font-weight: bold; font-family: var(--font-mono); }
.victory-actions { display: flex; flex-direction: column; gap: 0.5rem; }

/* Animations */
@keyframes popIn { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }
@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes slideDown { 0% { transform: translateY(-20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { 100% { opacity: 0; visibility: hidden; } }
.shake { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }