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

:root {
    --bg: #080808;
    --surface: #111111;
    --surface-hover: #1a1a1a;
    --border: #222222;
    --border-hover: #3a3a3a;
    --text: #e5e5e5;
    --text-muted: #888888;
    --accent: #00e5c7;
    --accent-dim: rgba(0, 229, 199, 0.15);
    --error: #ff4d4d;
    --success: #00e5c7;
    --rating-good: #7ee787;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-left: 80px;
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 48px 32px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 80px;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-item {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 20px;
    transition:
        background 0.15s,
        color 0.15s,
        transform 0.1s;
    margin-bottom: 6px;
    position: relative;
}

.sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    transform: scale(1.05);
}

.sidebar-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.sidebar-label {
    position: absolute;
    left: 60px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s,
        visibility 0.2s;
    pointer-events: none;
    box-shadow: var(--shadow);
}

.sidebar-item:hover .sidebar-label {
    opacity: 1;
    visibility: visible;
}

.theme-toggle {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.theme-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s;
}

.theme-dot:hover {
    transform: scale(1.25);
}

/* Header */
header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: none;
}

header h1 a {
    color: var(--text);
    text-decoration: none;
}

.btn-back {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s,
        background 0.15s;
    font-family: inherit;
    border-radius: 8px;
}

.btn-back:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--surface-hover);
}

/* Typography */
.page-title {
    font-size: 40px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-desc {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 40px;
    line-height: 1.6;
}

/* Grid & Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
    cursor: pointer;
    border-radius: 16px;
    transition:
        transform 0.2s,
        box-shadow 0.2s,
        border-color 0.2s;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.card:active {
    transform: translateY(-1px);
}

.card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Test Area */
.test-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 60vh;
    padding: 24px;
    overflow: hidden;
}

.center-stage {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.big-number {
    font-size: 96px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1;
}

.big-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Buttons */
.btn-primary {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 14px 48px;
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
    margin-top: 32px;
    border-radius: 12px;
    transition:
        border-color 0.15s,
        background 0.15s,
        transform 0.1s,
        box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    border-color: var(--text-muted);
    background: var(--surface-hover);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: scale(0.97);
}

.status-text {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Stats */
.stats-row {
    display: flex;
    gap: 48px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Rating Badges - Pill style */
.rating-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 24px;
    border: none;
}

.rating-top {
    color: var(--accent);
    background: var(--accent-dim);
}

.rating-good {
    color: var(--rating-good);
    background: rgba(126, 231, 135, 0.12);
}

.rating-avg {
    color: var(--text);
    background: var(--border);
}

.rating-below {
    color: var(--error);
    background: rgba(255, 77, 77, 0.12);
}

/* Info HUD */
.info-hud {
    position: absolute;
    top: 24px;
    right: 24px;
    text-align: right;
    pointer-events: none;
    z-index: 10;
}

.info-hud-item {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.info-hud-item span {
    color: var(--text);
    font-weight: 600;
}

/* Track & Aim Areas */
.track-area,
.aim-area {
    width: 100%;
    max-width: 800px;
    height: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    box-shadow: var(--shadow-sm);
}

.track-target,
.aim-target {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    user-select: none;
    pointer-events: none;
}

.track-target {
    width: 56px;
    height: 56px;
    background: var(--accent-dim);
    border: 2px solid var(--accent);
    box-shadow: 0 0 20px rgba(0, 229, 199, 0.2);
}

.aim-target {
    width: 56px;
    height: 56px;
    background: var(--accent);
    box-shadow: 0 0 16px rgba(0, 229, 199, 0.35);
    pointer-events: auto;
    cursor: pointer;
}

/* Memory Grid */
.memory-grid {
    display: grid;
    gap: 10px;
}

.memory-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    border-radius: 12px;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.1s;
}

.memory-cell:hover {
    border-color: var(--border-hover);
    transform: scale(1.02);
}

.memory-cell.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(0, 229, 199, 0.25);
}

.memory-cell.error {
    background: var(--error);
    border-color: var(--error);
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 72px);
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
}

