:root {
    --felt-1: #0b3d2e;
    --felt-2: #052b21;
    --card: #ffffff;
    --ink: #f8fafc;
    --muted: #cbd5e1;
    --line: rgba(15, 23, 42, 0.10);
    --shadow: 0 10px 24px rgba(0, 0, 0, .18);
    --shadow-soft: 0 8px 18px rgba(0, 0, 0, .10);
    --btn: #111827;
    --btn2: #0f766e;
    --danger: #b91c1c;
    --ok: #15803d;
    --warn: #b45309;
    --chip: #0b1220;
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background-color: #1a5e3c;
    background-image:
        radial-gradient(ellipse 110% 50% at 50% 0%,   rgba(255,255,255,0.06) 0%, transparent 65%),
        radial-gradient(ellipse 110% 50% at 50% 100%, rgba(0,0,0,0.32)       0%, transparent 65%),
        radial-gradient(ellipse 88%  88% at 50% 50%,  transparent 52%, rgba(0,0,0,0.22) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72%200.28' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='256' height='256' fill='white' filter='url(%23f)' opacity='0.085'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: auto, auto, auto, 256px 256px;
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--ink);
}

.container {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 32px;
}

.userbox,
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
    background: rgba(0, 0, 0, .22);
    border: 1px solid rgba(255, 255, 255, .14);
    color: #fff;
}

.badge.admin {
    background: rgba(168, 85, 247, .30);
}

.badge.magician {
    background: rgba(34, 197, 94, .25);
}

.badge.player {
    background: rgba(59, 130, 246, .25);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(17, 24, 39, .85);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    transition: .15s transform, .15s opacity, .15s background;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: .95;
}

.btn.secondary {
    background: rgba(15, 118, 110, .85);
}

.btn.ghost {
    background: rgba(255, 255, 255, .10);
}

.btn.danger {
    background: rgba(185, 28, 28, .85);
}

.grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.game-card,
.players-page-shell,
.player-page-shell {
    width: 100%;
    max-width: 1120px;
    margin-inline: auto;
}

.game-card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(15, 23, 42, .08);
    overflow: visible;
    min-width: 0;
}

.game-card-full {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 1120px;
    margin-inline: auto;
}

.game-card,
.panel,
.table-wrap {
    color: #0f172a;
}

.game-card .note,
.panel h3 small,
.empty,
.recent-location {
    color: #64748b;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(600px 120px at 20% 0%, rgba(15, 118, 110, .18), transparent 60%),
        linear-gradient(180deg, rgba(2, 6, 23, .03), transparent);
}

.game-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chip {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: conic-gradient(from 45deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .15), rgba(255, 255, 255, .85));
    border: 1px solid rgba(15, 23, 42, .10);
    display: grid;
    place-items: center;
    color: var(--chip);
    font-weight: 900;
    box-shadow: 0 10px 18px rgba(0, 0, 0, .12);
}

.game-title h2 {
    margin: 0;
    font-size: 18px;
}

.game-title .note {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.game-body {
    padding: 14px;
    display: grid;
    gap: 12px;
    min-width: 0;
    overflow: visible;
}

.two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: linear-gradient(180deg, rgba(2, 6, 23, .02), transparent);
    overflow: visible;
    min-width: 0;
}

.panel h3 {
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    color: #111827;
}

.panel .panel-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(15, 118, 110, .18);
    border: 1px solid rgba(103, 232, 249, .35);
    font-size: 13px;
    font-weight: 800;
}

.panel h3 small {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
}

.year-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 6px 0 10px;
    flex-wrap: wrap;
}

.year-selector .btn {
    padding: 8px 10px;
    border-radius: 10px;
}

.year-selector .total-btn {
    background: rgba(17, 24, 39, .88);
    color: #fff;
    border-color: rgba(255, 255, 255, .18);
}

.year-selector .active {
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .25);
}

.game-card .year-selector .btn {
    background: rgba(15, 23, 42, .06);
    border: 1px solid rgba(15, 23, 42, 0.10);
    color: #111827;
}

.game-card .year-selector .btn:hover {
    background: rgba(15, 23, 42, .10);
}

