/* ─── Design tokens ─── */
:root {
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-ui: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --bg-base: #e8e4dc;
    --bg-gradient: linear-gradient(160deg, #ebe7df 0%, #ddd8ce 45%, #d4cfc4 100%);
    --bg-mesh: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(180, 160, 130, 0.15) 0%, transparent 60%),
               radial-gradient(ellipse 60% 50% at 85% 90%, rgba(120, 150, 130, 0.12) 0%, transparent 55%);

    --surface: rgba(252, 250, 246, 0.88);
    --surface-raised: rgba(255, 253, 249, 0.95);
    --surface-inset: rgba(240, 236, 228, 0.6);
    --border: rgba(120, 108, 90, 0.18);
    --border-strong: rgba(100, 88, 72, 0.28);

    --text-primary: #2c2820;
    --text-secondary: #6b6358;
    --text-muted: #9a9288;
    --text-accent: #5c4a32;

    --accent: #8b6914;
    --accent-soft: rgba(139, 105, 20, 0.12);
    --accent-hover: #a67c1a;
    --sage: #5a7355;
    --sage-soft: rgba(90, 115, 85, 0.1);
    --rose: #9e4a4a;
    --rose-soft: rgba(158, 74, 74, 0.08);
    --positive: #4a7c59;
    --negative: #a05252;

    --shadow-sm: 0 1px 2px rgba(44, 40, 32, 0.06), 0 4px 12px rgba(44, 40, 32, 0.04);
    --shadow-md: 0 4px 16px rgba(44, 40, 32, 0.08), 0 12px 40px rgba(44, 40, 32, 0.06);
    --shadow-board: inset 0 2px 8px rgba(44, 40, 32, 0.06), 0 8px 32px rgba(44, 40, 32, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --board-bg: #f5f2eb;
    --board-frame: #c4b8a4;
    --cell-empty: rgba(210, 200, 185, 0.35);
    --cell-empty-hover: rgba(180, 165, 140, 0.25);
}

body.dark-theme {
    --bg-base: #141210;

    --surface: rgba(28, 26, 22, 0.92);
    --surface-raised: rgba(36, 33, 28, 0.96);
    --surface-inset: rgba(20, 18, 15, 0.7);
    --border: rgba(200, 185, 160, 0.1);
    --border-strong: rgba(200, 185, 160, 0.18);

    --text-primary: #ede8df;
    --text-secondary: #a89f92;
    --text-muted: #6b645a;
    --text-accent: #d4c4a0;

    --accent: #c9a84c;
    --accent-soft: rgba(201, 168, 76, 0.12);
    --accent-hover: #dbb95a;
    --sage: #7a9a72;
    --sage-soft: rgba(122, 154, 114, 0.12);
    --rose: #c47070;
    --rose-soft: rgba(196, 112, 112, 0.1);
    --positive: #6aab7a;
    --negative: #c47070;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35), 0 12px 48px rgba(0, 0, 0, 0.25);
    --shadow-board: inset 0 2px 12px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);

    --board-bg: #1e1c18;
    --board-frame: #3a3530;
    --cell-empty: rgba(60, 55, 48, 0.5);
    --cell-empty-hover: rgba(80, 72, 60, 0.45);

    background-image:
        linear-gradient(rgba(14, 12, 10, 0.88), rgba(20, 18, 16, 0.92)),
        url('../source/background/background_01.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* ─── Base ─── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    background-image:
        linear-gradient(rgba(232, 228, 220, 0.82), rgba(212, 207, 196, 0.88)),
        url('../source/background/background_01.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    transition: background 0.6s ease, color 0.4s ease;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--user-bg-tint, transparent);
    opacity: var(--user-bg-opacity, 0);
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.35s ease;
}

body.has-bg-tint::after {
    mix-blend-mode: multiply;
}

body.dark-theme.has-bg-tint::after {
    mix-blend-mode: soft-light;
}

html[data-reduce-motion="1"] *,
html[data-reduce-motion="1"] *::before,
html[data-reduce-motion="1"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

.app-shell {
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .app-shell { padding: 1.75rem 1.5rem 2.5rem; }
}

/* ─── Typography ─── */
.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

.section-label {
    font-family: var(--font-ui);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ─── Panels ─── */
.panel {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.panel-header .section-label { margin: 0; }

/* legacy alias — kept for JS compatibility */
.cozy-card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ─── Top bar ─── */
.top-bar {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(20, 18, 16, 0.06);
}

@media (min-width: 768px) {
    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .top-bar__row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1.25rem;
        width: 100%;
    }
}

.top-bar__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.brand-block { flex-shrink: 0; }

.brand-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-primary);
    line-height: 1;
    margin: 0;
}

.brand-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0.35rem 0 0;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.625rem;
}

/* ─── Stats ─── */
.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 5.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.stat-block .section-label {
    margin-bottom: 0.15rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.375rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-block--accent .stat-value { color: var(--accent); }
.stat-block--sage .stat-value { color: var(--sage); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

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

.btn-ghost {
    padding: 0.5rem 0.875rem;
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-inset);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-primary {
    padding: 0.5rem 1.125rem;
    background: var(--accent);
    color: #faf8f4;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: var(--surface-inset);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-icon:hover {
    border-color: var(--border-strong);
    color: var(--accent);
}

.btn-icon svg {
    width: 1rem;
    height: 1rem;
}

/* ─── Form controls ─── */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.select-field {
    appearance: none;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface-inset) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6358' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.625rem center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4375rem 1.75rem 0.4375rem 0.625rem;
    cursor: pointer;
    min-width: 11rem;
    transition: border-color 0.2s ease;
}

.select-field:hover,
.select-field:focus {
    outline: none;
    border-color: var(--border-strong);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.toggle-row span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 2.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.toggle-track::after {
    content: '';
    position: absolute;
    width: 0.875rem;
    height: 0.875rem;
    left: 0.1875rem;
    top: 0.1875rem;
    background: #faf8f4;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(1rem);
}

/* ─── Layout grid ─── */
.game-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .game-layout {
        grid-template-columns: 17rem 1fr 19.5rem;
        gap: 1.125rem;
    }
}

.sidebar-left,
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.sidebar-right .panel {
    padding: 0.75rem 0.875rem !important;
}

#quest-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

#rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sidebar-right .panel--balance .section-title {
    color: var(--rose);
}

/* ─── Tile hand panel ─── */
.tile-hand-panel { padding: 1.25rem; }

.tile-preview-stage {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.tile-preview-frame {
    padding: 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

#active-tile-preview {
    width: 5.5rem;
    height: 5.5rem;
    border-radius: var(--radius-md);
}

.tile-info-block {
    text-align: center;
    padding: 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 0.75rem;
}

#tile-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

#tile-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0.35rem 0 0;
    line-height: 1.45;
}

.rules-hint {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.rules-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rules-card {
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
}

.rules-card__when {
    margin: 0 0 0.35rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.rules-card__lines {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.rules-line {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.35rem 0.4rem;
    font-size: 0.625rem;
    line-height: 1.25;
}

.rules-line__pair {
    display: inline-flex;
    align-items: center;
    gap: 0.12rem;
    flex-shrink: 0;
}

.rules-line__emoji {
    font-size: 0.75rem;
    line-height: 1;
}

.rules-line__arrow {
    font-size: 0.5625rem;
    color: var(--text-muted);
}

.rules-line__desc {
    color: var(--text-secondary);
    min-width: 0;
}

.rules-line__pts {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-weight: 700;
    flex-shrink: 0;
}

.rules-card--house .rules-line__pts { color: #c06030; }
.rules-card--forest .rules-line__pts { color: #2d7a40; }
.rules-card--farm .rules-line__pts { color: #a08018; }

.rules-hint ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rules-hint li {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
}

.rules-hint li strong { color: var(--text-primary); font-weight: 600; }

/* ─── Queue panel ─── */
.queue-panel { padding: 1rem 1.25rem; }

.display-prefs-panel {
    padding: 0.75rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.queue-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin-top: 0.625rem;
}

.queue-row > div {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-sm);
    transition: opacity 0.2s ease;
}

.queue-row > div:nth-child(2) { opacity: 0.65; }
.queue-row > div:nth-child(3) { opacity: 0.4; }

/* ─── Board ─── */
.board-panel {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-container {
    background: var(--board-bg);
    border: 3px solid var(--board-frame);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-board);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
    aspect-ratio: var(--board-cols, 1) / var(--board-rows, 1);
    max-width: min(var(--board-max, 28rem), 100%);
    max-height: min(var(--board-max-vh, 72vh), 72vh);
    padding: 0.625rem;
    transition: all 0.5s ease;
}

.board-container--tall {
    width: auto;
    max-width: min(var(--board-max, 20rem), 92vw);
}

#grid-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.board-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.04) 0%, transparent 70%);
    pointer-events: none;
}

.board-hint {
    margin-top: 1rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
    max-width: 26rem;
    letter-spacing: 0.01em;
}

/* ─── Tile cells ─── */
.tile-cell {
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, background 0.18s ease;
    position: relative;
    border-radius: var(--radius-sm) !important;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.tile-cell--empty {
    background: var(--cell-empty) !important;
    border: 1px solid var(--border) !important;
    cursor: pointer;
}

.tile-cell--empty:hover:not(.locked):not(.masterpiece-tile) {
    background: var(--cell-empty-hover) !important;
    transform: scale(1.04);
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

.tile-cell:hover:not(.locked):not(.masterpiece-tile):not(.tile-cell--empty) {
    transform: scale(1.04) translateY(-2px);
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

.cell-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--border-strong);
    opacity: 0.5;
}

.masterpiece-tile {
    border: none !important;
    box-shadow: none !important;
    border-radius: 4px !important;
    transform: scale(1) !important;
    z-index: 10;
}

/* ─── Quest cards ─── */
.quest-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "body reward"
        "foot foot";
    gap: 0.35rem 0.4rem;
    padding: 0.4rem 0.5rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.quest-card__body {
    grid-area: body;
    min-width: 0;
}

.quest-card__aside {
    grid-area: foot;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding-top: 0.35rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--border);
    min-width: 0;
}

.quest-card__reward-slot {
    grid-area: reward;
    align-self: start;
}

.quest-card--done {
    opacity: 0.55;
    border-color: transparent;
    background: var(--sage-soft);
}

.quest-card--repeat {
    border-color: var(--positive);
    background: color-mix(in srgb, var(--sage-soft) 55%, var(--surface-inset));
}

.quest-card__count {
    font-size: 0.625rem;
    color: var(--positive);
    font-weight: 700;
    font-family: var(--font-mono);
    margin: 0.2rem 0 0;
}

.quests-panel__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.quests-panel__head .section-title {
    margin: 0;
}

.quest-summary {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--positive);
    white-space: nowrap;
}

.quest-card__title {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
    font-size: 0.6875rem;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.quest-card--done .quest-card__title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.quest-card__desc {
    font-size: 0.5625rem;
    color: var(--text-muted);
    margin: 0.12rem 0 0;
    line-height: 1.35;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.quest-card__done-label {
    font-size: 0.625rem;
    color: var(--positive);
    font-weight: 600;
    margin: 0.15rem 0 0;
}

.quest-reward {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--border);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.quest-diagram {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    padding: 0.15rem 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    align-content: center;
    min-width: 0;
    min-height: 1.25rem;
    flex: 1 1 auto;
    max-width: 100%;
    overflow: hidden;
    line-height: 0;
}

.quest-diagram .panel-tile-icon {
    width: 1rem;
    height: 1rem;
}

.quest-diagram .panel-tile-icon .tile-icon {
    width: 100%;
    height: 100%;
}

.quest-diagram .panel-tile-icon .tile-token {
    font-size: 0.6875rem;
    box-shadow: none;
}

.quest-diagram--grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    width: 2rem;
    height: 2rem;
    padding: 0.15rem;
    flex: 0 0 auto;
    place-items: center;
}

.quest-diagram--corners {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.1rem;
    place-items: center;
    flex: 0 0 auto;
}

.quest-diagram--grid .panel-tile-icon,
.quest-diagram--cross .panel-tile-icon {
    width: 0.85rem;
    height: 0.85rem;
}

.quest-diagram--corners .panel-tile-icon {
    width: 0.72rem;
    height: 0.72rem;
}

.quest-diagram__dot {
    font-size: 0.375rem;
    color: var(--text-muted);
    opacity: 0.35;
    line-height: 1;
}

.panel-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    line-height: 0;
    overflow: hidden;
}

.panel-tile-icon .tile-icon {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.panel-tile-icon .tile-token {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    font-size: 0.75rem;
    line-height: 1;
    box-shadow: none;
}

.panel-tile-arrow {
    font-size: 0.5625rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.rules-line__pair {
    display: inline-flex;
    align-items: center;
    gap: 0.12rem;
    flex-shrink: 0;
}

.rule-diagram {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    align-content: center;
    gap: 0.12rem;
    padding: 0.15rem 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 0;
    min-height: 1.25rem;
    flex: 1 1 auto;
    max-width: 100%;
    overflow: hidden;
    line-height: 0;
}

.rule-diagram .panel-tile-icon {
    width: 1rem;
    height: 1rem;
}

.rule-diagram .panel-tile-icon .tile-token {
    font-size: 0.6875rem;
}

/* ─── Quest unlock toast (Xbox-style) ─── */
.quest-toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    pointer-events: none;
    max-width: min(22rem, calc(100vw - 2rem));
}

.quest-toast {
    display: flex;
    align-items: stretch;
    background: rgba(18, 22, 20, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    opacity: 0;
    transform: translateX(110%);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.quest-toast--visible {
    opacity: 1;
    transform: translateX(0);
}

.quest-toast--out {
    opacity: 0;
    transform: translateX(110%);
    transition-duration: 0.28s;
}

.quest-toast__accent {
    width: 4px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #6fcf7a, #3d9a52);
}

.quest-toast__body {
    flex: 1;
    padding: 0.75rem 0.875rem 0.75rem 0.65rem;
    min-width: 0;
}

.quest-toast__kicker {
    margin: 0 0 0.25rem;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7ecf8a;
}

.quest-toast__main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.quest-toast__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #f5f7f5;
    line-height: 1.25;
}

.quest-toast__count {
    margin-left: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #9fd4a8;
}

.quest-toast__rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.quest-toast__reward {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.12rem 0.4rem;
    border-radius: var(--radius-sm);
}

.quest-toast__reward--pts {
    color: #b8f0c0;
    background: rgba(63, 140, 78, 0.35);
}

.quest-toast__reward--cards {
    color: #ffe8a8;
    background: rgba(180, 130, 40, 0.35);
}

.quest-toast__diagram {
    flex-shrink: 0;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
}

.quest-toast__diagram .quest-diagram {
    background: transparent;
    border: none;
    padding: 0;
}

@media (max-width: 640px) {
    .quest-toast-stack {
        top: auto;
        bottom: 5.5rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}

/* ─── Rule cards ─── */
.rule-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "body badge"
        "foot foot";
    gap: 0.35rem 0.4rem;
    padding: 0.4rem 0.5rem;
    background: var(--rose-soft);
    border: 1px solid var(--border);
    border-left: 2px solid var(--rose);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    overflow: hidden;
}

.rule-card__body {
    grid-area: body;
    min-width: 0;
}

.rule-card__aside {
    grid-area: foot;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding-top: 0.35rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--border);
    min-width: 0;
}

.rule-card__badge-slot {
    grid-area: badge;
    align-self: start;
}

.map-editor-code-status {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0.35rem 0 0;
    min-height: 1rem;
}

.map-code-field--pending {
    border-color: var(--accent) !important;
    opacity: 0.85;
}

.rule-card__title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
}

.rule-card__desc {
    font-size: 0.5625rem;
    color: var(--text-secondary);
    margin: 0.12rem 0 0;
    line-height: 1.35;
    white-space: normal;
}

.quest-diagram--cross {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
    width: 2rem;
    height: 2rem;
    padding: 0.1rem;
    flex: 0 0 auto;
    place-items: center;
}

.rule-card__badge {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--negative);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* ─── Chronicle log ─── */
.chronicle-panel__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
}

.chronicle-panel__hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.chronicle-panel {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    min-height: 9rem;
    max-height: 11rem;
}

.game-event-strip {
    align-self: flex-end;
    width: auto;
    max-width: 100%;
    margin-left: auto;
    margin-top: 0.15rem;
    padding: 0.5rem 0 0;
    text-align: right;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-secondary);
    background: transparent;
    border-bottom: none;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.game-event-strip.hidden { display: none; }

.game-event-strip[data-event-type="quest"] { color: var(--positive); font-weight: 500; }
.game-event-strip[data-event-type="synergy"] { color: var(--sage); }
.game-event-strip[data-event-type="animal"] { color: var(--accent); }

.log-entry--move {
    font-family: var(--font-mono, ui-monospace, Consolas, monospace);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom-color: var(--border);
}

#nature-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding-right: 0.25rem;
}

.log-entry {
    font-size: 0.6875rem;
    line-height: 1.45;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.log-entry--synergy { color: var(--sage); }
.log-entry--quest { color: var(--positive); font-weight: 500; }
.log-entry--animal { color: var(--accent); }
.log-entry--place { color: var(--text-muted); }

/* ─── Victory modal ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 16, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    z-index: 50;
    overflow-y: auto;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
    max-width: 42rem;
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
    .modal-card {
        flex-direction: row;
        align-items: flex-start;
    }
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.modal-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 1.25rem;
}

.score-hero {
    text-align: center;
    padding: 1.25rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.score-hero .section-label { margin-bottom: 0.375rem; }

#final-score {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--accent);
    line-height: 1;
}

.score-breakdown {
    display: flex;
    gap: 0.5rem;
}

.score-breakdown > div {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-inset);
}

.score-breakdown .section-label { font-size: 0.5625rem; }

#breakdown-positive {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--positive);
}

#breakdown-negative {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--negative);
}

.snapshot-frame {
    width: 100%;
    aspect-ratio: 1;
    padding: 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

/* ─── Animations ─── */
@keyframes sway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}
.animate-sway { animation: sway 4s ease-in-out infinite; }

@keyframes ripple {
    0%, 100% { transform: scale(1) translateY(0); opacity: 0.92; }
    50% { transform: scale(1.03) translateY(-1px); opacity: 1; }
}
.animate-ripple { animation: ripple 6s ease-in-out infinite; }

@keyframes smokeUp {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    30% { opacity: 0.7; }
    100% { transform: translateY(-24px) translateX(3px) scale(1.3); opacity: 0; }
}
.smoke-particle {
    position: absolute;
    animation: smokeUp 3s forwards linear;
    pointer-events: none;
    z-index: 25;
    opacity: 0.6;
}

@keyframes flutter {
    0%, 100% { transform: translate(0, 0) scaleX(1); }
    25% { transform: translate(3px, -3px) scaleX(-1); }
    50% { transform: translate(-2px, -6px) scaleX(1); }
    75% { transform: translate(-4px, -2px) scaleX(-1); }
}
.butterfly-particle {
    position: absolute;
    animation: flutter 4s infinite ease-in-out;
    pointer-events: none;
    z-index: 25;
    opacity: 0.7;
}

@keyframes floatUpAndFade {
    0% { transform: translateY(0) scale(0.8); opacity: 0; }
    20% { transform: translateY(-10px) scale(1); opacity: 1; }
    100% { transform: translateY(-48px) scale(0.95); opacity: 0; }
}
.floating-score {
    animation: floatUpAndFade 1.2s forwards cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--positive);
    box-shadow: var(--shadow-sm);
}

.floating-score--negative { color: var(--negative); }

.active-pulse {
    box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 4px rgba(139, 105, 20, 0.15);
    animation: softPulse 2.5s infinite ease-in-out;
}
@keyframes softPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 4px rgba(139, 105, 20, 0.1); }
    50% { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 6px rgba(139, 105, 20, 0.2); }
}

