/* ==================== HUMAN-FEELING DESIGN SYSTEM ==================== */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Patrick+Hand&family=Nunito:wght@400;600;700&display=swap');

:root {
    --ink: #1a1510;
    --paper: #faf6ef;
    --paper-dark: #f0ebe0;
    --paper-card: #fffdf8;
    --brown: #5c3d2e;
    --brown-light: #8b6f55;
    --terracotta: #c45b3a;
    --terracotta-soft: rgba(196, 91, 58, 0.1);
    --sage: #5a6f4e;
    --sage-light: rgba(90, 111, 78, 0.1);
    --gold: #d4a853;
    --gold-light: rgba(212, 168, 83, 0.15);
    --rust: #a0522d;
    
    --shadow-soft: 2px 3px 8px rgba(26, 21, 16, 0.08);
    --shadow-deep: 4px 6px 20px rgba(26, 21, 16, 0.12);
    --shadow-hover: 3px 5px 15px rgba(26, 21, 16, 0.15);
    
    --radius: 8px;
    --radius-lg: 14px;
}

[data-theme="light"] {
    --ink: #1a1510;
    --paper: #faf6ef;
    --paper-dark: #f0ebe0;
    --paper-card: #fffdf8;
    --brown: #5c3d2e;
    --brown-light: #8b6f55;
    --terracotta: #c45b3a;
    --terracotta-soft: rgba(196, 91, 58, 0.1);
    --sage: #5a6f4e;
    --sage-light: rgba(90, 111, 78, 0.1);
    --gold: #d4a853;
    --gold-light: rgba(212, 168, 83, 0.15);
    --rust: #a0522d;
    --shadow-soft: 1px 2px 6px rgba(26, 21, 16, 0.06);
    --shadow-deep: 2px 4px 12px rgba(26, 21, 16, 0.08);
    --shadow-hover: 3px 5px 16px rgba(26, 21, 16, 0.1);
}

[data-theme="dark"] {
    --ink: #e8dfd0;
    --paper: #1e1a15;
    --paper-dark: #2a2520;
    --paper-card: #282320;
    --brown: #c4a882;
    --brown-light: #a89070;
    --terracotta: #e07048;
    --terracotta-soft: rgba(224, 112, 72, 0.15);
    --sage: #7a9a68;
    --sage-light: rgba(122, 154, 104, 0.12);
    --gold: #e8c068;
    --gold-light: rgba(232, 192, 104, 0.12);
    --rust: #c07040;
    --shadow-soft: 2px 3px 10px rgba(0, 0, 0, 0.3);
    --shadow-deep: 4px 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 3px 5px 18px rgba(0, 0, 0, 0.5);
}

/* ==================== LOADING SCREEN ==================== */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--paper);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-cup {
    font-size: 3rem;
    animation: sip 2s ease-in-out infinite;
}

@keyframes sip {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(-3deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-4px) rotate(2deg); }
}

.loader-text {
    font-family: 'Patrick Hand', cursive;
    font-size: 1.3rem;
    color: var(--brown-light);
    letter-spacing: 1px;
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: var(--paper-dark);
    border-radius: 2px;
    overflow: hidden;
}

.loader-bar::after {
    content: '';
    display: block;
    width: 40%;
    height: 100%;
    background: var(--terracotta);
    border-radius: 2px;
    animation: loaderSlide 1.2s ease-in-out infinite;
}

@keyframes loaderSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ==================== FLOATING DECORATIONS ==================== */
.float-shape {
    position: fixed;
    pointer-events: none;
    opacity: 0.04;
    z-index: 0;
}

.float-shape-1 {
    top: 10%;
    left: 5%;
    animation: floatDrift 20s ease-in-out infinite;
}

.float-shape-2 {
    top: 60%;
    right: 5%;
    animation: floatDrift 25s ease-in-out infinite reverse;
}

.float-shape-3 {
    bottom: 15%;
    left: 10%;
    animation: floatDrift 18s ease-in-out infinite 5s;
}

