/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Prevent double-tap zoom on mobile */
html {
    touch-action: manipulation;
}

button, a, input, select, label {
    touch-action: manipulation;
}

:root {
    --bg-primary: #0d0d14;
    --bg-secondary: #14141f;
    --bg-tertiary: #1a1a2e;
    --bg-cell: #1e2a3a;
    --bg-cell-alt: #243447;
    --bg-cell-hover: #2a3f55;
    --bg-cell-highlight: #2a3d52;
    --bg-cell-highlight-alt: #324a5e;
    --text-primary: #eaeaea;
    --text-secondary: #8892a0;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --accent-glow: rgba(233, 69, 96, 0.3);
    --filled: #4ecca3;
    --filled-glow: rgba(78, 204, 163, 0.2);
    --marked: #ff6b6b;
    --correct: #4ecca3;
    --incorrect: #ff4757;
    --completed: #4ecca3;
    --border: #2a2a4a;
    --border-strong: #4a4a6a;
    --ripple-fill: rgba(78, 204, 163, 0.15);
    --ripple-mark: rgba(255, 107, 107, 0.12);
    --ripple-error: rgba(255, 71, 87, 0.2);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --bg-cell: #d0d8e0;
    --bg-cell-alt: #c5cdd5;
    --bg-cell-hover: #b8c4d0;
    --bg-cell-highlight: #c8d4e0;
    --bg-cell-highlight-alt: #bcc8d8;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5060;
    --accent: #d63850;
    --accent-hover: #e94560;
    --accent-glow: rgba(214, 56, 80, 0.2);
    --filled: #2d9d78;
    --filled-glow: rgba(45, 157, 120, 0.15);
    --marked: #d63850;
    --correct: #2d9d78;
    --incorrect: #d63850;
    --completed: #2d9d78;
    --border: #b8c4d0;
    --border-strong: #98a4b0;
    --ripple-fill: rgba(45, 157, 120, 0.25);
    --ripple-mark: rgba(214, 56, 80, 0.2);
    --ripple-error: rgba(214, 56, 80, 0.25);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --bg-primary: #0a1628;
    --bg-secondary: #0f2137;
    --bg-tertiary: #142d4a;
    --bg-cell: #1a3a5c;
    --bg-cell-alt: #1f4570;
    --bg-cell-hover: #2a5080;
    --bg-cell-highlight: #234b6e;
    --bg-cell-highlight-alt: #2a567a;
    --accent: #00b4d8;
    --accent-hover: #48cae4;
    --accent-glow: rgba(0, 180, 216, 0.3);
    --filled: #00b4d8;
    --filled-glow: rgba(0, 180, 216, 0.2);
    --correct: #00b4d8;
    --completed: #00b4d8;
    --border: #1e4976;
    --border-strong: #2a6090;
    --ripple-fill: rgba(0, 180, 216, 0.15);
    --ripple-mark: rgba(255, 107, 107, 0.12);
    --ripple-error: rgba(255, 71, 87, 0.2);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --bg-primary: #1a0a14;
    --bg-secondary: #2a1020;
    --bg-tertiary: #3a1830;
    --bg-cell: #4a2040;
    --bg-cell-alt: #5a2850;
    --bg-cell-hover: #6a3060;
    --bg-cell-highlight: #5a2848;
    --bg-cell-highlight-alt: #6a3058;
    --accent: #ff6b9d;
    --accent-hover: #ff8fb3;
    --accent-glow: rgba(255, 107, 157, 0.3);
    --filled: #ffa94d;
    --filled-glow: rgba(255, 169, 77, 0.2);
    --marked: #ff6b9d;
    --correct: #ffa94d;
    --completed: #ffa94d;
    --border: #5a2850;
    --border-strong: #7a3870;
    --ripple-fill: rgba(255, 169, 77, 0.15);
    --ripple-mark: rgba(255, 107, 157, 0.12);
    --ripple-error: rgba(255, 71, 87, 0.2);
}

/* Forest Theme */
[data-theme="forest"] {
    --bg-primary: #0a140a;
    --bg-secondary: #102010;
    --bg-tertiary: #183018;
    --bg-cell: #204020;
    --bg-cell-alt: #285028;
    --bg-cell-hover: #306030;
    --bg-cell-highlight: #285028;
    --bg-cell-highlight-alt: #306030;
    --accent: #7cb342;
    --accent-hover: #9ccc65;
    --accent-glow: rgba(124, 179, 66, 0.3);
    --filled: #7cb342;
    --filled-glow: rgba(124, 179, 66, 0.2);
    --marked: #ef5350;
    --correct: #7cb342;
    --completed: #7cb342;
    --border: #2a4a2a;
    --border-strong: #3a6a3a;
    --ripple-fill: rgba(124, 179, 66, 0.15);
    --ripple-mark: rgba(239, 83, 80, 0.12);
    --ripple-error: rgba(255, 71, 87, 0.2);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
}

/* Main app layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #ff8a80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input[type="number"], input[type="text"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.875rem;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="number"] {
    width: 50px;
    text-align: center;
}

#seed-input {
    width: 80px;
    font-family: monospace;
}

.custom-size {
    display: flex;
    align-items: center;
    gap: 4px;
}

.custom-size span {
    color: var(--text-secondary);
}

.seed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Button groups for visual organization */
.seed-row .btn {
    transition: transform 0.1s, box-shadow 0.2s;
}

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