@keyframes windowGlow {
    0%, 100% { filter: drop-shadow(0 0 1px #d4a843) brightness(1); }
    50% { filter: drop-shadow(0 0 5px #c9a030) brightness(1.15); }
}
body.dark-theme .night-glow { animation: windowGlow 3s infinite ease-in-out; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

/* ─── Dark theme tile overrides ─── */
body.dark-theme .bg-gradient-to-b.from-amber-100 {
    background-image: linear-gradient(to bottom, #78350f, #451a03) !important;
    border-color: #b45309 !important;
    color: #fef3c7 !important;
}
body.dark-theme .bg-gradient-to-b.from-emerald-100 {
    background-image: linear-gradient(to bottom, #064e3b, #022c22) !important;
    border-color: #047857 !important;
    color: #d1fae5 !important;
}
body.dark-theme .bg-gradient-to-b.from-sky-100 {
    background-image: linear-gradient(to bottom, #0c4a6e, #082f49) !important;
    border-color: #0369a1 !important;
    color: #e0f2fe !important;
}
body.dark-theme .bg-gradient-to-b.from-purple-100 {
    background-image: linear-gradient(to bottom, #581c87, #3b0764) !important;
    border-color: #7e22ce !important;
    color: #f3e8ff !important;
}
body.dark-theme .bg-gradient-to-b.from-yellow-100 {
    background-image: linear-gradient(to bottom, #713f12, #422006) !important;
    border-color: #a16207 !important;
    color: #fef9c3 !important;
}

/* Fog / obstacle cell styling */
.cell-fog {
    background: var(--surface-inset) !important;
    border: 1px dashed var(--border-strong) !important;
    cursor: not-allowed;
}

.cell-fog__label {
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.cell-rock-clearable {
    background: var(--accent-soft) !important;
    border: 1px dashed var(--accent) !important;
    cursor: pointer;
}

.cell-rock-clearable:hover {
    background: rgba(139, 105, 20, 0.18) !important;
}

.cell-rock-locked {
    background: var(--surface-inset) !important;
    border: 1px solid var(--border) !important;
    opacity: 0.7;
    cursor: not-allowed;
}

.cell-label {
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cell-cost {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    font-weight: 500;
    color: var(--negative);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    margin-top: 0.25rem;
}

.tile-token {
    background: var(--surface-raised);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.tile-label {
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.score-preview-badge {
    position: absolute;
    top: -0.375rem;
    right: -0.375rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-raised);
    z-index: 25;
}

.score-preview-badge--pos { color: var(--positive); }
.score-preview-badge--neg { color: var(--negative); }

/* ─── Tile icon (image themes) ─── */
.tile-icon {
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.12));
}

/* ─── Hexmap theme tile backgrounds ─── */
.theme-tile {
    background-size: cover;
    background-position: center;
}

.theme-tile--house { background-color: #f5e6c8; }
.theme-tile--forest { background-color: #dce8d0; }
.theme-tile--lake { background-color: #c8e6f5; }
.theme-tile--park { background-color: #f0e6f5; }
.theme-tile--farm { background-color: #f5efd5; }

body.dark-theme .theme-tile--house { background-color: #3d2e1a; }
body.dark-theme .theme-tile--forest { background-color: #1a2e1a; }
body.dark-theme .theme-tile--lake { background-color: #1a2838; }
body.dark-theme .theme-tile--park { background-color: #2a1a2e; }
body.dark-theme .theme-tile--farm { background-color: #2e281a; }

/* ─── Utilities ─── */
.hidden { display: none !important; }

/* ─── Main menu ─── */
.menu-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 20;
}

.menu-credits {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    pointer-events: none;
    z-index: 1;
    padding: 0 1.5rem;
    text-align: center;
    color: var(--text-muted);
    opacity: 0.42;
    user-select: none;
}

.menu-credits__author {
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.menu-credits__meta {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

@media (min-width: 640px) {
    .menu-credits {
        left: auto;
        right: 1.75rem;
        bottom: 1.5rem;
        align-items: flex-end;
        text-align: right;
        padding: 0;
    }
}

.menu-card {
    width: 100%;
    max-width: 26rem;
    padding: 2.5rem 2rem;
    text-align: center;
}

.menu-kicker {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

.menu-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    margin: 0;
    line-height: 1;
    color: var(--text-primary);
}

.menu-tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 1rem 0 2rem;
    font-style: italic;
    font-family: var(--font-display);
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.menu-actions--stack { margin-top: 0.5rem; }

.menu-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    flex-direction: column;
    gap: 0.25rem;
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.9375rem;
}

.menu-btn__hint {
    display: block;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.btn-primary .menu-btn__hint { color: rgba(250, 248, 244, 0.75); }

.menu-back {
    align-self: flex-start;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
}

.lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.lang-switch__label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.lang-btn {
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lang-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.lang-btn--active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.modal-card--tutorial {
    flex-direction: column !important;
    max-width: 24rem;
    gap: 1rem;
}

.tutorial-step__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.tutorial-step__text {
    margin: 0;
    line-height: 1.55;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.tutorial-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.tutorial-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s, transform 0.2s;
}

.tutorial-dot--active {
    background: var(--accent);
    transform: scale(1.15);
}

.tutorial-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.tutorial-actions .btn-primary {
    margin-left: auto;
}

.tutorial-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 9rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
}

.tut-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.tut-visual--synergy,
.tut-visual--quest {
    flex-direction: column;
    gap: 0.625rem;
}

.tut-visual__side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.tut-visual__tag {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.tut-visual__arrow {
    font-size: 1.25rem;
    color: var(--accent);
    font-weight: 700;
}

.tut-grid {
    display: grid;
    gap: 3px;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid var(--border);
}

.tut-grid--3 {
    grid-template-columns: repeat(3, 2rem);
    grid-template-rows: repeat(3, 2rem);
}

.tut-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.875rem;
}

.tut-cell--fog {
    background: rgba(148, 163, 184, 0.35);
    color: var(--text-muted);
}

.tut-cell--target {
    border: 2px dashed var(--accent);
    background: var(--accent-soft);
}

.tut-cell--pulse {
    animation: tut-pulse 1.2s ease-in-out infinite;
}

.tut-cell--highlight {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

@keyframes tut-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.06); opacity: 0.85; }
}

.tut-mini-tile {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 1rem;
}

.tut-mini-tile--active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.tut-mini-tile--dim {
    opacity: 0.45;
    font-size: 0.875rem;
}

.tut-synergy-badge {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.8125rem;
}

.tut-fog-clear {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.tut-fog-clear__from { opacity: 0.5; }
.tut-fog-clear__to { font-size: 1rem; }

.tut-quest-card {
    width: 100%;
    max-width: 16rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    text-align: left;
}

.tut-quest-card__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.tut-quest-check {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.tut-quest-card__desc {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.tut-quest-rewards {
    display: flex;
    gap: 0.5rem;
}

.tut-quest-reward {
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 700;
}

.tut-quest-reward--pts {
    background: var(--accent);
    color: #fff;
}

.tut-quest-reward--cards {
    background: var(--surface);
    border: 1px solid var(--border);
}

.tut-quest-arrow {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.tut-visual--balance {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.tut-balance-card {
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    background: rgba(220, 80, 80, 0.12);
    border: 1px solid rgba(200, 60, 60, 0.25);
    text-align: center;
    font-size: 0.85rem;
}

.tut-visual--rock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.tut-rock-badge {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(90, 140, 100, 0.15);
    color: var(--text-secondary);
}

.tut-visual--top {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
}

.tut-top-line {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tut-top-line span {
    color: var(--text-muted);
}

.tut-save-badge {
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(90, 140, 100, 0.15);
    font-size: 0.85rem;
}

.tut-visual--save {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.tut-visual--save .tut-save-badge {
    margin-top: 0;
    font-size: 1rem;
    padding: 0.5rem 1rem;
}


#menu-screen-modes {
    text-align: left;
}

.menu-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.25rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    z-index: 100;
    animation: toastIn 0.25s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Mode badge ─── */
.brand-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.mode-badge {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.mode-badge--expert {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.mode-badge--creative {
    color: var(--sage);
    border-color: var(--sage);
    background: rgba(107, 124, 94, 0.12);
}

/* ─── Creative palette ─── */
.creative-palette {
    padding: 1rem 1.25rem;
}

.creative-palette-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.375rem;
    margin-top: 0.625rem;
}

.creative-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.15rem;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    background: var(--surface-inset);
}

.creative-tile:hover {
    transform: scale(1.05);
}

.creative-tile--selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.creative-tile__label {
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0.85;
}

.creative-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0.75rem 0 0;
    line-height: 1.45;
}

.expert-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
}

.btn-rotate {
    padding: 0.35rem 0.75rem;
    font-size: 0.6875rem;
    text-transform: none;
    letter-spacing: 0;
}

.domino-preview {
    min-width: 5.5rem;
    min-height: 5.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.domino-shape {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.domino-cell {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.domino-cell--sm {
    width: 1.25rem;
    height: 1.25rem;
}

.domino-queue-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
}

.domino-highlight {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    z-index: 15;
}

.domino-highlight--invalid {
    outline: 2px solid var(--negative);
    outline-offset: -2px;
    opacity: 0.65;
}

/* ─── Text field ─── */
.text-field {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}

.text-field:focus {
    border-color: var(--accent);
}

.text-field--error {
    border-color: var(--rose, #c45c5c) !important;
    box-shadow: 0 0 0 2px rgba(196, 92, 92, 0.2);
}

.map-code-field {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.map-code-field--short {
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.map-code-field--multiline {
    text-transform: none;
    letter-spacing: 0.04em;
    line-height: 1.45;
    resize: vertical;
    min-height: 8rem;
    font-family: var(--font-mono);
    white-space: pre;
    overflow-x: auto;
}

.map-editor-code-status--error {
    color: var(--rose);
}

.map-editor-cell--preview {
    cursor: default;
    pointer-events: none;
}

.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.victory-actions .btn {
    width: 100%;
    padding: 0.75rem;
}

.menu-editor-symbols {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
    font-family: var(--font-mono);
}

.editor-size-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 0.5rem 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.editor-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.editor-preset {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    min-height: 0;
}

.leaderboard-school-filters {
    margin-top: 0.5rem;
}

.leaderboard-filters-summary {
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.375rem 0;
    list-style: none;
    user-select: none;
}

.leaderboard-filters-summary::-webkit-details-marker {
    display: none;
}

.leaderboard-filters-body {
    padding: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* ─── Victory + leaderboard ─── */
.modal-card--victory {
    max-width: 52rem;
    flex-direction: column;
    gap: 1.25rem;
    max-height: min(48rem, calc(100dvh - 2.5rem));
    overflow-y: auto;
    margin: auto;
    -webkit-overflow-scrolling: touch;
}

.victory-top {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

@media (min-width: 768px) {
    .victory-top {
        flex-direction: row;
        align-items: flex-start;
    }
}

.victory-summary {
    flex: 1;
    min-width: 0;
}

.victory-snapshot {
    width: 100%;
    max-width: 13rem;
    flex-shrink: 0;
}

.leaderboard-form {
    margin: 1rem 0 0;
}

.leaderboard-form-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.375rem;
}

.leaderboard-form .text-field {
    margin-top: 0.375rem;
    width: 100%;
}

.leaderboard-status {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0.375rem 0 0;
    min-height: 1rem;
}

.leaderboard-section {
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    flex-shrink: 0;
}

.modal-card--victory .leaderboard-scroll {
    max-height: 10rem;
    overflow-y: auto;
    margin-top: 0.625rem;
}

.leaderboard-scroll {
    max-height: 12rem;
    overflow-y: auto;
    margin-top: 0.625rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.leaderboard-table th {
    text-align: left;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface-raised);
}

.leaderboard-table td {
    padding: 0.4375rem 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.leaderboard-rank {
    width: 2rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.leaderboard-name {
    font-weight: 500;
    color: var(--text-primary);
}

.leaderboard-score {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--accent);
}

.leaderboard-mode {
    white-space: nowrap;
}

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

.leaderboard-empty {
    text-align: center;
    padding: 1rem !important;
    color: var(--text-muted);
    font-style: italic;
}

.modal-card--leaderboard {
    max-width: 36rem;
    flex-direction: column;
    align-items: stretch;
    max-height: min(40rem, calc(100dvh - 2.5rem));
    margin: auto;
    overflow: hidden;
    gap: 0.875rem;
    padding: 1.25rem 1.5rem;
}

.leaderboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.modal-card--leaderboard .modal-subtitle {
    margin: 0;
    flex-shrink: 0;
}

.modal-card--leaderboard .leaderboard-source-tabs,
.modal-card--leaderboard .leaderboard-tabs,
.modal-card--leaderboard .leaderboard-school-filters,
.modal-card--leaderboard .leaderboard-school-admin,
.modal-card--leaderboard .leaderboard-actions {
    flex-shrink: 0;
}

.modal-card--leaderboard .leaderboard-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .modal-card--leaderboard {
        flex-direction: column;
    }
}

/* ─── Board TOP leaderboard ─── */
.board-top-leaderboard {
    margin-top: 1rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.board-top-leaderboard.hidden {
    display: none;
}

.board-top-leaderboard__toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.board-top-leaderboard__toggle::-webkit-details-marker {
    display: none;
}

.board-top-leaderboard__toggle .section-title {
    margin: 0;
    font-size: 0.875rem;
}

.board-top-leaderboard-meta {
    flex: 1 1 auto;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.35;
}

.board-top-leaderboard__chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.board-top-leaderboard[open] .board-top-leaderboard__chevron {
    transform: rotate(180deg);
}

.board-top-leaderboard__body {
    padding: 0 1rem 0.875rem;
    border-top: 1px solid var(--border);
}

.board-top-leaderboard__toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0 0.375rem;
}

.board-top-refresh {
    font-size: 0.6875rem;
    padding: 0.25rem 0.625rem;
    min-height: 0;
}

.board-top-leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 14rem;
    overflow-y: auto;
}

.board-top-item {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}

.board-top-item--rank-1 {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.board-top-item--me {
    outline: 2px solid var(--sage);
    outline-offset: -1px;
}

.board-top-item__rank {
    font-size: 0.875rem;
    text-align: center;
    line-height: 1;
}

.board-top-item__name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board-top-item__score {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
}

.board-top-leaderboard-status {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0.625rem 0 0;
    line-height: 1.4;
    min-height: 1rem;
}

.leaderboard-school-admin {
    margin-top: 0.75rem;
}

.leaderboard-school-admin.hidden {
    display: none;
}

.leaderboard-admin-details {
    padding: 0.625rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
}

.leaderboard-admin-details summary {
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
}

.leaderboard-admin-details .admin-pin-input {
    width: 100%;
    margin-top: 0.625rem;
}

.leaderboard-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.leaderboard-admin-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
    line-height: 1.4;
}

.btn-school-reset--danger {
    color: var(--danger, #c44);
}

/* ─── Expert split + domino pick ─── */
.expert-split-panel {
    margin-top: 0.625rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--rose-soft);
    border: 1px solid var(--rose);
}

.expert-split-msg {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
    line-height: 1.45;
}

.expert-split-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.domino-cell--pickable {
    cursor: pointer;
    transition: outline 0.15s, transform 0.15s;
}

.domino-cell--pickable:hover {
    transform: scale(1.06);
}

.domino-cell--picked {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    z-index: 2;
}

/* ─── Board appearance (pod mapou) ─── */
.board-appearance {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.board-appearance__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0.25rem 0;
}

.board-appearance__toggle::-webkit-details-marker { display: none; }

.board-appearance__toggle .section-title {
    margin: 0;
    font-size: 0.875rem;
}

.board-appearance__chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.board-appearance[open] .board-appearance__chevron {
    transform: rotate(180deg);
}

.board-appearance__body {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.appearance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.appearance-row--theme .btn-icon {
    flex-shrink: 0;
}

.appearance-select {
    min-width: 0;
    width: 100%;
}

.bg-tint-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-input {
    width: 2.25rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

.range-input {
    flex: 1;
    accent-color: var(--accent);
}

.bg-tint-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: right;
}

.appearance-reset {
    font-size: 0.6875rem;
    padding: 0.35rem 0.5rem;
    align-self: flex-start;
}

/* ─── Leaderboard tabs ─── */
.leaderboard-source-tabs {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.leaderboard-source-tab {
    font-family: var(--font-ui);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-inset);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.leaderboard-school-filters {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin: 0.5rem 0;
    padding: 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.leaderboard-school-filters.hidden {
    display: none;
}

.leaderboard-school-hint {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    line-height: 1.4;
}

.leaderboard-actions.hidden {
    display: none;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.375rem;
    margin: 0.375rem 0 0.5rem;
    flex-wrap: wrap;
}

.leaderboard-tab {
    font-family: var(--font-ui);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-inset);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.leaderboard-tab:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.leaderboard-tab--active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.leaderboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-leaderboard-reset {
    font-size: 0.6875rem;
    padding: 0.35rem 0.625rem;
    color: var(--rose);
}

.btn-leaderboard-reset:hover {
    background: var(--rose-soft);
}

#btn-save-score:disabled {
    opacity: 0.65;
    cursor: default;
}

/* ─── Daily banner ─── */
.daily-banner {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.daily-banner.hidden { display: none; }

.daily-banner__icon { font-size: 1rem; }

.weekly-banner {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.weekly-banner.hidden { display: none; }

.weekly-banner__icon { font-size: 1rem; }

.menu-daily-nudge {
    margin-top: 1rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-primary);
    text-align: left;
}

.menu-daily-nudge.hidden { display: none; }

.menu-player-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.menu-stats-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.45;
}

.menu-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.menu-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
}

.menu-stat__val {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.1;
}

.menu-stat__val--text {
    font-family: var(--font-display);
    font-size: 0.8125rem;
}

.menu-stat__lbl {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.25;
}

/* ─── Achievements ─── */
.menu-achievements-summary-wrap {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.menu-achievements-icons { margin-left: 0.35rem; }

.daily-top-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 3.5rem;
    padding: 0.3rem 0.45rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #fff8e8 0%, #ffeccc 100%);
    border: 1px solid #e8c878;
    font-size: 0.625rem;
    color: #6a4a12;
}

.daily-top-badge__icon {
    font-size: 0.875rem;
    line-height: 1;
}

.daily-top-badge__rank {
    font-weight: 700;
    font-family: var(--font-mono);
}

.daily-top-badge__date {
    opacity: 0.85;
}

.daily-top-badge--victory {
    flex-direction: row;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
}

.victory-daily-top-badge {
    margin-top: 0.5rem;
}

.daily-top-pending {
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 248, 232, 0.9);
    border: 1px solid #e8c878;
    font-size: 0.75rem;
    color: #6a4a12;
    line-height: 1.4;
}

.achievement-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.achievement-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
    font-size: 0.6875rem;
}

.achievement-badge--new {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.modal-card--badges-dual,
.modal-card--achievements {
    max-width: min(52rem, 96vw);
    width: 100%;
    flex-direction: column !important;
    align-items: stretch !important;
}

.badges-dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    margin-top: 0.75rem;
}

@media (max-width: 640px) {
    .badges-dual-grid {
        grid-template-columns: 1fr;
    }
}

.badges-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-inset);
}

.badges-panel__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badges-panel__sub {
    margin: 0.25rem 0 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.badges-panel__empty {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.daily-top-badges-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 22rem;
    overflow-y: auto;
    margin-top: 0.15rem;
}

.daily-top-card {
    display: grid;
    grid-template-columns: 2.25rem 1fr;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #e8c878;
    background: linear-gradient(180deg, #fffaf0 0%, #fff3dc 100%);
    box-sizing: border-box;
}

.daily-top-card__icon {
    font-size: 1.25rem;
    text-align: center;
    line-height: 1;
}

.daily-top-card__title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #6a4a12;
    font-family: var(--font-mono);
}

.daily-top-card__desc {
    margin: 0.15rem 0 0;
    font-size: 0.6875rem;
    color: #8a6520;
    line-height: 1.3;
}

.modal-card--badges-dual .leaderboard-modal-header,
.modal-card--achievements .leaderboard-modal-header {
    width: 100%;
}

.modal-card--badges-dual .leaderboard-modal-header .modal-title,
.modal-card--achievements .leaderboard-modal-header .modal-title {
    margin-bottom: 0;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-height: 22rem;
    overflow-y: auto;
    margin-top: 0.25rem;
}

.achievement-card {
    display: grid;
    grid-template-columns: 2.25rem 1fr auto;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-inset);
    opacity: 0.55;
    box-sizing: border-box;
}

.achievement-card > div {
    min-width: 0;
}

.achievement-card--unlocked {
    opacity: 1;
    border-color: var(--accent);
    background: var(--surface);
}

.achievement-card__icon {
    font-size: 1.35rem;
    text-align: center;
    line-height: 1;
}

.achievement-card__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.achievement-card__desc {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.achievement-card__status {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.achievement-card--unlocked .achievement-card__status {
    color: var(--accent);
}

/* ─── Victory extras ─── */
.victory-class-stats {
    margin: 0.75rem 0;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    line-height: 1.5;
}

.victory-class-stats.hidden { display: none; }

.class-stats__label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.class-stats__diff--up { color: var(--positive); }
.class-stats__diff--down { color: var(--negative); }

.victory-heatmap-legend {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}

.victory-heatmap-legend.hidden { display: none; }

.heatmap-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 10;
    background: rgba(255, 120, 20, calc(var(--heat, 0.5) * 0.72));
    mix-blend-mode: multiply;
}

.snapshot-frame .tile-cell {
    position: relative;
    overflow: hidden;
}

.mode-badge--expert-limited {
    background: var(--rose-soft);
    color: var(--rose);
    border-color: var(--rose);
}

/* ─── Variant banners ─── */
.variant-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.variant-banner--puzzle {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--text);
}

.variant-banner--timed {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--rose);
    color: var(--rose);
}

.map-editor-cell--tile {
    background: rgba(134, 239, 172, 0.2);
}

.stat-block--timer .stat-value--urgent {
    color: var(--rose);
    animation: tut-pulse 1s ease-in-out infinite;
}

.menu-daily-streak {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.35);
    font-size: 0.8125rem;
    text-align: center;
}

.menu-editor-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
    line-height: 1.45;
}

.map-editor-grid {
    display: grid;
    gap: 3px;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--surface-inset);
    border: 1px solid var(--border);
    max-width: 100%;
}

.map-editor-cell {
    aspect-ratio: 1;
    min-height: 2rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0;
}

.map-editor-cell--fog { background: rgba(148, 163, 184, 0.35); }
.map-editor-cell--rock { background: rgba(100, 116, 139, 0.35); }

.map-editor-actions,
.map-editor-import-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.map-editor-actions .btn {
    width: 100%;
    font-size: 0.75rem;
    padding: 0.5rem 0.4rem;
    white-space: normal;
    line-height: 1.25;
    min-height: 2.5rem;
}

#menu-screen-editor,
#menu-screen-load-map {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.map-editor-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-bottom: 0.75rem;
}

.map-editor-label {
    display: block;
    width: 100%;
    margin-bottom: 0.35rem;
    white-space: nowrap;
}

.map-editor-field .map-editor-input,
#menu-screen-editor .text-field,
#menu-screen-load-map .text-field {
    flex: none;
    width: 100%;
    box-sizing: border-box;
}

.custom-map-board {
    margin: 0.75rem 0;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-inset);
}

.custom-map-board__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.custom-map-board__list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.custom-map-board__item {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    gap: 0.35rem;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}

.custom-map-board__item--me {
    font-weight: 600;
    color: var(--accent);
}

.custom-map-board__empty {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
}

.custom-map-board__score {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.victory-custom-map-panel {
    margin: 0.75rem 0;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
}

.victory-custom-map-note {
    margin: 0 0 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.btn--sm {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    min-height: 0;
}

.map-editor-import-row .text-field { flex: 1; }

.keyboard-help-panel {
    padding: 0.75rem 1rem;
}

.keyboard-help-list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.keyboard-help-list kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-inset);
    font-family: var(--font-mono, monospace);
    font-size: 0.6875rem;
}

.victory-blind-bonus {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(90, 140, 100, 0.12);
    border: 1px solid rgba(90, 140, 100, 0.35);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--positive, #2d6a3e);
    text-align: center;
}

.victory-blind-bonus.hidden { display: none; }

.victory-save-image {
    width: 100%;
    margin-top: 0.625rem;
}

.my-school-ranks {
    margin: 0 0 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-inset);
}

.my-school-ranks.hidden { display: none; }

.my-school-ranks__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.my-school-ranks__toggle::-webkit-details-marker { display: none; }

.my-school-ranks__chevron {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.my-school-ranks[open] .my-school-ranks__chevron { transform: rotate(180deg); }

.my-school-ranks__body {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border);
}

.my-school-ranks__hint {
    margin: 0.5rem 0 0.75rem !important;
    font-size: 0.8125rem !important;
}

.my-school-ranks__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.my-school-ranks__toolbar .section-label {
    width: 100%;
    margin: 0;
}

.my-school-ranks__toolbar .text-field {
    flex: 1 1 10rem;
    min-width: 8rem;
}

.my-school-ranks__scroll {
    max-height: 14rem;
}

tr.my-ranks-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

tr.my-ranks-row:hover,
tr.my-ranks-row:focus-visible {
    background: var(--accent-soft);
    outline: none;
}

.my-ranks-ahead {
    font-size: 0.75rem;
    max-width: 14rem;
    white-space: normal;
    line-height: 1.35;
}

.victory-share-row {
    margin-top: 0.5rem;
}

/* ─── Mobile / tablet ─── */
@media (max-width: 1023px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-left { order: 2; }
    .board-panel { order: 1; }
    .sidebar-right { order: 3; }

    .top-bar .toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .top-bar .select-field {
        min-width: 8rem;
    }

    .tile-cell {
        min-height: 2.75rem;
    }

    .map-editor-cell {
        min-height: 2.25rem;
    }

    .modal-card--victory {
        flex-direction: column !important;
    }
}

@media (max-width: 640px) {
    .menu-card {
        padding: 1.25rem 1rem;
    }

    .menu-btn {
        padding: 1rem 1.25rem;
    }

    .brand-row {
        flex-wrap: wrap;
    }

    .stat-block {
        min-width: 4.5rem;
    }
}


