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

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
    @view-transition { navigation: auto; }
}

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

@font-face {
    font-family: 'Arial Rounded MT';
    src: url('../fonts/ArialRoundedMT-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Arial Rounded MT';
    src: url('../fonts/ArialRoundedMT-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}

:root {
    --primary-bg:          #0a0e27;
    --text-white:          #ffffff;
    --text-gray:           #b8c1db;
    --card-bg:             rgba(20, 26, 55, 0.6);
    --card-border:         rgba(184, 193, 219, 0.12);
    --primary-blue:        #4a6fa5;
    --primary-blue-hover:  #5a7fb5;
    --gradient-blue:       linear-gradient(135deg, #2b3a87 0%, #4a6fa5 100%);
    --gradient-blue-hover: linear-gradient(135deg, #3545a0 0%, #5a80c5 100%);
    --success-color:       #4caf50;
    --error-color:         #f44336;
    --warning-color:       #ff9800;
    --font-family:         'Arial Rounded MT', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --link-color:          #4a9eff;

    --cell-size:           min(10vw, 52px);
    --board-gap:           1px;
    --board-border:        2px;
}

body {
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    background-image: radial-gradient(ellipse 80% 40% at 50% -5%, #0f1a40 0%, rgba(15, 26, 64, 0.35) 45%, transparent 75%);
    background-attachment: fixed;
    color: var(--text-white);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 70px;
    animation: pageIn 0.25s ease-out;
}

a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font-family); }
input  { font-family: var(--font-family); }
ul { list-style: none; }
img { max-width: 100%; }

#snow {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 1;
}

.navbar {
    background: transparent;
    padding: 1rem 2rem;
    position: fixed;
    top: 0; width: 100%;
    z-index: 1000;
    border-bottom: 1px solid transparent;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.navbar.scrolled {
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(10px);
    border-bottom-color: rgba(184, 193, 219, 0.08);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}
.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}
.nav-logo {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 1.5rem; font-weight: 700;
    color: inherit; text-decoration: none;
    transition: opacity 0.3s ease;
}
.nav-logo:hover { opacity: 0.8; text-decoration: none; }
.nav-logo img { width: 40px; height: 40px; }
.nav-app-title { font-size: 1.5rem; font-weight: 700; color: var(--text-white); text-align: center; text-decoration: none; }
.nav-app-title:hover { text-decoration: none; }
.lang-switcher { display: flex; justify-content: flex-end; position: relative; }
.lang-toggle {
    background: rgba(74, 111, 165, 0.15);
    border: 1px solid rgba(74, 111, 165, 0.3);
    color: var(--text-white);
    padding: 0.5rem 1rem;
    display: flex; align-items: center; gap: 0.5rem;
    border-radius: 8px;
    font-family: var(--font-family); font-size: 0.9rem; font-weight: 500;
    transition: background 0.3s ease;
}
.lang-toggle:hover { background: rgba(74, 111, 165, 0.25); }
.globe-icon { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.lang-toggle-text { min-width: 60px; text-align: left; }
.lang-chevron { width: 10px; height: 10px; opacity: 0.7; transition: transform 0.2s ease; filter: brightness(0) invert(1); }
.lang-switcher.open .lang-chevron { transform: rotate(180deg); }
.lang-dropdown {
    position: absolute; top: 100%; right: 0;
    background: var(--card-bg); backdrop-filter: blur(10px);
    border: 1px solid var(--card-border); border-radius: 10px;
    padding: 0.5rem; min-width: 130px; margin-top: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0; pointer-events: none; transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.lang-switcher.open .lang-dropdown { opacity: 1; pointer-events: auto; transform: translateY(0); }
.lang-btn {
    background: transparent; border: none; color: var(--text-gray);
    padding: 0.5rem 0.75rem; border-radius: 6px;
    font-family: var(--font-family); font-size: 0.9rem; font-weight: 500;
    display: flex; align-items: center; gap: 0.5rem;
    width: 100%;
    transition: background 0.2s ease;
}
.lang-btn:hover { background: rgba(74, 111, 165, 0.2); color: var(--text-white); }
.flag-icon { width: 20px; height: 14px; border-radius: 2px; object-fit: cover; }

.screen {
    display: none;
    position: relative;
    z-index: 2;
    flex: 1;
    width: 100%;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow-y: auto;
}
.screen.active {
    display: flex;
    animation: screenIn 0.22s ease-out;
}
@keyframes screenIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

#screen-home.active { flex-direction: column; gap: 1.25rem; }
#screen-difficulty.active { flex-direction: column; align-items: center; }
#screen-game.active { flex-direction: column; align-items: center; justify-content: flex-start; padding: 1rem 1rem 3rem; }
#screen-end.active { flex-direction: column; align-items: center; }

.setup-container {
    background: rgba(14, 19, 45, 0.75);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem 2.5rem;
    max-width: 500px;
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.setup-container::before {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 60%; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(184, 193, 219, 0.25), transparent);
    pointer-events: none;
}
@media (min-width: 500px) {
    .setup-container { max-width: 560px; }
}

.login-header { margin-bottom: 1.25rem; }

.login-logo-wrap {
    display: inline-flex; flex-shrink: 0;
    margin-bottom: 1rem;
    animation: floatLogo 3.5s ease-in-out infinite;
}
@keyframes floatLogo {
    0%, 100% { transform: translateY(-8px); }
    50%       { transform: translateY(8px); }
}

.login-logo {
    width: 90px; height: 90px;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45));
}
.login-header-text {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
}
.login-title-row {
    display: flex; align-items: baseline; gap: 0.5rem;
    justify-content: center; margin-bottom: 0.5rem;
}
.login-title { font-size: 2rem; font-weight: 700; }
.login-title-row .login-title { margin-bottom: 0; }
.login-subtitle { font-size: 0.95rem; color: rgba(184, 193, 219, 0.6); }
.version-number {
    font-size: 0.75rem; color: var(--text-gray); opacity: 0.5;
    letter-spacing: 0.05em; text-decoration: none;
    transition: opacity 0.2s;
}
.version-number:hover { opacity: 1; text-decoration: underline; }

@media (min-width: 500px) {
    .login-header {
        display: flex; align-items: center; gap: 1.5rem;
        text-align: left; margin-bottom: 1.5rem;
    }
    .login-logo-wrap { margin-bottom: 0; }
    .login-logo { width: 130px; height: 130px; }
    .login-header-text { align-items: flex-start; flex: 1; min-width: 0; }
    .login-title-row { justify-content: flex-start; }
}

.setup-form { display: flex; flex-direction: column; gap: 1rem; }
.setup-form .btn-text { margin-top: 0.25rem; }
#home-auth { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-hint {
    font-size: 0.8rem;
    color: var(--text-gray);
    opacity: 0.7;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 0.25rem;
    max-width: 400px;
    align-self: center;
}

.btn {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.875rem 2rem; border: none; border-radius: 50px;
    font-family: var(--font-family); font-size: 1rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.btn-primary {
    background: var(--gradient-blue);
    color: var(--text-white);
    width: 100%;
}
.btn-primary:hover:not(:disabled) {
    background: var(--gradient-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 111, 165, 0.3);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    color: var(--text-white);
    border: 2px solid rgba(184, 193, 219, 0.35);
    width: 100%;
}
.btn-secondary:hover {
    background: rgba(184, 193, 219, 0.08);
    border-color: rgba(184, 193, 219, 0.65);
    transform: translateY(-2px);
}

.btn-text {
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    width: 100%;
}
.btn-text:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.btn-icon { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.btn-text .btn-icon { filter: brightness(0) invert(0.45); transition: filter 0.15s ease; }
.btn-text:hover .btn-icon { filter: brightness(0) invert(0.8); }

.btn-discord {
    background: #5865F2;
    color: white;
    width: 100%;
}
.btn-discord:hover { background: #4752C4; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(88, 101, 242, 0.3); }
.discord-icon { width: 22px; height: 22px; filter: brightness(0) invert(1); }

.auth-divider {
    display: flex; align-items: center; gap: 1rem;
    color: var(--text-gray); font-size: 0.85rem;
    margin: 0.25rem 0;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px;
    background: var(--card-border);
}

.home-play-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.home-stats-row {
    display: flex;
    gap: 0.5rem;
}

.home-stats-row .btn {
    flex: 1;
    min-width: 0;
}

.mode-leaderboard-link {
    text-decoration: none;
    width: 100%;
    color: var(--text-gray);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    background: transparent;
}

.mode-leaderboard-link:hover {
    text-decoration: none;
    color: var(--text-white);
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.mode-leaderboard-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(0.7);
    transition: filter 0.3s ease;
}

.mode-leaderboard-link:hover .mode-leaderboard-icon {
    filter: brightness(0) invert(1);
}

#screen-home .setup-container {
    max-width: 650px;
}

.mode-greeting {
    display: flex; align-items: center; justify-content: center;
    margin-top: 0.6rem;
}
.mode-greeting-info { display: flex; align-items: center; gap: 0.5rem; }
.greeting-avatar {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
    flex-shrink: 0; opacity: 0.85;
}
.greeting-text { font-size: 1.15rem; color: var(--text-gray); }
.greeting-logout-btn {
    background: transparent; border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer; padding: 4px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.2s, background 0.2s;
    margin-left: 0.1rem;
}
.greeting-logout-btn img {
    width: 16px; height: 16px;
    opacity: 1; filter: invert(1);
}
.greeting-logout-btn:hover {
    color: rgba(255, 80, 80, 0.85);
    background: rgba(255, 80, 80, 0.1);
}
.greeting-logout-btn:hover img {
    filter: invert(40%) sepia(1) saturate(5) hue-rotate(320deg);
}

.hidden { display: none !important; }

.donation-cta {
    padding: 1.25rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(114, 164, 242, 0.1) 0%, rgba(74, 111, 165, 0.1) 100%);
    border-radius: 16px;
    border: 1px solid rgba(114, 164, 242, 0.2);
    backdrop-filter: blur(10px);
    max-width: 500px;
    width: 100%;
    position: relative; overflow: hidden;
}
.donation-cta::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(114, 164, 242, 0.12), transparent 70%);
    pointer-events: none;
}
.donation-cta h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.35rem; }
.donation-cta p  { font-size: 0.85rem; color: var(--text-gray); margin-bottom: 1rem; }
.kofi-button {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: linear-gradient(135deg, #72a4f2 0%, #4a6fa5 100%);
    color: white; padding: 0.65rem 1.5rem;
    border-radius: 50px; font-weight: 600; font-size: 0.9rem;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(114, 164, 242, 0.3);
}
.kofi-button:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(114, 164, 242, 0.5); text-decoration: none; }
.kofi-icon-svg { width: 20px; height: 20px; flex-shrink: 0; }