.float-shape-4 {
    top: 30%;
    right: 8%;
    animation: floatDrift 22s ease-in-out infinite 3s;
}

@keyframes floatDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -15px) rotate(5deg); }
    50% { transform: translate(-10px, -30px) rotate(-3deg); }
    75% { transform: translate(15px, 10px) rotate(4deg); }
}

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

.hidden { display: none !important; }

body {
    font-family: 'Patrick Hand', 'Nunito', cursive, sans-serif;
    background-color: var(--paper);
    background-image: 
        url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4z'/%3E%3Cpath d='M44 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4z'/%3E%3Cpath d='M4 34v-4H2v4H0v2h4v4h2v-4h4v-2H4zM4 4V0H2v4H0v2h4v4h2V6h4V4H4z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
        radial-gradient(ellipse at 20% 10%, var(--terracotta-soft) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, var(--sage-light) 0%, transparent 50%);
    color: var(--ink);
    line-height: 1.75;
    min-height: 100vh;
    padding: 24px;
    overflow-x: hidden;
    transition: background-color 0.6s ease, color 0.4s ease;
}

/* ==================== NAVBAR ==================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--paper-card);
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 36px;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 12px;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.navbar:hover { transform: translateY(-1px); }

.nav-brand {
    font-family: 'Caveat', cursive;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brown);
    text-decoration: none;
    letter-spacing: -0.3px;
    transition: transform 0.2s ease;
}

.nav-brand:hover { transform: rotate(-2deg) scale(1.05); }

.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }

.nav-links a {
    color: var(--brown-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    transition: all 0.2s ease;
    padding: 6px 12px;
    border-radius: 6px;
    border-bottom: 2px solid transparent;
}

.nav-links a:hover {
    color: var(--terracotta);
    background: var(--terracotta-soft);
    transform: translateY(-1px);
}

.theme-toggle,
.sound-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--paper-dark);
    background: var(--paper-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--ink);
}

.theme-toggle:hover,
.sound-toggle:hover {
    transform: rotate(15deg) scale(1.15);
    border-color: var(--terracotta);
    color: var(--terracotta);
}

.sound-toggle.muted { opacity: 0.4; }

.icon.hidden { display: none; }

/* ==================== CONTAINER ==================== */
.container {
    max-width: 850px;
    margin: 0 auto;
    animation: bounceIn 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bounceIn {
    0% { opacity: 0; transform: translateY(40px) scale(0.95); }
    50% { opacity: 0.6; transform: translateY(-5px) scale(1.02); }
    75% { opacity: 0.9; transform: translateY(2px) scale(0.99); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== HAND-DRAWN DIVIDER ==================== */
.wavy-divider {
    width: 80px;
    height: 24px;
    margin: 8px auto 0;
    opacity: 0.6;
}

/* ==================== HEADER ==================== */
.header {
    text-align: center;
    margin-bottom: 48px;
    padding: 32px 24px;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--terracotta);
    border-radius: 2px;
}

.header h1 {
    font-family: 'Caveat', cursive;
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--brown);
    line-height: 1.1;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    animation: wiggle 3s ease-in-out infinite;
    transform-origin: center;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-1deg); }
    75% { transform: rotate(1deg); }
}

.header .subtitle {
    color: var(--brown-light);
    font-size: 1.15rem;
    font-family: 'Nunito', sans-serif;
    font-style: italic;
}

