@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Outfit:wght@400;600;800&display=swap');

:root {
    /* Premium High-Contrast Theme */
    --primary: #fbbf24;
    /* Amber-400: High visibility Gold */
    --primary-hover: #f59e0b;

    --bg-dark: #020617;
    /* Slate-950: Almost black */
    --bg-card: #1e293b;
    /* Slate-800: Distinct card background */
    --bg-card-border: rgba(255, 255, 255, 0.3);
    /* PROMINENT BORDER */

    --text-main: #ffffff;
    /* PURE WHITE */
    --text-muted: #e2e8f0;
    /* Slate-200: Much lighter gray for readability */

    --grid-border: #94a3b8;
    /* Slate-400: Lighter border for grid */
    --cell-bg: #0f172a;
    /* Slate-900 */
    --cell-bg-hover: #334155;
    --cell-selected: rgba(251, 191, 36, 0.3);
    /* Gold tint */
    --cell-highlight: rgba(251, 191, 36, 0.15);

    --glass: rgba(15, 23, 42, 0.9);
    /* Less transparency for better text bg */
    --glass-border: rgba(255, 255, 255, 0.2);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.7;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
}

/* Typography */
h1,
h2,
h3,
.logo,
.badge,
.num-btn {
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.02em;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    /* Wider container */
    margin: 0 auto;
    padding: 0 5px;
}

/* Background Wrapper */
.bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
}

.bg-gradient {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 10%, #1e1b4b 0%, #020617 80%);
}

/* Navigation */
.navbar {
    height: 70px;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(2, 6, 23, 0.85);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 25px;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border-radius: 8px;
    /* Sharper corners */
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Game & Content Sections */
.game-section,
.content-section {
    padding-top: 120px;
    padding-bottom: 60px;
    min-height: 100vh;
}

.game-section {
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-flex {
    display: flex;
    gap: 50px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
}

.game-info-side {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.game-board-side {
    flex: 0 0 auto;
    width: 100%;
    max-width: 500px;
}

h1 {
    font-size: 3rem;
    line-height: 1.2;
    margin-bottom: 15px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Sudoku Card */
.sudoku-card {
    background: #0f172a;
    /* Solid deep background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-family: 'Outfit', sans-serif;
    gap: 10px;
}

.game-header>div {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    white-space: nowrap;
}

#timer {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 55px;
}

/* Grid Area - Responsive Constraints */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    background: #475569;
    /* Thick line color */
    border: 3px solid #475569;
    /* Outer border */
    aspect-ratio: 1;
    margin: 0 auto 0px auto;
    border-radius: 4px;
    user-select: none;
    width: 100%;
    max-width: 450px;
}

@media (max-width: 500px) {
    .sudoku-grid {
        max-width: 92vw;
        /* Reduced slightly to ensure shadows/borders aren't clipped by screen edge */
    }
}

.cell {
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 5vw, 1.5rem);
    font-weight: 600;
    color: #f8fafc;
    cursor: pointer;
    position: relative;
    aspect-ratio: 1;
    transition: background-color 0.2s, color 0.2s;
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    /* Standard thin border */
}

/* 3x3 Block Separation - Using borders instead of box-shadow to avoid clipping */
.cell.border-right-thick {
    border-right: 3px solid #475569;
}

.cell.border-bottom-thick {
    border-bottom: 3px solid #475569;
}

.cell:hover {
    background: #334155;
    z-index: 2;
}

.cell.selected {
    background: var(--primary) !important;
    color: #020617 !important;
    font-weight: 800;
    z-index: 5;
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(251, 191, 36, 0.5);
}

.cell.highlight-related {
    background: #2d3748;
}

.cell.highlight-number {
    background: rgba(251, 191, 36, 0.2);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.cell.error-shake {
    background: #7f1d1d !important;
    color: #fff !important;
    animation: shakeTriple 0.6s ease-in-out;
}

.cell.completed-row {
    animation: radiantFlash 0.8s ease-out;
    background: rgba(52, 211, 153, 0.4) !important;
}

.cell.fixed {
    color: #ffffff;
    font-weight: 800;
}

.cell.user {
    color: var(--primary);
    font-weight: 600;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Animations */
@keyframes shakeTriple {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-6px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(6px);
    }
}

.shake-3 {
    animation: shakeTriple 0.6s ease-in-out;
}

@keyframes radiantFlash {
    0% {
        filter: brightness(1) saturate(1);
        background-color: var(--primary);
    }

    50% {
        filter: brightness(2) saturate(2);
        background-color: #10b981;
        transform: scale(1.1);
        z-index: 10;
    }

    100% {
        filter: brightness(1) saturate(1);
        transform: scale(1);
    }
}

@keyframes popIn {
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    50% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-4px);
    }
}

@keyframes successPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.cell.success {
    animation: successPulse 0.5s ease-out;
    background: rgba(52, 211, 153, 0.3) !important;
}

/* Bright white for user entries */

/* Controls */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.controls-grid.two-rows {
    grid-template-columns: repeat(5, 1fr);
}

.num-btn {
    aspect-ratio: 1;
    background: #334155;
    border: 1px solid var(--glass-border);
    color: #f8fafc;
    border-radius: 6px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:hover {
    background: var(--primary);
    color: #020617;
}

/* Actions */
.action-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.action-btn .icon {
    font-size: 1.2rem;
    width: 44px;
    height: 44px;
    background: #334155;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    color: #fff;
}

.action-btn:hover .icon,
.action-btn.active .icon {
    background: var(--primary);
    color: #020617;
}

/* Timer & Header */
.game-header {
    font-size: 0.95rem;
}

.badge {
    background: var(--primary) !important;
    color: #020617;
    font-weight: 700;
}

#timer {
    color: var(--primary);
    font-family: monospace;
    font-size: 1.2rem;
}

/* Feedback Modal */
#feedback-modal {
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.7) !important;
}


/* Game Complete Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.stars span:hover,
.stars span.active {
    color: #fbbf24;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    transform: scale(1.2);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* Responsive */
@media (max-width: 900px) {
    .game-flex {
        flex-direction: column-reverse;
        align-items: center;
    }

    .game-info-side {
        text-align: center;
    }

    .nav-links {
        display: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 5px;
    }

    .sudoku-card {
        padding: 5px;
    }

    .controls-grid {
        gap: 3px;
    }

    .num-btn {
        font-size: 1.1rem;
    }

    h1 {
        font-size: 2.2rem;
    }
}