.difficulty-picker {
    display: flex; flex-direction: column; align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(74, 111, 165, 0.07);
    border: 1px solid rgba(74, 111, 165, 0.2);
    border-radius: 16px;
}

.difficulty-display {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    transition: opacity 0.15s;
}

.difficulty-stars {
    font-size: 1.6rem; color: #ffc107; letter-spacing: 3px;
    transition: letter-spacing 0.2s;
}

.difficulty-name {
    font-size: 1.4rem; font-weight: 700; color: var(--text-white);
    transition: color 0.2s;
}


.diff-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(184, 193, 219, 0.15);
    outline: none;
    cursor: pointer;
}

.diff-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--gradient-blue);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.4);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.diff-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(74, 111, 165, 0.6);
}

.diff-slider::-moz-range-thumb {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--gradient-blue);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.4);
    cursor: pointer;
}

.diff-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(184, 193, 219, 0.15);
    border: none;
}

.diff-labels {
    display: flex; justify-content: space-between;
    width: 100%;
    font-size: 0.7rem;
    color: var(--text-gray);
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mode-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-gray);
    opacity: 0.9;
    margin-bottom: -0.5rem;
}
.mode-selector {
    display: flex;
    gap: 0.5rem;
}
.mode-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-gray);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mode-btn:hover {
    border-color: rgba(74, 111, 165, 0.5);
    background: rgba(74, 111, 165, 0.08);
    color: var(--text-white);
}
.mode-btn.active {
    background: rgba(74, 111, 165, 0.2);
    border-color: rgba(74, 111, 165, 0.5);
    color: var(--text-white);
}
.mode-desc {
    font-size: 0.78rem;
    color: var(--text-gray);
    opacity: 0.7;
    text-align: center;
    line-height: 1.4;
    margin: -0.25rem 0 0;
}

