/* ============================================
   WikiGuessr - Stylesheet
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Colors */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(30, 30, 60, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.05);

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    --border-color: rgba(255, 255, 255, 0.1);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Typography */
    --font-primary: 'Outfit', 'Noto Sans JP', system-ui, sans-serif;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* ---------- Container ---------- */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding-top: var(--spacing-lg);
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.logo:hover {
    transform: scale(1.02);
}

.logo-icon {
    font-size: 2rem;
    -webkit-text-fill-color: initial;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: var(--spacing-sm);
}

/* ---------- Screens ---------- */
.screen {
    display: none;
    flex: 1;
    animation: fadeIn var(--transition-base);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
}

/* ---------- Welcome Card ---------- */
.welcome-card {
    text-align: center;
}

.welcome-card h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.instructions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    text-align: left;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.instruction-item p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---------- Difficulty Selection ---------- */
.difficulty-section {
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.difficulty-section h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

.difficulty-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-sm);
}

.difficulty-option {
    cursor: pointer;
}

.difficulty-option input {
    display: none;
}

.difficulty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-sm);
    background: var(--bg-glass);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.difficulty-option input:checked+.difficulty-card {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.difficulty-card:hover {
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
}

.difficulty-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.difficulty-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.difficulty-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

@media (max-width: 480px) {
    .difficulty-options {
        grid-template-columns: repeat(3, 1fr);
    }

    .difficulty-card {
        padding: var(--spacing-sm);
    }

    .difficulty-icon {
        font-size: 1.2rem;
    }

    .difficulty-name {
        font-size: 0.75rem;
    }

    .difficulty-desc {
        font-size: 0.6rem;
    }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-submit {
    background: var(--success);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
}

.btn-submit:hover {
    background: #16a34a;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---------- Loading Screen ---------- */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: var(--spacing-lg);
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-glass);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ---------- Timer ---------- */
.timer-container {
    margin-bottom: var(--spacing-lg);
}

.timer-bar {
    height: 8px;
    background: var(--bg-glass);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.timer-progress {
    height: 100%;
    background: var(--accent-gradient);
    width: 100%;
    transition: width 1s linear;
    border-radius: var(--radius-full);
}

.timer-progress.warning {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.timer-progress.danger {
    background: linear-gradient(90deg, var(--error), #f87171);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.timer-display {
    text-align: right;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

#timer-text {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-primary);
}

/* ---------- Hints Section ---------- */
.hints-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    flex: 1;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.hints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.hints-label {
    font-weight: 600;
    font-size: 1.1rem;
}

.hints-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hints-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    align-content: flex-start;
    flex: 1;
    overflow-y: auto;
}

.hint-tag {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    color: var(--text-primary);
    animation: hintAppear 0.4s ease-out;
    transition: all var(--transition-fast);
}

.hint-tag:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
}

.hint-tag.new {
    animation: hintAppear 0.4s ease-out, glow 1s ease-out;
}

@keyframes hintAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
    }

    100% {
        box-shadow: none;
    }
}

/* ---------- Answer Section ---------- */
.answer-section {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.answer-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-family: var(--font-primary);
    font-size: 1rem;
    background: var(--bg-glass);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

/* Autocomplete */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-xs);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-item {
    padding: var(--spacing-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: rgba(99, 102, 241, 0.2);
}

/* ---------- Skip Button ---------- */
#skip-btn {
    width: 100%;
}

/* ---------- Result Screen ---------- */
.result-card {
    text-align: center;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
}

.result-title.correct {
    color: var(--success);
}

.result-title.incorrect {
    color: var(--error);
}

.result-answer {
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.result-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-answer-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.result-answer-text:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer a:hover {
    color: var(--accent-primary);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .container {
        padding: var(--spacing-md);
    }

    .logo {
        font-size: 2rem;
    }

    .card {
        padding: var(--spacing-lg);
    }

    .answer-section {
        flex-direction: column;
    }

    .btn-submit {
        width: 100%;
    }

    .result-stats {
        gap: var(--spacing-lg);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}