/* ==================== DIFFICULTY SECTION ==================== */
.difficulty-section {
    background: var(--paper-card);
    padding: 36px 32px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 32px;
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes slideUpBounce {
    0% { opacity: 0; transform: translateY(50px) scale(0.96); }
    60% { transform: translateY(-8px) scale(1.01); }
    80% { transform: translateY(3px) scale(0.99); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.difficulty-section h2 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.7rem;
    color: var(--brown);
    font-family: 'Caveat', cursive;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.difficulty-btn {
    background: var(--paper-dark);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 28px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    transition: left 0.5s ease;
}

.difficulty-btn:hover::before { left: 100%; }

.difficulty-btn:hover {
    transform: translateY(-6px) rotate(-1deg);
    border-color: var(--terracotta);
    box-shadow: var(--shadow-hover);
}

.difficulty-btn:active {
    transform: translateY(-2px) rotate(0deg);
    transition-duration: 0.1s;
}

.difficulty-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.difficulty-btn:hover .difficulty-indicator { transform: scale(1.3); }

.difficulty-indicator.easy {
    background: var(--sage);
    box-shadow: 0 0 12px var(--sage);
    animation: pulse 2s ease-in-out infinite;
}

.difficulty-indicator.medium {
    background: var(--gold);
    box-shadow: 0 0 12px var(--gold);
    animation: pulse 2s ease-in-out infinite 0.5s;
}

.difficulty-indicator.hard {
    background: var(--terracotta);
    box-shadow: 0 0 12px var(--terracotta);
    animation: pulse 2s ease-in-out infinite 1s;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 8px currentColor; }
    50% { box-shadow: 0 0 16px currentColor; }
}

.difficulty-name {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Caveat', cursive;
}

.difficulty-desc { font-size: 0.85rem; color: var(--brown-light); }

/* ==================== DURATION SECTION ==================== */
.duration-section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px dashed var(--paper-dark);
    text-align: center;
}

.duration-section h3 {
    margin-bottom: 18px;
    font-size: 1.1rem;
    color: var(--brown-light);
    font-family: 'Nunito', sans-serif;
}

.duration-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.duration-btn {
    padding: 12px 24px;
    background: var(--paper-dark);
    border: 2px solid transparent;
    border-radius: 6px;
    color: var(--brown-light);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 65px;
}

.duration-btn:hover {
    background: var(--paper-card);
    border-color: var(--terracotta);
    color: var(--terracotta);
    transform: translateY(-2px) rotate(-1deg);
}

.duration-btn.active {
    border-color: var(--terracotta);
    color: var(--terracotta);
    background: var(--terracotta-soft);
    box-shadow: 0 0 0 3px var(--terracotta-soft);
}

.duration-btn:active { transform: scale(0.95); }

/* ==================== GAME SECTION ==================== */
.game-section { animation: slideUpBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ==================== SPEED VISUALIZER ==================== */
.speed-viz {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 40px;
    margin-bottom: 20px;
    padding: 0 8px;
}

.speed-bar {
    width: 4px;
    border-radius: 2px;
    background: var(--terracotta);
    transition: height 0.15s ease;
    min-height: 2px;
    opacity: 0.5;
}

.speed-bar.active {
    opacity: 1;
}

.speed-bar.peak {
    background: var(--gold);
    opacity: 1;
}

/* ==================== STATS BAR ==================== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-item {
    background: var(--paper-card);
    padding: 22px 16px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.3s ease;
    position: relative;
}

.stat-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--terracotta);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.stat-item:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.stat-item:hover::after { width: 40px; }

.stat-label {
    color: var(--brown-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--terracotta);
    font-family: 'Caveat', cursive;
    line-height: 1.2;
    transition: transform 0.15s ease;
}

.stat-value.bump { animation: statBump 0.3s ease; }

@keyframes statBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ==================== TEXT DISPLAY ==================== */
.text-display {
    background: var(--paper-card);
    padding: 36px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    font-size: 1.5rem;
    line-height: 2.2;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-soft);
    min-height: 200px;
    font-family: 'Patrick Hand', cursive;
    position: relative;
    overflow: hidden;
}

.text-display::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        transparent, transparent 27px,
        rgba(0,0,0,0.03) 27px, rgba(0,0,0,0.03) 28px
    );
    pointer-events: none;
}

.text-display .char {
    position: relative;
    transition: all 0.12s ease;
}

.text-display .char.correct { color: var(--sage); }

