/* Outfit (SIL Open Font License, fonts/OFL.txt), served by the app: works offline and sends nothing to third parties */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/outfit-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/outfit-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg-primary: #f0f7f6;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(255, 255, 255, 0.6);
    --text-main: #2d3748;
    --text-muted: #64748b;
    --accent-blue: #0284c7;
    /* accent-blue has 4.1:1 on white; small text needs 4.5:1 (WCAG AA) */
    --accent-blue-text: #0369a1;
    --news-bg: #f0f9ff;
    --news-border: #bae6fd;
    --accent-mint: #10b981;
    --accent-peach: #f97316;
    --accent-gold: #eab308;
    --accent-pink: #ec4899;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.35);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    --gutter: var(--space-4);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

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

* {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0fdf4 50%, #fdf2f8 100%);
    color: var(--text-main);
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

:focus-visible {
    outline: 3px solid rgba(2, 132, 199, 0.45);
    outline-offset: 2px;
}

/* App shell */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.06);
    /* No backdrop blur: behind it is only the page gradient, and a blur would be redone for every game frame */
    background: rgba(255, 255, 255, 0.4);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + var(--safe-top)) 16px 10px;
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 10;
}

.brand-title {
    flex: none;
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #0284c7, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: min(62%, 280px);
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-glass);
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.15s ease;
}

.player-badge:active {
    transform: scale(0.96);
}

.player-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-nav-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
    max-width: 72%;
}

.top-nav-actions .player-badge {
    max-width: 100%;
}

.install-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, #0369a1, #047857);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(2, 132, 199, 0.3);
    animation: installChipIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.install-chip:active {
    transform: scale(0.95);
}

@keyframes installChipIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.install-done {
    color: #047857;
    font-weight: 600;
}

.install-steps {
    margin: 0 0 0 1.3em;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}

.main-content {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bottom-nav {
    display: flex;
    justify-content: space-evenly;
    gap: 4px;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
}

.nav-tab {
    flex: 1 1 0;
    min-width: 0;
    max-width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 12px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-tab.active {
    color: var(--accent-blue-text);
    background: rgba(2, 132, 199, 0.08);
}

.tab-icon {
    font-size: 1.25rem;
    line-height: 1.2;
    transition: transform 0.2s ease;
}

.nav-tab.active .tab-icon {
    transform: translateY(-1px) scale(1.08);
}

.tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Game view */
.game-viewport {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Field shadow, the rectangle comes from game.js */
.game-viewport::before {
    content: "";
    position: absolute;
    left: var(--field-x, 0px);
    top: var(--field-y, 0px);
    width: var(--field-w, 100%);
    height: var(--field-h, 100%);
    border-radius: var(--field-radius, 0px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

/* game.js sets data-fill when the scene fills the whole view (phones) */
.game-viewport[data-fill]::before {
    display: none;
}

.game-viewport[hidden] {
    display: none;
}

/* Not found and error pages; they have no app shell to hide the loader */
.status-page {
    min-height: 100dvh;
    display: flex;
    padding: 20px;
    text-align: center;
}

.status-page .play-btn {
    text-decoration: none;
}

/* The account confirm button sits in the card like the other buttons */
.status-page form {
    display: contents;
}

.status-page ~ #app-loader {
    display: none;
}

/* Privacy and cookie pages; the body does not scroll, so the page does */
.legal-page {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: calc(var(--space-5) + var(--safe-top)) calc(var(--gutter) + var(--safe-right)) calc(var(--space-6) + var(--safe-bottom)) calc(var(--gutter) + var(--safe-left));
}

.legal-page,
.legal-page * {
    user-select: text;
    -webkit-user-select: text;
}

.legal-page ~ #app-loader {
    display: none;
}

.legal-card {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-6);
    border-radius: 24px;
    background: var(--bg-surface);
    box-shadow: var(--shadow-soft);
    line-height: 1.55;
}

.legal-card h1 {
    font-size: 1.8rem;
    line-height: 1.2;
    color: #1e293b;
}

.legal-card h2 {
    margin-top: var(--space-3);
    font-size: 1.15rem;
    color: #1e293b;
}

.legal-card ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-left: 1.3em;
}

.legal-card a {
    color: var(--accent-blue-text);
    font-weight: 600;
}

.legal-back {
    align-self: flex-start;
}

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

.legal-table-wrap {
    overflow-x: auto;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.legal-table th,
.legal-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.legal-table th {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legal-table code {
    font-size: 0.85em;
    white-space: nowrap;
}

.legal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.legal-footer a[aria-current="page"] {
    color: var(--text-main);
    text-decoration: none;
}

@media (max-width: 440px) {
    .legal-card {
        padding: var(--space-4);
    }
}

/* Admin (Components/Pages/Admin.razor); the body does not scroll, so the page does */
.admin-page {
    height: 100vh;
    height: 100dvh;
    max-width: 1200px;
    margin: 0 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: calc(var(--space-5) + var(--safe-top)) calc(var(--gutter) + var(--safe-right)) calc(var(--space-6) + var(--safe-bottom)) calc(var(--gutter) + var(--safe-left));
}

.admin-page,
.admin-page * {
    user-select: text;
    -webkit-user-select: text;
}

.admin-page ~ #app-loader {
    display: none;
}

.admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
}

.admin-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
}