/* Primary action buttons */
#new-btn, #daily-btn {
    font-weight: 600;
}

/* Session buttons */
#speedrun-btn, #timed-btn {
    border: 1px solid var(--border);
}

/* Icon-only buttons */
.btn-icon {
    padding: 6px 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-cell-hover);
}

.btn-icon {
    padding: 6px;
    min-width: 32px;
}

.btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
}

/* Daily button special styling */
.btn-daily {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.btn-daily:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Mobile header actions */
.mobile-header-actions {
    display: none;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.btn-mobile {
    padding: 8px 10px;
    border-radius: 8px;
}

.btn-mobile svg {
    width: 18px;
    height: 18px;
}

/* Mobile menu button */
.menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.menu-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Settings panel (mobile) */
.settings-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 200;
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.settings-panel.show {
    display: flex;
}

.settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.settings-panel-header h2 {
    font-size: 1.25rem;
    color: var(--accent);
}

.close-settings {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

/* 2-column grid for game controls */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.settings-panel .control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-panel .control-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-panel select,
.settings-panel input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
}

/* Custom size inputs */
.custom-size-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-size-inputs input {
    flex: 1;
    min-width: 60px;
    padding-right: 4px;
}

/* Hide number input spinners on desktop to prevent text overlap */
.custom-size-inputs input::-webkit-outer-spin-button,
.custom-size-inputs input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-size-inputs input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.custom-size-inputs span {
    color: var(--text-secondary);
}

/* Action buttons 2x2 grid */
.settings-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 4px;
}

.settings-panel .settings-buttons .btn {
    width: 100%;
    padding: 12px 8px;
    font-size: 0.9rem;
}

/* Settings section */
.settings-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
}

.settings-section h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Theme row */
.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.theme-row label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.theme-row select {
    flex: 1;
    max-width: 140px;
    padding: 8px 10px;
    font-size: 0.9rem;
}

/* Toggles in 2 columns */
.toggles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}

.toggles-grid .toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.toggles-grid .toggle-group label:first-child {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Game container */
.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    overflow: hidden;
    min-height: 0;
}

/* Game area - the puzzle grid with clues */
.game-area {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "corner col-clues"
        "row-clues grid";
    gap: 2px;
    background: var(--border);
    touch-action: none;
    -webkit-touch-callout: none;
}

.corner {
    grid-area: corner;
    background: var(--bg-secondary);
    min-width: 20px;
    min-height: 20px;
}

/* Column clues (top) */
.col-clues {
    grid-area: col-clues;
    display: flex;
    background: var(--bg-secondary);
    gap: 1px;
}

.clue-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 4px 2px;
    gap: 1px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.2s;
    overflow: hidden;
    box-sizing: border-box;
}

.clue-col.completed {
    color: var(--completed);
}

.clue-col.completed span {
    text-decoration: line-through;
    opacity: 0.7;
}

.clue-col.highlight {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Individual clue numbers that are matched/confirmed */
.clue-col span.matched {
    text-decoration: line-through;
    opacity: 0.5;
}

/* When column is fully completed, override with green */
.clue-col.completed span {
    color: var(--completed);
    opacity: 0.7;
}

/* Row clues (left) */
.row-clues {
    grid-area: row-clues;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    gap: 1px;
}

.clue-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 2px 4px;
    gap: 4px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.2s;
    overflow: hidden;
    box-sizing: border-box;
}

.clue-row.completed {
    color: var(--completed);
}

.clue-row.completed span {
    text-decoration: line-through;
    opacity: 0.7;
}