.difficulty-picker[data-level="easy"]   .difficulty-name { color: #a5d6a7; }
.difficulty-picker[data-level="medium"] .difficulty-name { color: #ffd180; }
.difficulty-picker[data-level="hard"]   .difficulty-name { color: #ef9a9a; }
.difficulty-picker[data-level="expert"] .difficulty-name { color: #e1bee7; }

.game-container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0;
}

.game-stat { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.game-stat-label { font-size: 0.7rem; color: var(--text-gray); text-transform: uppercase; letter-spacing: 1px; }
.game-stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.game-difficulty-badge {
    font-size: 0.8rem; font-weight: 600;
    padding: 0.3rem 1rem;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.badge-easy   { background: rgba(76, 175, 80, 0.2); color: #a5d6a7; border: 1px solid rgba(76, 175, 80, 0.3); }
.badge-medium { background: rgba(255, 152, 0, 0.2); color: #ffd180; border: 1px solid rgba(255, 152, 0, 0.3); }
.badge-hard   { background: rgba(244, 67, 54, 0.2); color: #ef9a9a; border: 1px solid rgba(244, 67, 54, 0.3); }
.badge-expert { background: rgba(156, 39, 176, 0.2); color: #e1bee7; border: 1px solid rgba(156, 39, 176, 0.3); }

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, var(--cell-size));
    grid-template-rows: repeat(9, var(--cell-size));
    gap: var(--board-gap);
    background: rgba(184, 193, 219, 0.15);
    border: var(--board-border) solid rgba(184, 193, 219, 0.4);
    border-radius: 8px;
    padding: var(--board-gap);
    user-select: none;
}

.sudoku-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * 0.5);
    font-weight: 700;
    font-family: var(--font-family);
    background: rgba(10, 14, 39, 0.85);
    color: var(--text-white);
    border: none;
    cursor: pointer;
    transition: background 0.12s ease;
    position: relative;
    padding: 0;
}

.sudoku-cell:hover { background: rgba(74, 111, 165, 0.15); }

.sudoku-cell.given { color: var(--text-gray); font-weight: 400; }
.sudoku-cell.user-placed { color: #72a4f2; }

.sudoku-cell.selected { background: rgba(74, 111, 165, 0.35); }
.sudoku-cell.highlighted { background: rgba(74, 111, 165, 0.12); }
.sudoku-cell.same-number { background: rgba(74, 111, 165, 0.22); }

.sudoku-cell.conflict {
    color: var(--error-color) !important;
    background: rgba(244, 67, 54, 0.1) !important;
}
.sudoku-cell.error-cell {
    color: var(--error-color) !important;
    background: rgba(244, 67, 54, 0.1) !important;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%; height: 100%;
    padding: 1px;
}
.notes-grid span {
    display: flex; align-items: center; justify-content: center;
    font-size: calc(var(--cell-size) * 0.22);
    font-weight: 400;
    color: rgba(184, 193, 219, 0.6);
    line-height: 1;
}


.sudoku-cell.win {
    animation: cellWin 0.5s ease forwards;
}
@keyframes cellWin {
    0%   { background: rgba(10, 14, 39, 0.85); }
    50%  { background: rgba(76, 175, 80, 0.25); }
    100% { background: rgba(76, 175, 80, 0.1); }
}

.sudoku-cell.border-left { box-shadow: -2px 0 0 0 rgba(184, 193, 219, 0.4); }
.sudoku-cell.border-top  { box-shadow: 0 -2px 0 0 rgba(184, 193, 219, 0.4); }
.sudoku-cell.border-left.border-top { box-shadow: -2px 0 0 0 rgba(184, 193, 219, 0.4), 0 -2px 0 0 rgba(184, 193, 219, 0.4); }

.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    width: 100%;
    max-width: calc(var(--cell-size) * 9 + var(--board-gap) * 10);
}

.numpad-btn {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 700;
    font-family: var(--font-family);
    background: rgba(74, 111, 165, 0.15);
    border: 1px solid rgba(74, 111, 165, 0.25);
    border-radius: 10px;
    color: var(--text-white);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.numpad-btn:hover {
    background: rgba(74, 111, 165, 0.3);
    transform: translateY(-2px);
}
.numpad-btn:active { transform: translateY(0); }
.numpad-btn.completed { opacity: 0.25; pointer-events: none; }

.game-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: calc(var(--cell-size) * 9 + var(--board-gap) * 10);
    justify-content: center;
}

.action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-gray);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-family);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    flex: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.action-icon { width: 20px; height: 20px; filter: brightness(0) invert(0.7); transition: filter 0.15s; }
.action-btn:hover .action-icon { filter: brightness(0) invert(1); }
.action-btn.active .action-icon { filter: brightness(0) invert(1); }
.action-btn:hover { background: rgba(74, 111, 165, 0.12); color: var(--text-white); border-color: rgba(74, 111, 165, 0.3); }
.action-btn.active { background: rgba(74, 111, 165, 0.2); color: #72a4f2; border-color: rgba(74, 111, 165, 0.4); }

.btn-ingame-back {
    max-width: calc(var(--cell-size) * 9 + var(--board-gap) * 10);
}


.end-container {
    max-width: 480px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}
.end-title { font-size: 2rem; font-weight: 700; text-align: center; }
.end-time-big { font-size: 3rem; font-weight: 700; color: #72a4f2; }

.final-score-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    text-align: center;
}
.final-score { margin-bottom: 1.5rem; }
.score-details { display: flex; justify-content: center; gap: 2rem; }
.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-label { font-size: 0.8rem; color: var(--text-gray); text-transform: uppercase; }
.detail-value { font-size: 1.2rem; font-weight: 700; }

.end-record {
    margin-top: 1rem;
    color: #ffc107;
    font-weight: 700;
    font-size: 1rem;
    animation: recordPulse 1.5s ease infinite;
}
@keyframes recordPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.end-score-msg {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-gray);
}

.end-streak-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1rem;
    animation: recordPulse 1.5s ease infinite;
}
.end-streak-count {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ff9800;
}
.end-streak-label {
    font-size: 0.9rem;
    color: var(--text-gray);
}

.end-actions { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; max-width: 320px; }
.end-actions .btn { width: 100%; }


/* Daily puzzle card */
.daily-card {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.06) 0%, rgba(255, 87, 34, 0.04) 100%);
    border: 1px solid rgba(255, 152, 0, 0.18);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    width: 100%;
    position: relative;
    overflow: hidden;
    text-align: center;
}
.daily-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.daily-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ffd180;
}
.daily-card-date {
    font-size: 0.7rem;
    color: var(--text-gray);
    opacity: 0.6;
}
.daily-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}
.daily-streak-display {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.daily-streak-icon {
    font-size: 1.1rem;
}
.daily-streak-count {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ff9800;
    line-height: 1;
}
.daily-streak-label {
    font-size: 0.8rem;
    color: var(--text-gray);
}
.daily-countdown {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.15rem;
}
.daily-countdown-label {
    font-size: 0.7rem;
    color: var(--text-gray);
    opacity: 0.7;
}
.daily-countdown-time {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffd180;
    font-variant-numeric: tabular-nums;
}

.btn-daily {
    background: linear-gradient(135deg, #e65100 0%, #ff9800 100%);
    color: white;
    width: auto;
    padding: 0.55rem 1.75rem;
    font-size: 0.85rem;
    border-radius: 50px;
}
.btn-daily:hover:not(:disabled) {
    background: linear-gradient(135deg, #bf360c 0%, #ffb74d 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}
.btn-daily:disabled { opacity: 0.4; cursor: not-allowed; }
.badge-daily {
    background: rgba(255, 152, 0, 0.2);
    color: #ffd180;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

#screen-daily.active { flex-direction: column; align-items: center; }

.spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(184, 193, 219, 0.15);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
.spinner-wrap { display: flex; justify-content: center; padding: 3rem 0; }
@keyframes spin { to { transform: rotate(360deg); } }

footer {
    text-align: center;
    padding: 1.5rem 2rem;
    color: var(--text-gray);
    font-size: 0.95rem;
    font-weight: 400;
    z-index: 2;
    margin-top: auto;
    opacity: 0.65;
}
.footer-links {
    display: flex; justify-content: center; align-items: center;
    gap: 0.75rem; margin-bottom: 0.5rem;
}
footer a { color: inherit; text-decoration: none; transition: color 0.3s ease; }
footer a:hover { color: var(--text-white); }

@media (max-width: 600px) {
    .lang-toggle-text { display: none; }
    .nav-logo span { display: none; }
    .nav-app-title { font-size: 1.1rem; white-space: nowrap; }
    .navbar { padding: 0.75rem 1rem; }
    .login-title { font-size: 1.5rem; }
}

@media (max-width: 540px) {
    :root { --cell-size: calc((100vw - 3rem) / 9); }

    body { padding-top: 60px; }
    .setup-container { padding: 1.5rem 1.25rem; }

    .screen { padding: 1rem; }
    #screen-home.active { gap: 1rem; }

    .home-play-layout { gap: 0.6rem; }
    .home-stats-row .btn { padding: 0.75rem 0.5rem; font-size: 0.85rem; }
    .btn-daily { padding: 0.5rem 1.2rem; font-size: 0.8rem; }
    .daily-card { padding: 0.75rem 1rem; }
    .daily-card-body { gap: 0.5rem; }

    .game-container { gap: 0.4rem; }
    .game-header { padding: 0.25rem 0; gap: 0.5rem; }
    .game-stat-value { font-size: 1.1rem; }
    .game-difficulty-badge { font-size: 0.7rem; padding: 0.2rem 0.75rem; }

    .numpad { gap: 4px; }
    .numpad-btn { font-size: 1.1rem; border-radius: 8px; }

    .action-btn { padding: 0.4rem 0.5rem; font-size: 0.55rem; }
    .action-icon { width: 16px; height: 16px; }

    .end-time-big { font-size: 2.5rem; }
    .end-container { gap: 1rem; }
    .final-score-card { padding: 1.25rem; }

    .donation-cta { padding: 1rem; }
    .donation-cta h2 { font-size: 1rem; }
}

@media (max-width: 360px) {
    :root { --cell-size: calc((100vw - 2.5rem) / 9); }

    .setup-container { padding: 1.25rem 1rem; }
    .login-title { font-size: 1.3rem; }
    .login-subtitle { font-size: 0.8rem; }

    .btn { padding: 0.7rem 1rem; font-size: 0.85rem; }
    .home-stats-row .btn { padding: 0.65rem 0.4rem; font-size: 0.8rem; }

    .action-btn span { display: none; }
    .action-btn { padding: 0.5rem; }
    .action-icon { width: 20px; height: 20px; }

    .numpad-btn { font-size: 1rem; }
}
