﻿:root {
    --font-display: "Space Grotesk", sans-serif;
    --font-body: "Manrope", sans-serif;
    --ink: #121417;
    --muted: #5e6570;
    --paper: #f3f6fa;
    --panel: rgba(255, 255, 255, 0.92);
    --accent: #2b67f2;
    --accent-dark: #1e49b8;
    --accent-soft: #78b3ff;
    --shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
    --border: rgba(15, 23, 42, 0.14);
    --ghost-bg: rgba(255, 255, 255, 0.95);
    --ghost-border: rgba(15, 23, 42, 0.18);
    --menu-hover: rgba(15, 23, 42, 0.06);
    --focus-ring: rgba(43, 103, 242, 0.35);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(43, 103, 242, 0.12), transparent 45%),
        radial-gradient(circle at 82% 8%, rgba(242, 176, 84, 0.18), transparent 45%),
        linear-gradient(135deg, #f7f8fc 0%, #eef2f7 40%, #f7f1e8 100%);
    --radius: 18px;
    --radius-sm: 12px;
    --tile-bg: rgba(255, 255, 255, 0.92);
    --tile-ink: #0f172a;
    --tile-border: rgba(15, 23, 42, 0.15);
    --tile-correct: #22c55e;
    --tile-correct-ink: #0f172a;
}

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

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    min-height: 100vh;
    background: var(--page-bg);
}

body[data-mode="dark"] {
    --ink: #f8fafc;
    --muted: #a6b0be;
    --paper: #0f172a;
    --panel: rgba(15, 23, 42, 0.92);
    --accent: #60a5fa;
    --accent-dark: #2563eb;
    --accent-soft: #3b82f6;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    --border: rgba(148, 163, 184, 0.3);
    --ghost-bg: rgba(15, 23, 42, 0.72);
    --ghost-border: rgba(148, 163, 184, 0.35);
    --menu-hover: rgba(148, 163, 184, 0.18);
    --focus-ring: rgba(96, 165, 250, 0.45);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(96, 165, 250, 0.22), transparent 45%),
        radial-gradient(circle at 82% 8%, rgba(14, 116, 144, 0.24), transparent 45%),
        linear-gradient(135deg, #0b1220 0%, #0f172a 45%, #111827 100%);
    --tile-bg: rgba(15, 23, 42, 0.95);
    --tile-ink: #f8fafc;
    --tile-border: rgba(148, 163, 184, 0.35);
    --tile-correct: #22c55e;
    --tile-correct-ink: #0b1220;
}

body[data-theme="midnight"] {
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --accent-soft: #0ea5e9;
    --page-bg:
        radial-gradient(circle at 10% 18%, rgba(56, 189, 248, 0.28), transparent 45%),
        radial-gradient(circle at 85% 12%, rgba(59, 130, 246, 0.25), transparent 45%),
        linear-gradient(135deg, #061024 0%, #0b1b3b 50%, #0f1e2e 100%);
}

body[data-theme="forest"] {
    --accent: #22c55e;
    --accent-dark: #16a34a;
    --accent-soft: #4ade80;
    --page-bg:
        radial-gradient(circle at 14% 18%, rgba(34, 197, 94, 0.28), transparent 45%),
        radial-gradient(circle at 84% 12%, rgba(20, 83, 45, 0.32), transparent 45%),
        linear-gradient(135deg, #071a12 0%, #0e2418 50%, #0f2a1b 100%);
}

body[data-theme="sunset"] {
    --accent: #f97316;
    --accent-dark: #ea580c;
    --accent-soft: #fb923c;
    --page-bg:
        radial-gradient(circle at 14% 18%, rgba(249, 115, 22, 0.25), transparent 45%),
        radial-gradient(circle at 84% 12%, rgba(251, 146, 60, 0.2), transparent 45%),
        linear-gradient(135deg, #fff4eb 0%, #fff1e6 45%, #fef3e8 100%);
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.header-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.toolbar-btn,
.ghost-btn,
.choose-btn,
.link-btn {
    font-family: var(--font-body);
    font-size: 0.92rem;
    border-radius: 999px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.toolbar-btn:hover,
.ghost-btn:hover,
.choose-btn:hover,
.link-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.choose-btn {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.link-btn {
    background: transparent;
    border-color: transparent;
    color: var(--accent);
    padding: 0;
    cursor: pointer;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.toolbar-menu {
    position: relative;
}

.toolbar-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--panel);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 20;
}

.toolbar-menu:hover .toolbar-dropdown,
.toolbar-menu:focus-within .toolbar-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.dropdown-title {
    font-weight: 600;
    margin-bottom: 8px;
}


.menu-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 8px 6px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink);
}

.menu-item:hover,
.menu-item.is-active {
    background: var(--menu-hover);
}


.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.06em;
    font-family: var(--font-display);
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
}

.brand-tagline {
    color: var(--muted);
    font-size: 0.9rem;
}

.auth-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 24px;
    align-items: start;
}

.section-card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

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

.section-label {
    font-weight: 700;
    font-size: 1.05rem;
}

.section-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.game-header .title {
    font-family: var(--font-display);
    margin: 0 0 8px;
}

.subtitle {
    margin: 0 0 18px;
    color: var(--muted);
}

.game-header .cta-btn {
    margin-top: 4px;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.cta-btn {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 12px 22px;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.25);
}

.game-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: baseline;
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

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

.stat-inline__label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}