.clue-row.highlight {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Individual clue numbers that are matched/confirmed */
.clue-row span.matched {
    text-decoration: line-through;
    opacity: 0.5;
}

/* When row is fully completed, override with green */
.clue-row.completed span {
    color: var(--completed);
    opacity: 0.7;
}

/* The puzzle grid */
.grid {
    grid-area: grid;
    display: grid;
    background: var(--border);
    gap: 1px;
}

.cell {
    background: var(--bg-cell);
    cursor: pointer;
    transition: background 0.15s ease-out, transform 0.1s ease-out;
    position: relative;
    will-change: background;
}

/* Alternating 5x5 section backgrounds for better visibility */
.cell.section-alt {
    background: var(--bg-cell-alt, #243447);
}

.cell:hover {
    background: var(--bg-cell-hover);
}

/* Row/column highlight on hover */
.cell.row-highlight,
.cell.col-highlight {
    background: var(--bg-cell-highlight, #2a3d52);
}

.cell.row-highlight.col-highlight {
    background: var(--bg-cell-hover);
}

.cell.section-alt.row-highlight,
.cell.section-alt.col-highlight {
    background: var(--bg-cell-highlight-alt, #324a5e);
}

.cell.filled {
    background: var(--filled);
}

.cell.filled.row-highlight,
.cell.filled.col-highlight {
    background: var(--filled);
    filter: brightness(1.15);
}

/* Keyboard selection indicator */
.cell.keyboard-selected {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
    z-index: 10;
}

.cell.keyboard-selected.filled {
    outline-color: var(--text-primary);
}

.cell.marked {
    background: var(--bg-cell);
}

.cell.marked.section-alt {
    background: var(--bg-cell-alt, #243447);
}

.cell.marked::before,
.cell.marked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 55%;
    height: 3px;
    background: var(--marked);
    border-radius: 2px;
}

.cell.marked::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cell.marked::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.cell.correct {
    background: var(--correct);
}

.cell.incorrect {
    background: var(--incorrect);
    animation: shake 0.3s ease-out;
}

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

/* Strong grid lines every 5 cells */
.cell.border-left {
    box-shadow: inset 3px 0 0 0 var(--border-strong);
}

.cell.border-top {
    box-shadow: inset 0 3px 0 0 var(--border-strong);
}

.cell.border-left.border-top {
    box-shadow: inset 3px 0 0 0 var(--border-strong), inset 0 3px 0 0 var(--border-strong);
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 1rem;
}

.stat-value.mistakes {
    color: var(--marked);
}

.scoreboard-btn {
    margin-left: auto;
}

/* Progress bar */
.progress-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar {
    width: 80px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: var(--filled);
    border-radius: 3px;
    transition: width 0.3s ease-out;
    width: 0%;
}

.progress-text {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 45px;
}

/* Mobile toggle at bottom */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 2px solid var(--border);
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
}

.mode-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 12px 20px;
    background: linear-gradient(135deg, #4ecca3 0%, #45b393 100%);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(78, 204, 163, 0.3);
}

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

.mode-toggle-btn.mark-mode {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.mode-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    padding: 6px;
}

.mode-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.mode-label {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.mode-hint {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.7;
    margin-left: 4px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    padding: 16px;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
    width: 360px;
    border: 1px solid var(--border);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--accent);
}

.modal-content p {
    margin-bottom: 8px;
    font-size: 1rem;
}

#solution-count-display {
    color: var(--accent);
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 4px;
}

#solutions-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 8px 0;
}

#solution-count {
    color: var(--accent);
    font-weight: 600;
}

#new-record {
    color: var(--filled);
    font-weight: 700;
    font-size: 1.25rem;
    margin: 12px 0;
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

/* Win Modal - Pattern Preview */
.win-content {
    width: auto;
    max-width: 95%;
}

/* Confirmation modal */
.confirm-content {
    width: 280px;
}

.confirm-content h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.confirm-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.confirm-content .modal-actions {
    gap: 12px;
}

.confirm-content .btn {
    min-width: 80px;
}