/* FocusOnNavigate focuses the heading for screen readers; it is not interactive */
.admin-header h1:focus {
    outline: none;
}

/* Five sections do not fit a phone in German, so the buttons wrap instead of running off the screen */
.admin-header .segmented {
    flex-wrap: wrap;
    max-width: 100%;
}

.admin-user {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    color: var(--text-muted);
    font-weight: 600;
}

.admin-subtitle {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1e293b;
    overflow-wrap: anywhere;
}

.admin-page .segmented {
    align-self: flex-start;
    flex-wrap: wrap;
}

.admin-page a.segment-btn {
    display: inline-block;
    text-decoration: none;
}

.admin-table a {
    color: var(--accent-blue-text);
    font-weight: 600;
    text-decoration: none;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-3);
}

.admin-stats .stat-box {
    background: var(--bg-surface);
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    padding: var(--space-2);
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.admin-table td {
    padding: var(--space-2);
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}

.admin-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.admin-nickname {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-row-flagged {
    background: #fef2f2;
}

/* Trends (Components/Pages/AdminTrends.razor); bars are sized in percent, so the chart follows the panel width */
.range-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.range-form label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.range-form input[type="date"] {
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
}

.range-form .play-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

a.stat-box {
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

a.stat-box.active {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

a.stat-box:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.chart {
    margin: var(--space-4) 0 0;
}

.chart-body {
    display: flex;
    gap: var(--space-3);
}

.chart-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    min-width: 46px;
    height: 240px;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.chart-plot {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 240px;
    padding-bottom: 1px;
    border-bottom: 1px solid #e2e8f0;
    background-image: repeating-linear-gradient(to top, #edf2f7 0 1px, transparent 1px 25%);
}

.chart-col {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
    min-width: 3px;
}

.chart-bar {
    width: 100%;
    max-width: 38px;
    min-height: 2px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #38bdf8, var(--accent-blue));
}

.chart-bar-empty {
    min-height: 0;
    background: none;
}

.chart-labels {
    display: flex;
    gap: 2px;
    margin-left: calc(46px + var(--space-3));
    padding-top: var(--space-2);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.chart-labels span {
    flex: 1;
    min-width: 3px;
    text-align: center;
    white-space: nowrap;
}

.chart-label-hidden {
    visibility: hidden;
}

.admin-details {
    margin-top: var(--space-4);
}

.admin-details summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .chart-scale,
    .chart-plot {
        height: 180px;
    }
}

.admin-key {
    align-self: center;
    padding: var(--space-2) var(--space-3);
    border-radius: 10px;
    background: #f1f5f9;
    font-size: 1rem;
    user-select: all;
    -webkit-user-select: all;
}

/* Rename and delete forms of the admin pages */
.admin-manage {
    gap: var(--space-4);
}

.admin-danger {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid #fee2e2;
}

.admin-row-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
}

.admin-confirm {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: 0.85rem;
    color: var(--text-main);
}

.admin-confirm input {
    margin-top: 3px;
}

.danger-btn {
    flex: none;
    padding: 10px 18px;
    border: none;
    border-radius: 14px;
    background: #b91c1c;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.danger-btn.compact {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.game-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: pointer;
}

/* Just below the HUD, left of the wind indicator; --hud-bottom comes from game.js */
.pause-btn {
    position: absolute;
    left: calc(var(--field-x, 0px) + 12px);
    top: calc(var(--field-y, 0px) + var(--hud-bottom, 60px) + 8px);
    z-index: 4;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
    color: #37474f;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -1px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    -webkit-tap-highlight-color: transparent;
}

.pause-btn:active {
    transform: scale(0.94);
}

.pause-overlay {
    animation: fadeIn 0.15s ease;
}

.pause-score {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3);
    border-radius: 18px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
}

.pause-score span {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pause-score strong {
    font-size: 2rem;
    font-weight: 800;
    color: #0284c7;
    font-variant-numeric: tabular-nums;
}

.game-start-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5;
    padding: 20px;
    text-align: center;
}

/* margin: auto keeps a tall card scrollable */
.play-card {
    margin: auto;
    background: #ffffff;
    border-radius: 28px;
    padding: var(--space-6) var(--space-5);
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.play-card-intro,
.play-card-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.play-card-intro {
    gap: var(--space-2);
}

.play-card h2 {
    font-size: 2rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.15;
}

/* Release note on the start card; it does not block the play button */
.news-banner {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
    background: var(--news-bg);
    border: 1px solid var(--news-border);
    border-radius: 14px;
    color: var(--text-main);
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: left;
}

.news-banner p {
    flex: 1;
}

.mode-badge {
    align-self: center;
    background: #ecfdf5;
    color: #047857;
    padding: 6px 14px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.rules-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.init-error {
    color: #dc2626;
}

.play-btn {
    background: linear-gradient(135deg, #0369a1, #0277b6);
    color: #ffffff;
    border: none;
    padding: 16px 28px;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.play-btn:active {
    transform: scale(0.97);
}

.play-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.play-btn.block {
    width: 100%;
}

.play-btn.compact {
    flex: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    border-radius: 14px;
    white-space: nowrap;
}

.back-btn {
    width: 100%;
}

.submit-status {
    min-height: 1.2em;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.game-over-dialog {
    margin: auto;
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    border-radius: 28px;
    padding: var(--space-6) var(--space-5);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-over-summary,
.game-over-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.game-over-dialog h3 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
}

.score-display-box {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 20px;
    padding: var(--space-4);
    border: 1px solid rgba(186, 230, 253, 0.6);
}

.score-number {
    font-size: 3rem;
    font-weight: 800;
    color: #0284c7;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.score-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.new-record-badge {
    align-self: center;
    padding: 8px 18px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    color: #78350f;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
    animation: recordPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes recordPop {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.best-compare {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
}

.rival-compare-badge {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.stat-box {
    background: #f8fafc;
    border-radius: 14px;
    padding: var(--space-3);
    border: 1px solid #e2e8f0;
    min-width: 0;
}

.stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    overflow-wrap: anywhere;
}

.stat-lbl {
    font-size: 0.75rem;
    color: #64748b;
}

.action-buttons-row {
    display: flex;
    gap: var(--space-3);
}

.restart-btn,
.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.restart-btn {
    flex: 2;
    min-width: 0;
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    border: none;
    padding: 14px;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(16, 185, 129, 0.35);
    transition: transform 0.15s ease;
}

.restart-btn:active {
    transform: scale(0.96);
}

.share-btn {
    flex: 1;
    min-width: 0;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.share-btn:active {
    transform: scale(0.97);
}

.share-btn.compact {
    flex: none;
    padding: 8px 16px;
    white-space: nowrap;
}

/* Content screens */
.scroll-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: var(--gutter);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.card-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: var(--space-5);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-soft);
    min-width: 0;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
}

.panel-title {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: anywhere;
}

.panel-desc {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-5) var(--space-2);
}

.segmented {
    display: inline-flex;
    flex: none;
    gap: var(--space-1);
    padding: var(--space-1);
    background: #f1f5f9;
    border-radius: 12px;
}

.segment-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.segment-btn.active {
    background: #ffffff;
    color: var(--accent-blue-text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.daily-card {
    gap: var(--space-3);
    text-align: center;
}

.daily-date {
    font-size: 1.8rem;
    line-height: 1.2;
}

.daily-countdown {
    background: #f8fafc;
    border-radius: 14px;
    padding: var(--space-3);
    font-weight: 600;
    color: #475569;
}

.retry-btn {
    align-self: center;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-error {
    color: #dc2626;
}

.form-message {
    font-size: 0.85rem;
    color: var(--accent-blue-text);
}

.form-success {
    font-size: 0.8rem;
    color: #047857;
}

.form-failure {
    font-size: 0.8rem;
    font-weight: 600;
    color: #dc2626;
}

.input-row {
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
}

.input-row .text-input {
    flex: 1 1 auto;
    min-width: 0;
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-input::placeholder {
    text-transform: none;
    letter-spacing: normal;
}

.create-league summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-blue-text);
    padding: var(--space-1) 0;
}

.create-league .input-row {
    margin-top: var(--space-3);
}

.league-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.league-code {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.invite-btn {
    align-self: flex-start;
    margin-top: var(--space-1);
}

.my-leagues {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.my-leagues-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-1);
    background: #f1f5f9;
    border-radius: 12px;
}

.profile-nickname {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.info-note {
    padding: var(--space-3) var(--space-4);
    background: #f8fafc;
    border-radius: 14px;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.45;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    font-weight: 600;
}

.app-version {
    margin-top: auto;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    user-select: text;
}

.app-version a,
.field-note a {
    color: var(--accent-blue-text);
    font-weight: 600;
}

/* A button among the links of the version line looks like them */
.app-version .link-btn {
    padding: 0;
}

.field-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rival-inline {
    font-size: 0.9rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.leaderboard-table th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.leaderboard-table td {
    padding: 10px;
    font-size: 0.95rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.leaderboard-table .col-rank {
    width: 48px;
}

.leaderboard-table .col-combo {
    width: 72px;
    color: #64748b;
}

.leaderboard-table td.col-combo {
    font-size: 0.85rem;
}

.leaderboard-table .col-score {
    width: 96px;
    text-align: right;
    white-space: nowrap;
}

.leaderboard-table td.col-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.leaderboard-table tr.current-player {
    background: #e0f2fe;
    font-weight: 700;
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.player-cell-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-cell-combo {
    display: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.you-tag {
    flex: none;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent-blue-text);
    background: rgba(2, 132, 199, 0.1);
    padding: 2px 7px;
    border-radius: 999px;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}

.rank-1 { background: #fef08a; color: #854d0e; }
.rank-2 { background: #e2e8f0; color: #475569; }
.rank-3 { background: #fed7aa; color: #9a3412; }

.text-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-family: inherit;
    /* iOS zooms into inputs below 16px */
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: text;
    -webkit-user-select: text;
}

.text-input:focus {
    border-color: var(--accent-blue-text);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

.language-select {
    width: auto;
    min-width: 0;
    max-width: 60%;
    padding: 8px 12px;
    cursor: pointer;
}

.language-select.compact {
    max-width: 100%;
    padding: 6px 10px;
    border-color: transparent;
    background-color: #f1f5f9;
    color: #475569;
}

/* Rules link and language picker under the play button of the start card */
.start-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-1) var(--space-4);
}

.start-language {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
}

.link-btn {
    border: none;
    background: none;
    padding: 6px 4px;
    color: var(--accent-blue-text);
    font-weight: 600;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

/* Native modal dialog; the browser keeps focus inside and makes the rest of the app inert */
.modal-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: calc(var(--space-4) + var(--safe-top)) calc(var(--space-4) + var(--safe-right)) calc(var(--space-4) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
    border: none;
    background: transparent;
    color: inherit;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-dialog[open] {
    display: flex;
}

.modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

/* Rules dialog (RulesDialog.razor) */
.rules-dialog {
    margin: auto;
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
    border-radius: 28px;
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: left;
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.rules-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.rules-header h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
}

.icon-btn {
    flex: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: #f1f5f9;
    color: #475569;
    font-size: 1rem;
    cursor: pointer;
}

.rules-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}

.rules-section h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-blue-text);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.rules-list {
    margin: 0 0 0 1.2em;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bubble-legend {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble-legend li {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bubble-legend strong {
    display: block;
    color: #1e293b;
}

.bubble-icon {
    flex: none;
    width: 48px;
    height: 48px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (hover: hover) and (pointer: fine) {
    .play-btn:not(:disabled):hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 26px rgba(2, 132, 199, 0.45);
    }

    .nav-tab:not(.active):hover,
    .segment-btn:not(.active):hover {
        color: var(--accent-blue-text);
    }

    .share-btn:hover {
        background: #e2e8f0;
    }

    .player-badge:hover {
        transform: translateY(-1px);
    }
}

.nickname-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    text-align: left;
}

.nickname-field label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.nickname-input {
    font-weight: 600;
    text-align: center;
    font-size: 1.1rem;
    background: #f8fafc;
}

.nickname-field.compact {
    gap: var(--space-1);
}

.nickname-field.compact .nickname-input {
    padding: 9px 14px;
    font-size: 1rem;
}

.nickname-field.has-error .nickname-input {
    border-color: #f87171;
    box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.15);
    animation: nicknameShake 0.35s ease;
}

.nickname-error {
    font-size: 0.78rem;
    color: #dc2626;
    font-weight: 600;
}

@keyframes nicknameShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* Loader (markup in App.razor) */
#app-loader {
    position: fixed;
    inset: 0;
    z-index: 900; /* under #blazor-error-ui */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 15%, rgba(186, 230, 253, 0.8), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(251, 207, 232, 0.7), transparent 45%),
        linear-gradient(135deg, #e0f2fe 0%, #f0fdf4 50%, #fdf2f8 100%);
    transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}

.app-container.app-ready ~ #app-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-container.app-ready ~ #app-loader .loader-card {
    transform: scale(1.06);
}

.app-container.app-ready ~ #app-loader *,
.app-container.app-ready ~ #app-loader *::before,
.app-container.app-ready ~ #app-loader *::after {
    animation-play-state: paused;
}

.app-container.app-ready ~ #app-loader .loader-slow {
    display: none;
}

.loader-sky span {
    position: absolute;
    left: var(--x);
    bottom: calc(var(--s) * -1.5);
    width: var(--s);
    height: var(--s);
    animation: loaderRise var(--d) linear var(--delay) infinite;
}

.loader-sky i {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 14%, transparent 16%),
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.9), rgba(129, 212, 250, 0.45) 60%, rgba(3, 155, 229, 0.55) 100%);
    box-shadow: inset 0 0 0 1.5px rgba(3, 155, 229, 0.35), 0 4px 12px rgba(2, 132, 199, 0.12);
    animation: loaderSway calc(var(--d) / 3) ease-in-out var(--delay) infinite alternate;
}

.loader-sky span:nth-child(3n) i {
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 14%, transparent 16%),
        radial-gradient(circle at 35% 35%, #fffde7, rgba(253, 216, 53, 0.55) 60%, rgba(245, 127, 23, 0.55) 100%);
    box-shadow: inset 0 0 0 1.5px rgba(245, 127, 23, 0.35), 0 0 16px rgba(255, 215, 0, 0.35);
}

.loader-sky span:nth-child(4n+2) i {
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 14%, transparent 16%),
        radial-gradient(circle at 35% 35%, #e0f2f1, rgba(128, 203, 196, 0.5) 60%, rgba(0, 137, 123, 0.5) 100%);
    box-shadow: inset 0 0 0 1.5px rgba(0, 137, 123, 0.3);
}

@keyframes loaderRise {
    0% { transform: translateY(0) scale(0.9); opacity: 0; }
    8% { opacity: 1; }
    82% { transform: translateY(calc(-100vh - 40px)) scale(1); opacity: 1; }
    90% { transform: translateY(calc(-100vh - 60px)) scale(1.35); opacity: 0.6; }
    100% { transform: translateY(calc(-100vh - 70px)) scale(1.6); opacity: 0; }
}

@keyframes loaderSway {
    from { transform: translateX(calc(var(--drift) * -1)) rotate(-6deg); }
    to { transform: translateX(var(--drift)) rotate(6deg); }
}

.loader-card {
    position: relative;
    width: min(340px, 100%);
    padding: 34px 28px 28px;
    border-radius: 32px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 30px 60px -20px rgba(2, 132, 199, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    text-align: center;
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.5s ease;
}

.loader-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.loader-bubble {
    position: relative;
    width: 86px;
    height: 86px;
    animation: loaderBob 2.4s ease-in-out infinite;
}

.loader-bubble i {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 26%, #ffffff 0 12%, transparent 14%),
        radial-gradient(circle at 70% 72%, rgba(255, 255, 255, 0.7) 0 5%, transparent 6%),
        conic-gradient(from 0deg, rgba(255, 182, 193, 0.55), rgba(255, 245, 157, 0.55), rgba(165, 214, 167, 0.5), rgba(129, 212, 250, 0.6), rgba(206, 147, 216, 0.55), rgba(255, 182, 193, 0.55)),
        #bae6fd;
    box-shadow: inset 0 0 0 2px rgba(3, 155, 229, 0.35), inset -8px -10px 20px rgba(2, 132, 199, 0.25), 0 12px 30px rgba(2, 132, 199, 0.25);
    animation: loaderJelly 2.4s ease-in-out infinite;
}

.loader-bubble::before,
.loader-bubble::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(56, 189, 248, 0.55);
    animation: loaderRing 2.4s ease-out infinite;
}

.loader-bubble::after {
    animation-delay: 1.2s;
}

.loader-title {
    font-weight: 800;
    font-size: 2.4rem;
    line-height: 1;
    background: linear-gradient(135deg, #0284c7, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes loaderBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes loaderJelly {
    0%, 100% { transform: scale(1, 1) rotate(0deg); }
    25% { transform: scale(1.06, 0.95) rotate(90deg); }
    50% { transform: scale(0.96, 1.05) rotate(180deg); }
    75% { transform: scale(1.04, 0.97) rotate(270deg); }
}

@keyframes loaderRing {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.9); opacity: 0; }
}

.loader-progress {
    position: relative;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    overflow: hidden;
}

.loader-progress-bar {
    position: relative;
    height: 100%;
    width: max(8%, var(--blazor-load-percentage, 0%));
    border-radius: inherit;
    background: linear-gradient(90deg, #38bdf8, #10b981);
    transition: width 0.3s ease;
    overflow: hidden;
}

.loader-progress-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
    transform: translateX(-100%);
    animation: loaderShimmer 1.4s ease-in-out infinite;
}

@keyframes loaderShimmer {
    to { transform: translateX(100%); }
}

.loader-text {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-weight: 600;
    color: #475569;
    font-size: 0.95rem;
}

.loader-dots::after {
    content: "";
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: loaderDots 1.5s steps(4, end) infinite;
}

@keyframes loaderDots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75%, 100% { content: "..."; }
}

.loader-starting,
.loader-is-starting .loader-downloading,
.loader-is-starting .loader-percent {
    display: none;
}

.loader-is-starting .loader-starting {
    display: inline;
}

.loader-percent {
    font-variant-numeric: tabular-nums;
    color: var(--accent-blue-text);
    font-weight: 800;
}

.loader-percent::after {
    content: var(--blazor-load-percentage-text, "");
}

.loader-slow {
    font-size: 0.8rem;
    color: #64748b;
    opacity: 0;
    max-height: 0;
    margin-top: -22px;
    animation: loaderSlow 0.5s ease 15s forwards;
}

.loader-slow a {
    color: var(--accent-blue-text);
    font-weight: 700;
}

@keyframes loaderSlow {
    to { opacity: 1; max-height: 3em; margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .loader-sky span,
    .loader-sky i,
    .loader-bubble,
    .loader-bubble i,
    .loader-bubble::before,
    .loader-bubble::after,
    .loader-progress-bar::after {
        animation: none;
    }

    .loader-sky span {
        bottom: auto;
        top: var(--y, 50%);
        opacity: 0.7;
    }
}


/* Small phones */
@media (max-width: 360px) {
    :root {
        --gutter: var(--space-3);
    }

    .top-nav {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-title {
        font-size: 1.3rem;
    }

    .player-badge {
        padding: 5px 10px;
        font-size: 0.82rem;
    }

    .bottom-nav {
        gap: 2px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .nav-tab {
        font-size: 0.68rem;
        padding: 5px 2px;
    }

    .tab-icon {
        font-size: 1.15rem;
    }

    .card-panel {
        padding: var(--space-4);
        border-radius: 18px;
    }

    .panel-title {
        font-size: 1.15rem;
    }

    .daily-date {
        font-size: 1.45rem;
    }

    .leaderboard-table .col-rank {
        width: 38px;
    }

    .leaderboard-table .col-score {
        width: 80px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 6px;
    }

    .play-card {
        padding: var(--space-5) var(--space-4);
        gap: var(--space-3);
        border-radius: 24px;
    }

    .play-card h2 {
        font-size: 1.7rem;
    }

    .game-over-dialog {
        padding: var(--space-5) var(--space-4);
        gap: var(--space-3);
        border-radius: 24px;
    }

    .score-number {
        font-size: 2.4rem;
    }

    .stat-box {
        padding: var(--space-2);
    }

    .action-buttons-row {
        gap: var(--space-2);
    }

    .restart-btn {
        flex: 1.4;
        font-size: 1.05rem;
    }

    .share-btn {
        font-size: 0.92rem;
        padding: 12px 8px;
    }
}

@media (max-width: 440px) {
    /* The combo moves under the name so long nicknames stay readable */
    .leaderboard-table .col-combo {
        display: none;
    }

    .player-cell-combo {
        display: block;
    }

    .install-chip {
        padding: 6px 9px;
    }

    .install-chip-label {
        display: none;
    }
}

/* Short portrait screens */
@media (orientation: portrait) and (max-height: 660px) {
    .game-start-overlay {
        padding: var(--space-3);
    }

    .play-card {
        gap: var(--space-3);
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .play-card-intro {
        gap: var(--space-1);
    }

    .play-card h2 {
        font-size: 1.5rem;
    }

    .rules-hint {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .play-btn {
        padding: 13px 22px;
        font-size: 1.15rem;
    }

    .modal-backdrop,
    .modal-dialog {
        padding: var(--space-2);
    }

    .game-over-dialog {
        gap: var(--space-2);
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .game-over-summary,
    .game-over-actions {
        gap: var(--space-2);
    }

    .game-over-dialog h3 {
        font-size: 1.35rem;
    }

    .score-display-box {
        padding: var(--space-2);
    }

    .score-number {
        font-size: 2.2rem;
    }

    .restart-btn,
    .share-btn {
        padding-top: 11px;
        padding-bottom: 11px;
    }
}

/* Tablets and larger; phones in landscape keep their compact layout (see below) */
@media (min-width: 768px) and (min-height: 541px) {
    :root {
        --gutter: var(--space-6);
    }

    .app-container {
        max-width: 720px;
    }

    .top-nav {
        padding-left: 24px;
        padding-right: 24px;
    }

    .brand-title {
        font-size: 1.75rem;
    }

    .player-badge {
        font-size: 1rem;
        padding: 8px 18px;
    }

    .bottom-nav {
        padding-top: 10px;
    }

    .nav-tab {
        max-width: 120px;
        padding: 8px 6px;
        font-size: 0.85rem;
    }

    .tab-icon {
        font-size: 1.5rem;
    }

    .game-start-overlay {
        padding: var(--space-6);
    }

    .play-card {
        max-width: 440px;
        padding: calc(var(--space-6) + var(--space-3)) var(--space-6);
        gap: var(--space-5);
    }

    .play-card h2 {
        font-size: 2.3rem;
    }

    .rules-hint {
        font-size: 0.95rem;
    }

    .game-over-dialog {
        max-width: 460px;
        padding: calc(var(--space-6) + var(--space-3)) var(--space-6);
    }

    .scroll-view {
        gap: var(--space-5);
    }

    .card-panel {
        padding: var(--space-6);
        border-radius: 24px;
    }

    .panel-title {
        font-size: 1.5rem;
    }

    .segment-btn {
        padding: 8px 18px;
        font-size: 0.95rem;
    }

    .leaderboard-table th {
        padding: 10px 14px;
        font-size: 0.78rem;
    }

    .leaderboard-table td {
        padding: 12px 14px;
        font-size: 1.05rem;
    }

    .leaderboard-table .col-rank {
        width: 60px;
    }

    .leaderboard-table .col-combo {
        width: 96px;
    }

    .leaderboard-table .col-score {
        width: 130px;
    }
}

@media (min-width: 1200px) {
    /* A laptop or desktop screen is read from further away: a larger base and no text under 13 px */
    html {
        font-size: 17px;
    }

    .app-container {
        max-width: 760px;
    }

    .nav-tab,
    .stat-lbl,
    .app-version,
    .leaderboard-table th,
    .player-cell-combo,
    .you-tag,
    .nickname-error,
    .admin-table th,
    .range-form label,
    .chart-scale,
    .chart-labels {
        font-size: 0.8rem;
    }
}

/* Landscape phones and wide screens: side rail instead of header and tab bar */
@media (orientation: landscape) and (max-height: 540px), (orientation: landscape) and (min-width: 900px) {
    .app-container {
        max-width: none;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas:
            "brand main"
            "nav main";
        padding-left: 0;
        padding-right: var(--safe-right);
    }

    .top-nav {
        grid-area: brand;
        flex-direction: column;
        justify-content: flex-start;
        gap: 8px;
        padding: calc(8px + var(--safe-top)) 8px 6px calc(8px + var(--safe-left));
        border-bottom: none;
        border-right: 1px solid var(--border-glass);
    }

    .brand-name,
    .player-name,
    .install-chip-label {
        display: none;
    }

    .top-nav-actions {
        flex-direction: column;
        max-width: none;
        gap: 6px;
    }

    .install-chip {
        padding: 6px 9px;
    }

    .player-badge {
        justify-content: center;
        max-width: none;
        padding: 6px 10px;
    }

    .main-content {
        grid-area: main;
    }

    .bottom-nav {
        grid-area: nav;
        flex-direction: column;
        justify-content: space-evenly;
        gap: 2px;
        min-height: 0;
        padding: 4px 6px calc(6px + var(--safe-bottom)) calc(6px + var(--safe-left));
        border-top: none;
        border-right: 1px solid var(--border-glass);
    }

    .nav-tab {
        max-width: none;
        min-height: 0;
    }
}

/* Phones in landscape */
@media (orientation: landscape) and (max-height: 540px) {
    :root {
        --gutter: var(--space-3);
    }

    .nav-tab {
        padding: 2px 8px;
        gap: 1px;
        font-size: 0.62rem;
    }

    .tab-icon {
        font-size: 1.1rem;
        line-height: 1.1;
    }

    .game-start-overlay,
    .modal-backdrop,
    .modal-dialog {
        padding: var(--space-2);
    }

    .play-card {
        max-width: 580px;
        flex-direction: row;
        align-items: center;
        gap: var(--space-5);
        padding: var(--space-4) var(--space-5);
        border-radius: 24px;
    }

    .play-card-intro,
    .play-card-form {
        flex: 1 1 0;
        min-width: 0;
    }

    .play-card-intro {
        gap: var(--space-1);
    }

    .play-card-form {
        gap: var(--space-2);
    }

    .play-card h2 {
        font-size: 1.6rem;
    }

    .rules-hint {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .play-btn {
        padding: 12px 20px;
        font-size: 1.1rem;
    }

    .game-over-dialog {
        max-width: 660px;
        flex-direction: row;
        align-items: center;
        gap: var(--space-5);
        padding: var(--space-4) var(--space-5);
        border-radius: 24px;
    }

    .game-over-summary,
    .game-over-actions {
        flex: 1 1 0;
        min-width: 0;
        gap: var(--space-2);
    }

    .game-over-dialog h3 {
        font-size: 1.3rem;
    }

    .score-display-box {
        padding: var(--space-2);
    }

    .score-number {
        font-size: 2.1rem;
    }

    .stat-box {
        padding: var(--space-2);
    }

    .restart-btn,
    .share-btn {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .scroll-view {
        gap: var(--space-3);
    }

    .card-panel {
        padding: var(--space-4);
        gap: var(--space-3);
    }

    .loader-card {
        gap: 14px;
        padding: 20px 26px;
    }

    .loader-logo {
        gap: 8px;
    }

    .loader-bubble {
        width: 60px;
        height: 60px;
    }

    .loader-title {
        font-size: 1.9rem;
    }
}

/* Wide landscape screens (laptops, desktops, tablets): the rail gives the game field the full height */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 541px) {
    .top-nav {
        gap: 14px;
        padding: calc(16px + var(--safe-top)) 12px 12px calc(12px + var(--safe-left));
    }

    .brand-title {
        flex-direction: column;
        gap: 0;
        font-size: 1.2rem;
    }

    .brand-icon {
        font-size: 1.75rem;
    }

    .brand-name {
        display: inline;
    }

    .bottom-nav {
        justify-content: flex-start;
        gap: 6px;
        padding: 4px 12px calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
    }

    .nav-tab {
        flex: none;
        padding: 10px 8px;
    }
}

/* Content screens side by side once the rail leaves enough width */
@media (orientation: landscape) and (min-width: 900px), (orientation: landscape) and (max-height: 540px) and (min-width: 780px) {
    .scroll-view {
        padding-inline: max(var(--gutter), calc((100% - 960px) / 2));
    }

    .scroll-view.split {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
        align-content: start;
        padding-inline: max(var(--gutter), calc((100% - 1200px) / 2));
    }

    .scroll-view.split > .app-version {
        grid-column: 1 / -1;
    }

    .scroll-view.split > :only-child {
        grid-column: 1 / -1;
        justify-self: center;
        width: min(100%, 960px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal-backdrop,
    .modal-dialog::backdrop,
    .game-over-dialog,
    .rules-dialog,
    .loader-card {
        animation: none;
    }

    .nav-tab.active .tab-icon {
        transform: none;
    }

    .install-chip {
        animation: none;
    }
}