.text-display .char.incorrect {
    color: var(--terracotta);
    background: var(--terracotta-soft);
    border-radius: 2px;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.text-display .char.current {
    background: var(--terracotta);
    color: var(--paper);
    animation: currentBlink 1s ease-in-out infinite;
    border-radius: 2px;
}

@keyframes currentBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==================== INPUT SECTION ==================== */
.input-section { margin-bottom: 20px; }

.text-input {
    width: 100%;
    background: var(--paper-card);
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius);
    padding: 20px;
    font-size: 1.1rem;
    color: var(--ink);
    font-family: 'Patrick Hand', cursive;
    resize: none;
    height: 120px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.text-input:focus {
    outline: none;
    border-color: var(--terracotta);
    box-shadow: 0 0 0 4px var(--terracotta-soft), var(--shadow-deep);
    transform: scale(1.005);
}

.text-input::placeholder {
    color: var(--brown-light);
    font-style: italic;
}

/* ==================== BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 26px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:active { transform: scale(0.95) !important; }

.btn-primary {
    background: var(--terracotta);
    color: white;
    border-color: var(--terracotta);
}

.btn-primary:hover {
    transform: translateY(-3px) rotate(-1deg);
    box-shadow: 0 6px 20px var(--terracotta-soft);
    background: #b84f32;
}

.btn-secondary {
    background: var(--paper-dark);
    color: var(--ink);
    border-color: var(--paper-dark);
}

.btn-secondary:hover {
    background: var(--paper-card);
    border-color: var(--brown-light);
    transform: translateY(-3px) rotate(1deg);
    box-shadow: var(--shadow-hover);
}

/* ==================== RESULTS SECTION ==================== */
.results-section { animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.results-card {
    background: var(--paper-card);
    padding: 40px 32px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-deep);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.results-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, var(--gold-light) 0%, transparent 50%);
    opacity: 0.3;
    pointer-events: none;
}

.results-card h2 {
    font-size: 2rem;
    margin-bottom: 28px;
    color: var(--brown);
    font-family: 'Caveat', cursive;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.result-item {
    background: var(--paper-dark);
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.result-item:hover {
    transform: translateY(-4px) rotate(-0.5deg);
    box-shadow: var(--shadow-hover);
}

.result-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--terracotta-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--terracotta);
    margin-bottom: 8px;
    border: 2px solid var(--terracotta);
}

.result-icon-wrapper.error {
    background: rgba(160, 82, 45, 0.1);
    color: var(--rust);
    border-color: var(--rust);
}

.result-icon { width: 28px; height: 28px; }

.result-label {
    color: var(--brown-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}

.result-value {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--terracotta);
    font-family: 'Caveat', cursive;
}

.result-unit { color: var(--brown-light); font-size: 0.85rem; }
.result-content { display: flex; flex-direction: column; gap: 4px; }

.result-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== HIGHSCORES SECTION ==================== */
.highscores-section {
    background: var(--paper-card);
    padding: 32px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-top: 32px;
}

.highscores-section h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.7rem;
    color: var(--brown);
    font-family: 'Caveat', cursive;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.highscores-section h2 .icon {
    color: var(--gold);
    animation: spin 4s linear infinite;
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.highscores-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: var(--paper-dark);
    border: 2px solid transparent;
    border-radius: 6px;
    color: var(--brown-light);
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
}

.tab-btn:hover {
    background: var(--paper-card);
    color: var(--terracotta);
    transform: translateY(-2px);
}

.tab-btn.active {
    border-color: var(--terracotta);
    color: var(--terracotta);
    background: var(--terracotta-soft);
}

.highscores-list { min-height: 100px; }

.no-scores {
    text-align: center;
    color: var(--brown-light);
    padding: 40px 20px;
    font-style: italic;
}

.score-item {
    background: var(--paper-dark);
    padding: 16px 20px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.25s ease;
    border-left: 3px solid transparent;
}

.score-item:hover {
    transform: translateX(6px);
    background: var(--paper-card);
    border-left-color: var(--terracotta);
}

.score-rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--terracotta);
    font-family: 'Caveat', cursive;
    min-width: 40px;
}