.game-card .year-selector .btn.active {
    background: rgba(15, 118, 110, .12);
    border-color: rgba(15, 118, 110, .35);
    color: #0f766e;
}

.game-card .year-selector .btn.total-btn {
    background: rgba(17, 24, 39, .92);
    border-color: rgba(17, 24, 39, .92);
    color: #fff;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    direction: ltr;
}

.table-wrap table {
    direction: rtl;
}

table,
.games-table,
.players-table,
.leaders-table,
.leaders-table.big {
    width: 100%;
    border-collapse: collapse;
}

table {
    min-width: 0;
    table-layout: fixed;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

th {
    text-align: right;
    background: rgba(15, 23, 42, .04);
    color: #111827;
    font-weight: 700;
}

tbody tr:nth-child(even) {
    background: rgba(2, 6, 23, .02);
}

.num {
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.profit.pos {
    color: var(--ok);
    font-weight: 700;
}

.profit.neg {
    color: var(--danger);
    font-weight: 700;
}

.empty {
    color: var(--muted);
    font-size: 13px;
    padding: 8px 2px;
}

.link {
    color: #0f766e;
    text-decoration: none;
    font-weight: 700;
}

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

.games-table th {
    color: #e6fffa;
    font-size: 15px;
    font-weight: 800;
    background: rgba(0, 0, 0, .28);
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
    text-align: right;
}

.games-table td {
    color: #f8fafc;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.games-table tr:hover {
    background: rgba(255, 255, 255, .06);
}

.footer-note {
    margin-top: 12px;
    color: rgba(255, 255, 255, .75);
    font-size: 12px;
    text-align: center;
}

.table-actions {
    display: flex;
    justify-content: flex-start;
    padding: 10px 0 0;
}

.toggle-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.header-actions {
    margin-right: auto;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.flash-stack {
    margin: 16px 0;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    border: 1px solid;
}

.flash-success {
    background: #e8f7e8;
    color: #1f6b1f;
    border-color: #b7e0b7;
}

.flash-error {
    background: #fdeaea;
    color: #8b1e1e;
    border-color: #f3b7b7;
}

.flash-warning {
    background: #fff6e5;
    color: #8a5a00;
    border-color: #f0d28a;
}

.flash-info {
    background: #eaf3ff;
    color: #174a8b;
    border-color: #b9d3f7;
}

.admin-import-grid {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.admin-import-grid form {
    margin: 0;
}

.admin-import-grid .btn {
    width: 100%;
    text-align: center;
}

.form-hint {
    margin-top: 8px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.table-meta {
    margin-bottom: 0.75rem;
    color: #e2e8f0;
    font-size: 0.95rem;
}

.games-page .btn.ghost {
    color: #0f172a;
    border-color: #0f172a;
}

.games-page .btn.primary {
    color: #ffffff;
}

.games-page h2,
.games-page h3,
.games-page th,
.games-page td {
    color: #0f172a;
}

@media (max-width: 900px) {

    html,
    body {
        overflow-x: hidden;
    }

    .container {
        width: calc(100% - 20px);
        max-width: 100%;
        margin: 0 auto;
        padding: 10px 0 18px;
    }

    .userbox,
.actions {
        width: 100%;
    }

    .grid {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
        margin-top: 10px;
    }

    .game-card,
    .players-page-shell,
    .player-page-shell,
    .game-body,
    .panel,
    .game-card-full {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .year-selector {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        overflow-x: auto;
        justify-content: flex-start;
        max-width: 100%;
    }

    .year-selector .btn {
        flex: 0 0 auto;
        min-width: 52px;
        max-width: 72px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table {
        direction: rtl;
        table-layout: auto;
        min-width: 760px;
        width: 100%;
    }
}

@media (max-width: 520px) {

    th,
    td {
        padding: 8px;
        font-size: 13px;
    }
}

/* Home board desktop width */
@media (min-width: 901px) {
    .game-card.home-board {
        width: 100%;
        max-width: 1120px;
        margin-inline: auto;
    }

    .game-card.home-board .game-body,
    .game-card.home-board .panel,
    .game-card.home-board .table-wrap {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}
