:root {
    --ink: #172033;
    --muted: #778196;
    --line: #d9dfE8;
    --blue: #2d70d6;
    --blue-dark: #1d55aa;
    --blue-soft: #e7f0fc;
    --cell-soft: #f1f6fc;
    --danger: #d64c4c;
    --surface: #fff;
    --shadow: 0 18px 50px rgba(28, 51, 84, .09);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: #f7f9fc; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1120px) / 2)); background: rgba(255,255,255,.88); border-bottom: 1px solid #e9edf3; backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 750; letter-spacing: -.5px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--blue); border-radius: 9px; font-size: 18px; }
.nav-actions { display: flex; align-items: center; gap: 22px; }
.language-switch { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; }
.language-switch a { padding: 4px 7px; border-radius: 5px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 800; }
.language-switch a.active { color: white; background: var(--blue); }
.text-button, .login-link { border: 0; background: none; color: #556176; text-decoration: none; cursor: pointer; font-weight: 600; }
.text-button:hover, .login-link:hover { color: var(--blue); }
.avatar { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-weight: 800; cursor: pointer; }
.page-shell { max-width: 1060px; margin: 0 auto; padding: 42px 24px 64px; }
.game-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: 1.6px; }
h1, h2 { margin: 0; letter-spacing: -.8px; }
.game-heading h1 { font-size: 28px; }
.game-heading h1 span { color: var(--muted); font-weight: 500; }
.game-heading h1 .title-main { color: var(--ink); font-weight: 700; }
.completion-rate { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.completion-rate b { color: var(--blue); font-variant-numeric: tabular-nums; }
.difficulty-control { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; font-weight: 600; }
.difficulty-control select { min-width: 134px; padding: 10px 34px 10px 13px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.game-layout { display: grid; grid-template-columns: minmax(420px, 570px) 1fr; gap: 52px; align-items: center; }
.board-panel { min-width: 0; }
.game-meta { height: 32px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; color: var(--muted); font-size: 13px; }
.game-meta b { color: var(--danger); }
.live-score { color: var(--muted); }
.live-score b { color: var(--blue); font-variant-numeric: tabular-nums; }
.timer { color: #526076; font-variant-numeric: tabular-nums; font-weight: 700; }
.timer { justify-self: end; }
.sudoku-board { aspect-ratio: 1; display: grid; grid-template-columns: repeat(9, 1fr); overflow: hidden; background: var(--surface); border: 2px solid #34465f; box-shadow: var(--shadow); user-select: none; }
.sudoku-board.loading { opacity: .45; pointer-events: none; }
.cell { position: relative; display: grid; place-items: center; padding: 0; color: var(--blue); background: white; border: 0; border-right: 1px solid #bec8d5; border-bottom: 1px solid #bec8d5; font-size: clamp(20px, 4.1vw, 34px); font-weight: 500; cursor: pointer; }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid #56677d; }
.cell:nth-child(n+19):nth-child(-n+27), .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid #56677d; }
.cell.fixed { color: #28384d; font-weight: 650; }
.cell.related { background: var(--cell-soft); }
.cell.same { background: #dceafb; }
.cell.selected { z-index: 1; background: #c9def8; box-shadow: inset 0 0 0 2px var(--blue); }
.cell.conflict { color: var(--danger); background: #fdeaea; }
.cell.wrong { color: var(--danger); background: #ffe3e3; box-shadow: inset 0 0 0 2px rgba(214, 76, 76, .45); animation: wrong-cell .2s ease-in-out; }
.sudoku-board.ended, .controls-panel.ended .tool-row, .controls-panel.ended .number-pad { pointer-events: none; opacity: .68; }
@keyframes wrong-cell { 0%, 100% { transform: translateX(0); } 35% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
.notes-grid { position: absolute; inset: 3px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); color: var(--blue); font-size: clamp(7px, 1.4vw, 12px); line-height: 1; }
.notes-grid i { display: grid; place-items: center; font-style: normal; }
.controls-panel { display: flex; flex-direction: column; gap: 22px; max-width: 390px; }
.tool-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.tool { min-width: 0; padding: 0; border: 0; color: #566176; background: none; font-size: 12px; cursor: pointer; }
.tool > span { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 7px; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-size: 23px; font-weight: 700; transition: .15s; }
.tool:hover > span, .tool.active > span { color: white; background: var(--blue); transform: translateY(-1px); }
.tool small { display: block; color: var(--blue); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.number-pad { display: grid; grid-template-columns: repeat(9,1fr); gap: 4px; }
.number-pad button { height: 54px; padding: 0; border: 0; border-radius: 7px; color: var(--blue); background: var(--blue-soft); font-size: 26px; font-weight: 600; cursor: pointer; transition: .12s; }
.number-pad button:hover { color: white; background: var(--blue); transform: translateY(-2px); }
.primary-button { width: 100%; min-height: 52px; border: 0; border-radius: 9px; color: white; background: var(--blue); box-shadow: 0 8px 20px rgba(45,112,214,.22); font-weight: 750; cursor: pointer; transition: .15s; }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.secondary-button { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 9px; color: #596579; background: white; font-weight: 700; cursor: pointer; }
.secondary-button:hover { color: var(--blue); border-color: #b8c9e3; background: #f7faff; }
.danger-button { width: 100%; min-height: 46px; border: 0; border-radius: 9px; color: white; background: var(--danger); font-weight: 750; cursor: pointer; }
.danger-button:hover { background: #b93b3b; }
.status-message, .mobile-message { min-height: 20px; margin: -10px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.status-message.error, .mobile-message.error, .form-error { color: var(--danger); }
.mobile-message { display: none; }
dialog { width: min(430px, calc(100% - 32px)); padding: 38px; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 90px rgba(18,35,60,.25); text-align: center; }
dialog::backdrop { background: rgba(24,35,52,.45); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--muted); font-size: 27px; cursor: pointer; }
.result-icon { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: white; background: #4bb589; font-size: 30px; }
.game-over-dialog .result-icon { background: var(--danger); }
.result-dialog h2, .leaderboard-dialog h2, .profile-dialog h2 { margin-bottom: 8px; font-size: 28px; }
.result-dialog > p:not(.eyebrow) { color: var(--muted); }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 26px 0; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-stats div + div { border-left: 1px solid var(--line); }
.result-stats b, .result-stats span { display: block; }
.result-stats b { color: var(--blue); font-size: 23px; }
.result-stats span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.leaderboard-list { margin-top: 24px; text-align: left; }
.personal-best-section { margin-top: 24px; padding: 18px; border-radius: 13px; background: #f5f8fc; text-align: left; }
.personal-best-section h3, .community-title { margin: 0; color: #536076; font-size: 13px; letter-spacing: .2px; }
.personal-best-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 13px; }
.personal-best-card { min-width: 0; padding: 10px 4px; border: 1px solid #e5ebf3; border-radius: 9px; background: white; text-align: center; }
.personal-best-card span, .personal-best-card b { display: block; }
.personal-best-card span { color: var(--muted); font-size: 10px; }
.personal-best-card b { margin-top: 4px; color: var(--blue); font-size: 15px; font-variant-numeric: tabular-nums; }
.community-title { margin-top: 25px; text-align: left; }
.community-title + .leaderboard-list { margin-top: 10px; }
.leaderboard-entry { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; column-gap: 14px; padding: 14px 3px; border-bottom: 1px solid #edf0f4; }
.leaderboard-entry .rank { color: var(--muted); font-weight: 800; }
.leaderboard-entry .name { min-width: 0; display: flex; flex-direction: column; gap: 5px; overflow-wrap: anywhere; font-weight: 650; line-height: 1.25; }
.leaderboard-entry .name small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.25; }
.leaderboard-entry .points { margin-left: 4px; color: var(--blue); font-weight: 750; white-space: nowrap; }
.profile-dialog { text-align: left; }
.profile-dialog .eyebrow, .profile-dialog h2, .profile-username { text-align: center; }
.profile-avatar { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; color: var(--blue-dark); background: var(--blue-soft); font-size: 26px; font-weight: 800; }
.profile-username { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.profile-details { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.profile-details div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; }
.profile-details span { color: var(--muted); font-size: 12px; }
.profile-details b { overflow-wrap: anywhere; color: #4d596d; text-align: right; font-size: 13px; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0; }
.profile-stats div { min-width: 0; text-align: center; }
.profile-stats div + div { border-left: 1px solid var(--line); }
.profile-stats b, .profile-stats span { display: block; }
.profile-stats b { color: var(--blue); font-size: 20px; font-variant-numeric: tabular-nums; }
.profile-stats span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.profile-form { display: grid; gap: 8px; }
.profile-form label { color: #4f5a6d; font-size: 13px; font-weight: 700; }
.profile-form input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.profile-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.profile-form .form-error { min-height: 18px; margin: 0; }
.profile-form .form-error.success { color: #268463; }
.profile-form .primary-button { min-height: 46px; }
.logout-button { margin-top: 10px; color: var(--danger); }
.logout-button:hover { color: #b73535; border-color: #efcaca; background: #fff8f8; }
.confirm-dialog { max-width: 400px; text-align: center; }
.confirm-dialog h2 { margin: 0 0 10px; font-size: 25px; }
.confirm-dialog > p { margin: 0; color: var(--muted); line-height: 1.55; }
.confirm-icon { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: var(--danger); background: #fff0f0; }
.confirm-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.auth-page { min-height: 100vh; background: radial-gradient(circle at 15% 15%, #e9f2ff, transparent 28%), #f7f9fc; }
.auth-page.auth-pending .auth-shell { visibility: hidden; }
.auth-shell { min-height: calc(100vh - 72px); display: grid; place-items: center; padding: 36px 20px; }
.auth-card { width: min(440px, 100%); padding: 40px; background: white; border: 1px solid #edf0f5; border-radius: 18px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 30px; }
.auth-subtitle { margin: 10px 0 25px; color: var(--muted); line-height: 1.55; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 22px; padding: 4px; background: #f0f3f7; border-radius: 9px; }
.auth-tabs button { padding: 9px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 700; }
.auth-tabs button.active { color: var(--blue); background: white; box-shadow: 0 2px 7px rgba(30,50,80,.09); }
.auth-card form { display: grid; gap: 16px; }
.auth-card label { display: grid; gap: 7px; color: #4f5a6d; font-size: 13px; font-weight: 700; }
.form-field { display: grid; gap: 7px; }
.required-note { margin: -4px 0 0; color: var(--muted); font-size: 12px; }
.required-marker { color: var(--danger); font-weight: 800; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; }
.auth-card input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 50px; }
.password-toggle { position: absolute; top: 50%; right: 4px; width: 40px; height: 40px; padding: 9px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; transform: translateY(-50%); }
.password-toggle:hover { color: var(--blue); background: var(--blue-soft); }
.password-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.password-toggle svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-closed { display: none; }
.password-toggle.visible .eye-open { display: none; }
.password-toggle.visible .eye-closed { display: block; }
.form-error { min-height: 18px; margin: -2px 0; font-size: 13px; }
.forgot-password-link { display: block; margin-top: 15px; color: var(--blue); text-align: center; text-decoration: none; font-size: 13px; font-weight: 650; }
.forgot-password-link:hover { text-decoration: underline; }
.guest-link { display: block; margin-top: 22px; color: var(--muted); text-align: center; text-decoration: none; font-size: 13px; }
.guest-link:hover { color: var(--blue); }
.password-reset-card { text-align: center; }
.password-reset-card form { text-align: left; }
.recovery-icon { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: var(--blue); background: var(--blue-soft); }
.recovery-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reset-result { padding: 22px 18px; border: 1px solid #cfe9df; border-radius: 12px; color: #276d56; background: #f1fbf7; line-height: 1.55; }
.reset-result p { margin: 10px 0 0; }
.result-check { width: 38px; height: 38px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; color: white; background: #45a77f; font-weight: 800; }
@media (max-width: 820px) {
    .topbar { height: 62px; padding: 0 16px; }
    .brand { font-size: 19px; }
    .brand-mark { width: 30px; height: 30px; }
    .text-button { display: none; }
    .page-shell { padding: 24px 12px 42px; }
    .game-heading { align-items: center; }
    .game-heading .eyebrow { display: none; }
    .game-heading h1 { font-size: 21px; }
    .difficulty-control > span { display: none; }
    .game-layout { display: flex; flex-direction: column; gap: 23px; }
    .board-panel { width: min(100%, 570px); }
    .controls-panel { width: min(100%, 570px); max-width: none; gap: 18px; }
    .number-pad { gap: 3px; }
    .number-pad button { height: 48px; font-size: 22px; }
    .status-message { display: none; }
    .mobile-message { display: block; margin-top: 12px; }
}
@media (max-width: 430px) {
    .login-link { font-size: 13px; }
    .game-heading { margin-bottom: 12px; }
    .game-meta { height: 28px; }
    .cell { font-size: 25px; }
    .tool-row { gap: 2px; }
    .tool > span { width: 43px; height: 43px; }
    dialog { padding: 34px 24px 26px; }
    .auth-card { padding: 30px 22px; }
    .personal-best-list { grid-template-columns: repeat(3, 1fr); }
    .leaderboard-entry { column-gap: 10px; }
}