.score-details { flex: 1; display: flex; gap: 20px; flex-wrap: wrap; }
.score-detail { display: flex; flex-direction: column; }
.score-detail-label { font-size: 0.7rem; color: var(--brown-light); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Nunito', sans-serif; }
.score-detail-value { font-size: 1rem; font-weight: 600; color: var(--ink); }
.score-date { color: var(--brown-light); font-size: 0.8rem; }

/* ==================== TOAST NOTIFICATION ==================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--paper-card);
    border: 2px solid var(--terracotta);
    border-radius: var(--radius);
    padding: 14px 24px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    color: var(--ink);
    box-shadow: var(--shadow-deep);
    z-index: 1000;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show { transform: translateX(0); }

.toast.toast-success { border-color: var(--sage); }
.toast.toast-error { border-color: var(--rust); }

/* ==================== WPM GAUGE ==================== */
.wpm-gauge {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    position: relative;
}

.wpm-gauge svg {
    transform: rotate(-90deg);
}

.wpm-gauge circle {
    fill: none;
    stroke-width: 4;
}

.wpm-gauge .gauge-bg {
    stroke: var(--paper-dark);
}

.wpm-gauge .gauge-fill {
    stroke: var(--terracotta);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.wpm-gauge .gauge-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--terracotta);
}

/* ==================== FOOTER ==================== */
.footer {
    text-align: center;
    margin-top: 48px;
    padding: 24px;
    color: var(--brown-light);
    font-size: 0.85rem;
    border-top: 1px dashed var(--paper-dark);
}

/* ==================== PAGE STYLES ==================== */
.page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.page-container h1 {
    font-size: 2.6rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--brown);
    font-family: 'Caveat', cursive;
}

.page-container .page-subtitle {
    color: var(--brown-light);
    font-size: 1.1rem;
    margin-bottom: 32px;
    font-style: italic;
}

.page-section {
    background: var(--paper-card);
    padding: 32px;
    border: 2px solid var(--paper-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.page-section:hover { box-shadow: var(--shadow-hover); }

.page-section h2 {
    font-size: 1.5rem;
    color: var(--brown);
    margin-bottom: 14px;
    font-family: 'Caveat', cursive;
}

.page-section p {
    color: var(--ink);
    line-height: 1.85;
    margin-bottom: 14px;
}

.page-section ul, .page-section ol {
    margin: 14px 0 14px 24px;
    color: var(--ink);
    line-height: 2;
}

.page-section li { margin-bottom: 6px; }

.page-section code {
    background: var(--paper-dark);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.88rem;
    color: var(--terracotta);
    font-family: 'Nunito', monospace;
}

.page-section pre {
    background: var(--paper-dark);
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 14px 0;
}

.page-section pre code { background: none; padding: 0; color: var(--ink); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    body { padding: 16px; }
    .header h1 { font-size: 2.4rem; }
    .navbar { flex-direction: column; align-items: center; }
    .nav-links { justify-content: center; }
    .difficulty-section { padding: 24px; }
    .difficulty-buttons { grid-template-columns: 1fr; }
    .text-display { padding: 24px; font-size: 1.2rem; }
    .stats-bar { grid-template-columns: 1fr; }
    .results-stats { grid-template-columns: 1fr; }
    .result-value { font-size: 2rem; }
    .action-buttons { flex-direction: column; }
    .btn { width: 100%; }
    .duration-buttons { gap: 10px; }
    .duration-btn { padding: 10px 18px; min-width: 60px; }
    .page-container h1 { font-size: 1.8rem; }
    .wpm-gauge { width: 60px; height: 60px; }
    .speed-viz { height: 30px; }
}

@media (max-width: 480px) {
    .header h1 { font-size: 2rem; }
    .text-display { font-size: 1rem; padding: 20px; }
    .difficulty-section h2,
    .results-card h2,
    .highscores-section h2,
    .page-container h1 { font-size: 1.5rem; }
}

@media print {
    body { background: white; color: black; }
    .action-buttons, .footer, .theme-toggle, .sound-toggle, .navbar { display: none; }
    .float-shape { display: none !important; }
}