.stat-inline__value {
    font-weight: 600;
    color: var(--ink);
}

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    border: 1px solid var(--border);
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.2);
    transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
    background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-track {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.toggle-label {
    color: var(--muted);
}

.puzzle-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-stack {
    width: 100%;
    max-width: min(72vh, 680px);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.puzzle-topline {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    min-height: 24px;
}

.puzzle-board {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    background: var(--paper);
    border: 1px solid var(--border);
    overflow: hidden;
    touch-action: none;
}

.puzzle-tile {
    position: absolute;
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 16px;
    border: 1px solid var(--tile-border);
    background: var(--tile-bg);
    color: var(--tile-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--move-duration) ease;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.board--dragging .puzzle-tile {
    transition: none;
}

.board--instant .puzzle-tile {
    transition-duration: 0ms;
}

.puzzle-tile.is-correct {
    background: var(--tile-correct);
    color: var(--tile-correct-ink);
    border-color: rgba(15, 23, 42, 0.1);
}

.tile-number {
    pointer-events: none;
}

.puzzle-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    background: rgba(15, 23, 42, 0.35);
    color: #fff;
    font-family: var(--font-display);
    text-align: center;
    z-index: 5;
}

.countdown-number {
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 700;
}

.overlay-label {
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 600;
}

.win-panel {
    position: relative;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 28px;
    padding: 28px 32px;
    min-width: min(90%, 420px);
    text-align: center;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
    animation: winPop 0.6s ease forwards;
}

.win-panel::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 32px;
    background: radial-gradient(circle at top, rgba(34, 197, 94, 0.35), transparent 65%);
    opacity: 0.8;
    z-index: -1;
    animation: winGlow 2.2s ease-in-out infinite;
}

.win-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    color: #f8fafc;
}

.win-time {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: #22c55e;
    margin-top: 10px;
}

.win-meta {
    margin-top: 6px;
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.95rem;
}

.win-highlight {
    margin-top: 10px;
    font-weight: 600;
    color: #fbbf24;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.win-actions {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}

.win-actions .ghost-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.share-status {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

@keyframes winPop {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

.history-block {
    margin-bottom: 18px;
}

.block-title {
    font-weight: 600;
    margin-bottom: 12px;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.65);
}

body[data-mode="dark"] .history-item {
    background: rgba(15, 23, 42, 0.6);
}

.history-time {
    font-weight: 600;
    margin-bottom: 4px;
}

.history-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

.history-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.history-login-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 24px;
}

.auth-modal__panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 24px;
    width: min(420px, 90vw);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

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

.auth-modal__title {
    font-weight: 700;
    font-size: 1.1rem;
}

.section-close {
    border: none;
    background: transparent;
    font-size: 1rem;
    cursor: pointer;
    color: var(--muted);
}

.auth-row {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.auth-label {
    display: grid;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.auth-label input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    font-family: var(--font-body);
}

body[data-mode="dark"] .auth-label input {
    background: rgba(15, 23, 42, 0.85);
    color: var(--ink);
}

.auth-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.auth-status {
    color: var(--muted);
    font-size: 0.85rem;
}

.auth-google img {
    width: 18px;
    height: 18px;
}

.auth-google {
    justify-content: center;
}

@media (max-width: 960px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app {
        padding: 16px;
    }
    .app-header {
        padding: 16px;
    }
    .toolbar-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    .puzzle-stack {
        width: 100%;
    }
}

@media (min-width: 1200px) {
    .puzzle-stack {
        max-width: min(72vh, 720px);
    }
}