.pattern-preview {
    display: grid;
    gap: 1px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin: 16px auto;
    padding: 1px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pattern-cell {
    aspect-ratio: 1;
    transition: background 0.3s ease-out;
}

.pattern-cell.filled {
    background: var(--filled);
}

.pattern-cell.empty {
    background: var(--bg-tertiary);
}

/* Staggered reveal animation for pattern */
.pattern-cell.reveal {
    animation: pattern-reveal 0.4s ease-out backwards;
}

@keyframes pattern-reveal {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.win-stats {
    margin: 16px 0;
}

.win-stats p {
    margin: 6px 0;
}

/* Win modal login prompt */
.win-login-prompt {
    margin: 16px 0;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px dashed var(--accent);
}

.win-login-prompt p {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.win-login-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Scoreboard */
.scoreboard-content {
    max-width: 480px;
    width: 100%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.scoreboard-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.scoreboard-tab-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Row labels */
.scoreboard-tab-row::before {
    display: none;
}

.scoreboard-tab {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    font-weight: 500;
}

.scoreboard-tab:hover {
    background: var(--bg-cell-hover);
    color: var(--text-primary);
}

.scoreboard-tab.active {
    color: #fff;
}

/* Type tabs - orange/amber - more prominent */
.type-tabs {
    margin-bottom: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.type-tabs .scoreboard-tab {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.type-tabs .scoreboard-tab.active {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* Size tabs - cyan/teal */
.size-tabs .scoreboard-tab.active {
    background: linear-gradient(135deg, #00b4d8, #0096c7);
    border-color: #00b4d8;
    box-shadow: 0 2px 6px rgba(0, 180, 216, 0.25);
}

/* Mode tabs - pink/magenta */
.mode-tabs .scoreboard-tab.active {
    background: linear-gradient(135deg, #e94560, #d63850);
    border-color: #e94560;
    box-shadow: 0 2px 6px rgba(233, 69, 96, 0.25);
}

/* Difficulty tabs - purple/violet */
.difficulty-tabs .scoreboard-tab.active {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    border-color: #9b59b6;
    box-shadow: 0 2px 6px rgba(155, 89, 182, 0.25);
}

.scoreboard-list {
    text-align: left;
    overflow-y: auto;
    flex: 1;
    padding: 4px;
}

.scoreboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    gap: 12px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background 0.2s;
}

.scoreboard-entry:hover {
    border-color: var(--border);
    background: var(--bg-cell-hover);
}

.scoreboard-entry:first-child {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 215, 0, 0.05));
    border-color: rgba(255, 215, 0, 0.3);
}

.scoreboard-rank {
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 28px;
    font-size: 0.95rem;
}

.scoreboard-rank.gold { color: #ffd700; text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
.scoreboard-rank.silver { color: #c0c0c0; }
.scoreboard-rank.bronze { color: #cd7f32; }

.scoreboard-time {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.scoreboard-seed {
    margin-left: auto;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    transition: all 0.2s;
}

.scoreboard-seed:hover {
    color: var(--accent);
    background: var(--bg-cell-hover);
}

.scoreboard-mistakes {
    font-size: 0.75rem;
    color: var(--marked);
    opacity: 0.9;
}

.scoreboard-empty {
    color: var(--text-secondary);
    padding: 40px 32px;
    text-align: center;
    font-style: italic;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 4px;
    border: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 150;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .header-controls {
        display: none;
    }

    .mobile-header-actions {
        display: flex;
    }

    /* Hide logo and page title on mobile */
    .header-left .logo,
    .header-left .page-title {
        display: none !important;
    }

    .menu-btn {
        display: flex;
    }

    .game-container {
        padding: 4px;
        padding-bottom: 4px;
    }

    .mobile-toggle {
        display: block;
    }

    .footer {
        padding: 8px 12px;
        gap: 6px 12px;
        margin-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 8px;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.875rem;
    }

    /* Scoreboard button in footer - hidden on mobile (moved to settings panel) */
    .scoreboard-btn {
        display: none;
    }

    .progress-bar {
        width: 50px;
    }

    .progress-text {
        font-size: 0.7rem;
        min-width: 35px;
    }

    .toast {
        bottom: 150px;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .header {
        padding: 12px 24px;
    }

    .logo {
        font-size: 1.5rem;
    }

    .footer {
        padding: 12px 24px;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

/* ========================================
   TUTORIAL
   ======================================== */

.tutorial-content {
    max-width: 500px;
    width: 100%;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tutorial-header h2 {
    margin: 0;
}

.tutorial-step-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
}

.tutorial-steps {
    min-height: 280px;
}

.tutorial-step {
    display: none;
}

.tutorial-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-step h3 {
    color: var(--accent);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.tutorial-step p {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.tutorial-visual {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}

.tutorial-arrow {
    font-size: 1.5rem;
    color: var(--accent);
}

/* Tutorial grid cells */
.t-row {
    display: flex;
    gap: 2px;
}

.t-cell {
    width: 24px;
    height: 24px;
    background: var(--bg-cell);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--marked);
}

.t-cell.filled {
    background: var(--filled);
}

.t-cell.marked {
    background: var(--bg-cell);
    color: var(--marked);
    font-weight: bold;
}

.t-cell.empty {
    background: var(--bg-cell);
    opacity: 0.5;
}

.tutorial-example-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tutorial-result {
    font-weight: 600;
    color: var(--filled);
}

/* Clue demo */
.tutorial-clue-demo {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.clue-example {
    display: flex;
    align-items: center;
    gap: 12px;
}

.clue-num {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
    color: var(--text-primary);
}

.clue-means {
    color: var(--text-secondary);
}

.clue-visual {
    display: flex;
    gap: 2px;
}

.clue-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Overlap demonstration */
.overlap-demo {
    flex-direction: column;
    align-items: stretch;
}

.overlap-example {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.overlap-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.overlap-positions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.overlap-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pos-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 50px;
}

.overlap-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(78, 204, 163, 0.1);
    border-radius: 6px;
    border: 1px dashed var(--filled);
}

.overlap-conclusion {
    text-align: center;
    color: var(--filled);
    font-weight: 600;
    font-size: 0.9rem;
}

.t-cell.certain {
    background: var(--filled);
    box-shadow: 0 0 8px var(--filled-glow);
}

.t-cell.dim {
    background: var(--bg-cell);
    opacity: 0.4;
}

/* Compact overlap examples */
.overlap-demo.compact {
    gap: 10px;
}

.overlap-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.mini-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
}

.overlap-show {
    display: flex;
    gap: 2px;
}

.mini-result {
    font-size: 0.8rem;
    color: var(--filled);
    min-width: 70px;
}

/* Action demo */
.tutorial-action-demo {
    display: flex;
    align-items: center;
    gap: 20px;
}

.action-before, .action-after {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.action-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Controls demo */
.tutorial-controls-demo {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.control-example {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Cross-reference demo - THE KEY */
.crossref-demo {
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.crossref-grid {
    display: grid;
    grid-template-columns: 30px repeat(3, 28px);
    grid-template-rows: 24px 28px;
    gap: 2px;
    align-items: center;
    justify-items: center;
}

.crossref-grid.solved {
    background: rgba(78, 204, 163, 0.1);
    padding: 8px;
    border-radius: 6px;
}

.crossref-corner {
    /* empty top-left */
}

.crossref-col-clues {
    display: contents;
}

.crossref-col-clues span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.crossref-row-clue {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    padding-right: 4px;
}

.crossref-cells {
    display: contents;
}

.crossref-cells .t-cell {
    width: 26px;
    height: 26px;
}

.crossref-cells .t-cell.q {
    background: var(--bg-cell);
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crossref-explanation {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.crossref-explanation p {
    margin: 4px 0;
}

/* Tutorial controls inline */
.tutorial-controls-inline {
    display: flex;
    gap: 24px;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* Easy wins section */
.easy-wins {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.easy-win-example {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ew-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 120px;
}

.ew-visual {
    display: flex;
    gap: 2px;
}

.ew-result {
    font-size: 0.8rem;
    color: var(--filled);
    font-weight: 500;
}

/* Overlap full example (showing all possibilities) */
.overlap-full-example {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.ofe-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.ofe-possibilities {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.ofe-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ofe-pos {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 60px;
}

.ofe-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(78, 204, 163, 0.1);
    border-radius: 8px;
    border: 1px dashed var(--filled);
}

.ofe-conclusion {
    font-size: 0.85rem;
    color: var(--filled);
    font-weight: 600;
    margin-left: auto;
}

/* Cross-reference walkthrough */
.crossref-walkthrough {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.cw-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.cw-num {
    width: 24px;
    height: 24px;
    background: var(--filled);
    color: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.cw-text {
    flex: 1;
    min-width: 150px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.cw-visual {
    display: flex;
    gap: 2px;
    align-items: center;
}

.cw-visual.vertical {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.cw-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cw-insight {
    font-size: 0.8rem;
    color: var(--filled);
    font-style: italic;
}

/* Cross-reference grid demo (3x5 grid) */
.crossref-grid-demo {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.cgd-step {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.cgd-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.cgd-grid {
    display: grid;
    grid-template-columns: 28px repeat(5, 22px);
    grid-template-rows: 20px repeat(3, 22px);
    gap: 2px;
    align-items: center;
    justify-items: center;
}

.cgd-corner {
    /* empty */
}

.cgd-col-clue {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.cgd-col-clue.hl {
    color: var(--filled);
}

.cgd-row-clue {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
    padding-right: 4px;
}

.cgd-row-clue.hl {
    color: var(--filled);
}

.cgd-grid .t-cell {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
}

.cgd-grid .t-cell.hl {
    box-shadow: 0 0 6px var(--filled);
}

.cgd-conclusion {
    font-size: 0.85rem;
    color: var(--filled);
    text-align: center;
    margin-top: 4px;
}

/* Completed line demo */
.completed-line-demo {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.cl-example {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.cl-clue {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
    text-align: right;
}

.cl-before, .cl-after {
    display: flex;
    gap: 2px;
}

.cl-explain {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Tips list */
.tutorial-tips-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    text-align: left;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.tip-num {
    width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.tip-item span:last-child {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Modes compact */
.tutorial-modes-compact {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.85rem;
}

.tutorial-modes-compact p {
    margin: 4px 0;
    color: var(--text-secondary);
}

/* Strategy */
.tutorial-strategy {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.strategy-example {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.strategy-clue {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 130px;
}

.strategy-visual {
    display: flex;
    gap: 2px;
}

.strategy-result {
    font-size: 0.85rem;
    color: var(--filled);
    font-weight: 500;
}

/* Modes info */
.tutorial-modes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    text-align: left;
}

.mode-info {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.9rem;
}

.mode-info strong {
    color: var(--accent);
}

/* Tutorial tips/notes */
.tutorial-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.tutorial-tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

/* Tutorial navigation */
.tutorial-nav {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 12px;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--text-primary);
}

/* Separator dashes - styled for visual distinction */
.separator-dash {
    color: var(--accent);
    font-weight: 300;
    opacity: 0.7;
    margin: 0 2px;
}

/* Tutorial Step 6: Account promo */
.tutorial-account-promo {
    text-align: center;
    padding: 10px;
}

.account-promo-icon {
    color: var(--accent);
    margin-bottom: 12px;
}

.account-promo-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.account-promo-benefits {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

.benefit-item {
    background: var(--bg-tertiary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tutorial-account-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.tutorial-skip-account {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

@media (max-width: 480px) {
    .tutorial-content {
        padding: 20px 16px;
    }

    .tutorial-steps {
        min-height: 320px;
    }

    .tutorial-visual {
        padding: 16px;
        flex-wrap: wrap;
    }

    .t-cell {
        width: 20px;
        height: 20px;
    }

    .tutorial-tip {
        font-size: 0.8rem;
    }
}

/* ========================================
   EFFECTS - Confetti, Ripple, Animations
   ======================================== */

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    border-radius: 2px;
    animation: confetti-fall 3s ease-out forwards;
    pointer-events: none;
    z-index: 200;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg) scale(0.5);
        opacity: 0;
    }
}

/* Page-wide Ripple Effect */
.page-ripple {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    width: var(--ripple-size, 100px);
    height: var(--ripple-size, 100px);
    transform: translate(-50%, -50%) scale(0);
    background: radial-gradient(
        circle,
        var(--ripple-color, rgba(78, 204, 163, 0.15)) 0%,
        transparent 60%
    );
    animation: page-ripple-expand 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes page-ripple-expand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Smooth cell fill animation - uses box-shadow instead of transform to avoid layout shifts */
.cell.filled {
    animation: cell-fill 0.2s ease-out;
}

@keyframes cell-fill {
    0% {
        box-shadow: inset 0 0 0 50px var(--bg-cell);
    }
    100% {
        box-shadow: inset 0 0 0 0 var(--bg-cell);
    }
}

/* Smooth mark animation */
.cell.marked::before,
.cell.marked::after {
    animation: mark-appear 0.15s ease-out;
}

@keyframes mark-appear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(45deg) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(45deg) scale(1);
    }
}

.cell.marked::after {
    animation: mark-appear-reverse 0.15s ease-out;
}

@keyframes mark-appear-reverse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(-45deg) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(-45deg) scale(1);
    }
}

/* Settings Panel - Effects Section */
.settings-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.settings-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.toggle-group label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Hide mobile-only settings on desktop */
.mobile-only-setting {
    display: none;
}

/* Hide desktop-only elements on mobile */
.desktop-only {
    display: inline-flex;
}

@media (max-width: 768px) {
    .mobile-only-setting {
        display: flex;
    }
    .desktop-only {
        display: none !important;
    }
}

/* Also show on devices that support vibration (touch devices) */
@media (pointer: coarse) {
    .mobile-only-setting {
        display: flex;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 26px;
    border: 1px solid var(--border);
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

/* Theme Selector */
.theme-select-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.theme-select-group label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.theme-select-group select {
    min-width: 120px;
}

/* Desktop Effects Settings */
.effects-dropdown {
    position: relative;
}

.effects-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
}

.effects-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.effects-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 100;
}

.effects-dropdown.open .effects-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.effects-menu .toggle-group {
    padding: 6px 0;
}

.effects-menu .toggle-group label {
    font-size: 0.85rem;
}

.effects-menu .theme-select-group {
    padding: 6px 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.effects-menu .theme-select-group select {
    width: 100%;
}

/* Session Progress Indicators */
.session-progress {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.speedrun-progress .sr-step {
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.3s;
}

.speedrun-progress .sr-step.active {
    background: var(--accent);
    color: white;
    font-weight: bold;
}

.speedrun-progress .sr-step.completed {
    background: var(--filled);
    color: white;
}

.speedrun-progress .sr-arrow {
    color: var(--text-secondary);
}

.timed-counter {
    font-weight: bold;
}

.timed-counter #timed-count {
    color: var(--accent);
    font-size: 1.2em;
}

/* Speed Run Results */
.speedrun-results,
.timed-results {
    text-align: center;
    padding: 16px 0;
}

.speedrun-results p,
.timed-results p {
    margin: 8px 0;
}

.speedrun-results .sr-total {
    margin-top: 16px;
    font-size: 1.2em;
    color: var(--accent);
}

.timed-results .puzzles-completed {
    font-size: 1.3em;
}

.timed-results .puzzles-completed span {
    color: var(--accent);
    font-weight: bold;
}

.new-record {
    color: var(--filled);
    font-weight: bold;
    animation: pulse 1s infinite;
}

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

/* Session modal control groups */
#speedrun-start-modal .control-group,
#timed-start-modal .control-group {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#speedrun-start-modal .control-group label,
#timed-start-modal .control-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#speedrun-start-modal .control-group select,
#timed-start-modal .control-group select {
    width: 100%;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

@media (max-width: 768px) {
    .session-progress {
        top: 60px;
        padding: 6px 12px;
        font-size: 0.8rem;
        transition: opacity 0.5s ease;
    }

    .session-progress.faded {
        opacity: 0.2;
        pointer-events: none;
    }
}

/* Timed scoreboard options */
.timed-options {
    gap: 8px;
    justify-content: center;
}

.timed-options select {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

/* Scoreboard entry variants */
.scoreboard-splits {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.scoreboard-count {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent);
}

/* ============ AUTH STYLES ============ */

.auth-content {
    max-width: 360px;
    position: relative;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-form input::placeholder {
    color: var(--text-secondary);
}

.auth-error {
    color: var(--incorrect);
    font-size: 0.875rem;
    min-height: 1.2em;
    margin: 0;
}

.auth-switch {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 8px;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Account Modal */
.account-content {
    max-width: 400px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.account-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-avatar svg {
    width: 36px;
    height: 36px;
    fill: var(--text-secondary);
}

.account-details {
    flex: 1;
}

.account-display-name {
    display: flex;
    gap: 8px;
    align-items: center;
}

.account-display-name input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.account-username {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 4px 0 0 0;
}

.account-stats h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Account button logged in state */
#account-btn.logged-in {
    background: var(--accent);
    color: white;
}

#account-btn.logged-in:hover {
    background: var(--accent-hover);
}

/* ============================================
   SCOREBOARD OVERHAUL - Global Leaderboards
   ============================================ */

/* Source tabs - Local vs Global toggle */
.source-tabs {
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.source-tabs .scoreboard-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
}

.source-tabs .scoreboard-tab svg {
    opacity: 0.7;
}

.source-tabs .scoreboard-tab.active {
    background: linear-gradient(135deg, var(--accent), #3da88a);
    border-color: var(--accent);
    box-shadow: 0 2px 10px rgba(78, 204, 163, 0.3);
}

.source-tabs .scoreboard-tab.active svg {
    opacity: 1;
}

/* Loading state */
.scoreboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    gap: 12px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Enhanced scoreboard entries for global */
.scoreboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.scoreboard-entry.scoreboard-me {
    background: linear-gradient(135deg, rgba(78, 204, 163, 0.15), rgba(78, 204, 163, 0.05));
    border-color: rgba(78, 204, 163, 0.4);
}

/* Player info with avatar */
.scoreboard-player {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #3da88a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.player-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.you-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}

.mistakes-badge {
    background: var(--text-secondary);
    color: var(--bg-primary);
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 8px;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.8;
}

.on-day-badge {
    color: #fbbf24;
    font-size: 0.8rem;
    margin-left: 4px;
    vertical-align: middle;
}

.replay-badge {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.7;
}

.replay-row {
    opacity: 0.7;
}

/* Improved rank display */
.scoreboard-rank {
    font-weight: 700;
    min-width: 36px;
    text-align: center;
    font-size: 1rem;
}

/* Medals for top 3 */
.scoreboard-rank.gold {
    font-size: 1.2rem;
}
.scoreboard-rank.silver {
    font-size: 1.2rem;
}
.scoreboard-rank.bronze {
    font-size: 1.2rem;
}

/* Stats on right side */
.scoreboard-time {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.scoreboard-games {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.scoreboard-count {
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent);
}

/* Empty state hint */
.scoreboard-hint {
    display: block;
    font-size: 0.85rem;
    margin-top: 8px;
    opacity: 0.7;
    font-style: normal;
}

/* Splits display */
.scoreboard-splits {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile adjustments for scoreboard */
@media (max-width: 768px) {
    .source-tabs .scoreboard-tab {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .scoreboard-entry {
        padding: 10px 12px;
        gap: 8px;
    }

    .scoreboard-games {
        display: none;
    }

    .scoreboard-splits {
        display: none;
    }
}

/* ============================================
   PAGE SYSTEM - Full-page navigation
   ============================================ */

.page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.page.active {
    display: flex;
    animation: page-fade-in 0.2s ease-out;
}

@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Back button */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 12px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--bg-cell-hover);
    border-color: var(--accent);
}

.back-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Page title */
.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 8px;
}

/* ============================================
   ACCOUNT PAGE
   ============================================ */

.page-account .page-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.account-header-section {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.account-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #3da88a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.account-info-edit {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-btn input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
}

.input-with-btn input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.input-with-btn input:focus {
    outline: none;
    border-color: var(--accent);
}

.member-since {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Stats section */
.account-stats-section {
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.account-stats-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.stats-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-card {
    text-align: center;
    padding: 20px 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: transform 0.2s, border-color 0.2s;
}

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

.stat-card .stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Recent puzzles section */
.account-recent-section {
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.recent-scores-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-score-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.recent-score-item:hover {
    background: var(--bg-cell-hover);
    border-color: var(--accent);
}

.recent-score-size {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

.recent-score-difficulty {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: capitalize;
    min-width: 60px;
}

.recent-score-time {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--accent);
    min-width: 70px;
}

.recent-score-seed {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    margin-left: auto;
}

.recent-score-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.placeholder-text {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    font-style: italic;
}

/* Actions section */
.account-actions-section {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.account-actions-section .btn {
    min-width: 120px;
}

/* ============================================
   SCORES PAGE
   ============================================ */

.scores-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scores-filter-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 70px;
    flex-shrink: 0;
}

.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.source-toggle,
.type-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.filter-pill {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-pill:hover {
    color: var(--text-primary);
    background: var(--bg-cell-hover);
}

.filter-pill.active {
    background: var(--accent);
    color: white;
}

/* Different colors for each filter section */
.source-toggle .filter-pill.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
}

.type-toggle .filter-pill.active {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

.mode-pills .filter-pill.active {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
}

.size-pills .filter-pill.active,
.size-pills-timed .filter-pill.active {
    background: linear-gradient(135deg, #06b6d4, #0ea5e9);
}

.difficulty-pills .filter-pill.active,
.difficulty-pills-sr .filter-pill.active,
.difficulty-pills-timed .filter-pill.active {
    background: linear-gradient(135deg, #ec4899, #f43f5e);
}

.speedrun-mode-pills .filter-pill.active {
    background: linear-gradient(135deg, #eab308, #f59e0b);
}

.duration-pills .filter-pill.active {
    background: linear-gradient(135deg, #22c55e, #10b981);
}

.filter-row-standard select,
.filter-row-speedrun select,
.filter-row-timed select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.filter-row-standard select:focus,
.filter-row-speedrun select:focus,
.filter-row-timed select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Daily date picker */
.daily-date-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.date-nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.date-nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.date-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.date-input {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent);
}

.daily-player-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.daily-player-count.has-players {
    color: var(--accent);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Scores table */
.scores-table-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    flex: 1;
}

.scores-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.scores-table th {
    text-align: left;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.scores-table th.sortable {
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.scores-table th.sortable:hover {
    color: var(--text-primary);
}

.scores-table th.sortable::after {
    content: '';
    margin-left: 6px;
    opacity: 0.3;
}

.scores-table th.sortable.sorted::after {
    opacity: 1;
}

.scores-table th.sortable.asc::after {
    content: '↑';
}

.scores-table th.sortable.desc::after {
    content: '↓';
}

.scores-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.scores-table tr:last-child td {
    border-bottom: none;
}

.scores-table tr:hover td {
    background: var(--bg-tertiary);
}

.scores-table tr.row-highlight td {
    background: rgba(78, 204, 163, 0.1);
}

/* Column widths */
.col-rank { width: 60px; text-align: center; }
.col-player { width: auto; min-width: 150px; }
.col-time {
    width: 100px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--accent);
}
.col-count {
    width: 100px;
    font-weight: 600;
    color: var(--accent);
}
.col-splits {
    width: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.col-seed { width: 100px; }
.col-date { width: 110px; color: var(--text-secondary); }

/* Seed link button */
.seed-link {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.seed-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.col-actions { width: 80px; text-align: right; }

/* Rank styling */
.rank-gold { color: #ffd700; text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
.rank-silver { color: #c0c0c0; text-shadow: 0 0 6px rgba(192, 192, 192, 0.3); }
.rank-bronze { color: #cd7f32; text-shadow: 0 0 6px rgba(205, 127, 50, 0.3); }

/* Player cell */
.player-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #3da88a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: white;
    text-transform: uppercase;
}

.player-name {
    font-weight: 500;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-details {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Empty and loading states */
.scores-empty,
.scores-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    gap: 12px;
    text-align: center;
}

.scores-empty svg {
    opacity: 0.3;
}

.scores-empty p,
.scores-loading p {
    font-size: 1rem;
    margin: 0;
}

.scores-empty-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .page-content {
        padding: 16px;
    }

    .account-header-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
    }

    .account-avatar-large {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .account-info-edit {
        width: 100%;
    }

    .input-with-btn {
        flex-wrap: wrap;
    }

    .input-with-btn input {
        width: 100%;
        flex: unset;
    }

    .stats-grid-large {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-card .stat-number {
        font-size: 1.5rem;
    }

    .recent-score-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .recent-score-seed {
        margin-left: 0;
        width: 100%;
        order: 10;
    }

    /* Scores page mobile */
    .scores-filter-bar {
        padding: 12px;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .source-toggle,
    .type-toggle {
        width: 100%;
        justify-content: center;
    }

    .filter-pill {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .filter-row-standard,
    .filter-row-daily,
    .filter-row-speedrun,
    .filter-row-timed {
        justify-content: stretch;
    }

    .daily-date-picker {
        width: 100%;
        justify-content: center;
    }

    .filter-row-standard select,
    .filter-row-speedrun select,
    .filter-row-timed select {
        flex: 1;
    }

    /* Convert table to cards on mobile */
    .scores-table-container {
        background: transparent;
        border: none;
    }

    .scores-table {
        display: block;
        width: 100%;
    }

    .scores-table thead {
        display: none;
    }

    .scores-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .scores-table tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 12px;
        background: var(--bg-secondary);
        border-radius: 10px;
        border: 1px solid var(--border);
    }

    .scores-table tr::after {
        content: attr(data-mobile-info);
        width: 100%;
        font-size: 0.75rem;
        color: var(--text-muted);
        text-transform: capitalize;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }

    .scores-table tr:hover td {
        background: transparent;
    }

    .scores-table td {
        padding: 0;
        border: none;
    }

    .col-rank {
        width: auto;
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    .col-player {
        flex: 1;
        min-width: 0;
    }

    .col-player .player-cell {
        gap: 8px;
    }

    .col-player .player-name {
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .col-player .player-info {
        min-width: 0;
    }

    .col-player .player-details {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .col-time, .col-count {
        font-family: 'Courier New', monospace;
        font-weight: 600;
        font-size: 1rem;
        color: var(--accent);
        flex-shrink: 0;
        margin-left: auto;
    }

    .col-seed {
        flex-shrink: 0;
    }

    .col-seed .seed-link {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .col-date {
        font-size: 0.75rem;
        color: var(--text-secondary);
        flex-shrink: 0;
    }

    .col-splits {
        width: 100%;
        font-size: 0.75rem;
        color: var(--text-secondary);
        font-family: 'Courier New', monospace;
    }

    .col-actions {
        display: none;
    }

    /* Latest row - mobile optimized layout */
    .scores-table tr.latest-row {
        display: block !important;
        padding: 12px;
    }

    .scores-table tr.latest-row .col-player {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
        width: 100%;
    }

    .scores-table tr.latest-row .col-player .player-cell {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: 1;
        min-width: 0;
    }

    .scores-table tr.latest-row .col-player .player-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        flex: 1;
    }

    .scores-table tr.latest-row .col-player .player-name {
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .scores-table tr.latest-row .col-player .player-details {
        font-size: 0.75rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .scores-table tr.latest-row .col-time,
    .scores-table tr.latest-row .col-seed,
    .scores-table tr.latest-row .col-date {
        display: inline-block;
        margin-right: 12px;
    }

    .scores-table tr.latest-row .col-time {
        font-weight: 600;
        color: var(--accent);
    }

    .scores-table tr.latest-row .col-seed .seed-link {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    .scores-table tr.latest-row .col-date {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    /* Hide the ::after mobile-info for latest since details are inline */
    .scores-table tr.latest-row::after {
        display: none !important;
    }
}