.numpad-btn {
    height: 56px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    font-family: inherit;
    border-radius: 12px;
    transition:
        background 0.1s,
        border-color 0.1s,
        transform 0.1s;
}

.numpad-btn:hover {
    border-color: var(--border-hover);
    background: var(--surface-hover);
}

.numpad-btn:active {
    transform: scale(0.96);
}

.sequence-input {
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2em;
    color: var(--accent);
    min-height: 64px;
    margin-top: 16px;
}

/* Reaction Test */
.rt-box {
    width: 100%;
    max-width: 640px;
    height: 420px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.rt-label {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.rt-sub {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 12px;
    font-weight: 500;
}

/* Aim Layout */
.aim-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
    width: 100%;
}

.aim-preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.aim-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition:
        width 0.2s,
        height 0.2s;
    max-width: 500px;
    max-height: 360px;
    box-shadow: var(--shadow-sm);
}

.aim-preview-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.aim-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 280px;
}

.aim-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: 100%;
}

.aim-setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    justify-content: space-between;
}

.aim-setting-row label {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.aim-setting-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.aim-setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(0, 229, 199, 0.3);
}

.aim-setting-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(0, 229, 199, 0.3);
}

.aim-setting-row .aim-val {
    font-size: 14px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: right;
}

/* Number Bar */
.num-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px 48px;
    font-size: 56px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.25em;
    color: var(--text);
    border-radius: 12px;
    min-width: 320px;
    text-align: center;
    user-select: none;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

/* Sequence Grid */
.seq-grid {
    display: grid;
    grid-template-columns: repeat(3, 96px);
    gap: 12px;
}

.seq-cell {
    width: 96px;
    height: 96px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.1s;
}

.seq-cell:hover {
    border-color: var(--border-hover);
}

.seq-cell.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(0, 229, 199, 0.25);
}

.seq-cell.error {
    background: var(--error);
    border-color: var(--error);
}

/* Number Memory compare */
.nm-correct {
    color: var(--accent);
}

.nm-wrong {
    color: var(--error);
}

/* Schulte Grid */
.sg-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sg-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 480px;
    margin-bottom: 16px;
    padding: 0 8px;
}

.sg-hud-item {
    font-size: 16px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sg-hud-item span {
    color: var(--text);
    font-weight: 700;
}

.sg-grid {
    display: grid;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.sg-cell {
    width: 72px;
    height: 72px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    transition:
        background 0.1s,
        border-color 0.1s,
        transform 0.1s,
        color 0.1s;
}

.sg-cell:hover {
    border-color: var(--border-hover);
    transform: scale(1.03);
}

.sg-cell.sg-done {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.sg-cell.sg-wrong {
    background: rgba(255, 77, 77, 0.2);
    border-color: var(--error);
}

/* Utilities */
.hide {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        padding-left: 64px;
    }

    .sidebar {
        width: 64px;
        padding: 16px 0;
    }

    .container {
        padding: 24px 16px;
    }

    .page-title {
        font-size: 28px;
    }

    .aim-layout {
        flex-direction: column;
        gap: 32px;
    }

    .stats-row {
        gap: 24px;
    }

    .big-number {
        font-size: 64px;
    }

    .stat-value {
        font-size: 32px;
    }

    .track-area,
    .aim-area {
        height: 360px;
    }

    .rt-box {
        height: 320px;
    }

    .num-bar {
        font-size: 36px;
        padding: 16px 24px;
        min-width: 220px;
    }

    .seq-grid {
        grid-template-columns: repeat(3, 80px);
        gap: 8px;
    }

    .seq-cell {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .seq-grid {
        grid-template-columns: repeat(3, 72px);
        gap: 6px;
    }

    .seq-cell {
        width: 72px;
        height: 72px;
    }

    .numpad {
        grid-template-columns: repeat(3, 64px);
    }

    .numpad-btn {
        height: 48px;
    }

    .sg-cell {
        width: 56px;
        height: 56px;
        font-size: 18px;
    }
}
