:root {
    --cell-size: 28px;
    --color-bg: #edf2f7;
    --color-surface: rgba(255, 255, 255, 0.88);
    --color-border: #d4dee8;
    --color-text: #142235;
    --color-muted: #5f7187;
    --color-accent: #0f766e;
    --color-accent-strong: #115e59;
    --color-accent-soft: #d7f3ee;
    --color-win: #16a34a;
    --color-loss: #dc2626;
    --color-closed: #c0c0c0;
    --color-closed-hover: #d4d4d4;
    --color-opened: #c0c0c0;
    --color-flag: #d31818;
    --color-mine: #111111;
    --mso-frame-light: #ffffff;
    --mso-frame-mid: #c0c0c0;
    --mso-frame-shadow: #808080;
    --mso-frame-dark: #5a5a5a;
    --mso-counter-bg: #000000;
    --mso-counter-fg: #ff2d2d;
    --shadow-soft: 0 12px 30px rgba(20, 34, 53, 0.08);
    --shadow-card: 0 16px 40px rgba(20, 34, 53, 0.12);
    --radius: 4px;
    --radius-lg: 20px;
}

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

body {
    font-family: "Segoe UI", "Aptos", system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 24rem),
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 18rem),
        linear-gradient(180deg, #f8fbfd 0%, var(--color-bg) 45%, #e6edf5 100%);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--color-accent);
}

.page-shell {
    position: relative;
}

.page-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
    background-size: 36px 36px;
    opacity: 0.22;
    pointer-events: none;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(20, 34, 53, 0.88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.9rem 1.5rem;
}

.navbar-inner {
    max-width: 1680px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.navbar-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    flex: 0 0 auto;
}

.navbar-tag {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.83rem;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.navbar-auth-link {
    text-decoration: none;
}

.navbar-auth-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.84rem;
    flex: 0 0 auto;
}

.navbar-actions form {
    flex: 0 0 auto;
}

.container {
    width: min(100% - 2rem, 1680px);
    max-width: none;
    margin: 0 auto;
    padding: 2rem 0 3rem;
    position: relative;
    z-index: 1;
}

.hero-card {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.6rem 1.75rem;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(231, 246, 243, 0.96)),
        #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
}

.hero-copy {
    max-width: 44rem;
}

.hero-kicker {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-card h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    line-height: 1.05;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    max-width: 42rem;
    color: var(--color-muted);
    font-size: 1rem;
}

.list-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-stat {
    min-width: 7rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: rgba(20, 34, 53, 0.94);
    color: #fff;
    box-shadow: 0 10px 24px rgba(20, 34, 53, 0.22);
}

.hero-stat-value {
    display: block;
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 800;
}

.hero-stat-label {
    display: block;
    margin-top: 0.28rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.74);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.btn-secondary {
    padding: 0.7rem 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.68);
    color: var(--color-text);
    border: 1px solid rgba(20, 34, 53, 0.08);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 8px 18px rgba(20, 34, 53, 0.08);
}

.btn-secondary:hover {
    background: #fff;
    border-color: rgba(15, 118, 110, 0.3);
    color: var(--color-accent-strong);
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    padding: 0.82rem 1.15rem;
    font-size: 0.9rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent), #139487);
    color: #fff;
    border: 1px solid rgba(17, 94, 89, 0.38);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: saturate(1.05);
    box-shadow: 0 16px 28px rgba(15, 118, 110, 0.28);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-card {
    max-width: 32rem;
    margin: 2.5rem auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 250, 251, 0.95)),
        #fff;
    border: 1px solid rgba(20, 34, 53, 0.08);
    border-radius: 22px;
    padding: 1.7rem;
    box-shadow: var(--shadow-card);
}

.auth-card h1 {
    margin: 0 0 0.45rem 0;
    font-size: clamp(1.6rem, 2.4vw, 2rem);
    line-height: 1.08;
}

.auth-kicker {
    margin: 0 0 0.4rem 0;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-weight: 700;
}

.auth-form {
    display: grid;
    gap: 0.95rem;
    margin-top: 1.25rem;
}

.auth-field {
    display: grid;
    gap: 0.38rem;
}

.auth-field span {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text);
}

.auth-input {
    padding: 0.82rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
    background: #fff;
}

.auth-submit {
    justify-self: start;
    min-width: 8.5rem;
}

.auth-footer {
    margin-top: 1.1rem;
    color: var(--color-muted);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1rem;
    backdrop-filter: blur(12px);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.filter-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

.filter-select,
.filter-input {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--color-text);
}

.filter-select {
    cursor: pointer;
    min-width: 9rem;
}

.filter-input {
    min-width: 14rem;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.filter-clear {
    font-size: 0.8rem;
    color: var(--color-loss);
    text-decoration: none;
    align-self: center;
    padding: 0.35rem 0;
}

.filter-clear:hover {
    text-decoration: underline;
}

.table-shell {
    background: rgba(255, 255, 255, 0.56);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.68);
    box-shadow: var(--shadow-card);
    overflow: visible;
}

.table-scroll {
    overflow-x: auto;
    border-radius: 24px;
}

.game-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

.game-table th {
    position: sticky;
    top: 0;
    background: rgba(243, 248, 251, 0.96);
    backdrop-filter: blur(8px);
    text-align: left;
    padding: 0.8rem 1rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    border-bottom: 1px solid rgba(20, 34, 53, 0.08);
}

.game-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(20, 34, 53, 0.06);
    font-size: 0.92rem;
    background: rgba(255, 255, 255, 0.54);
}

.game-row {
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}

.game-row:hover td {
    background: rgba(233, 246, 243, 0.9);
}

.game-table tr:last-child td {
    border-bottom: none;
}

.game-link {
    color: var(--color-accent-strong);
    text-decoration: none;
    font-weight: 700;
}

.table-subtle {
    margin-top: 0.12rem;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.board-pill,
.result-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.25rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.board-pill {
    background: rgba(20, 34, 53, 0.08);
    color: var(--color-text);
}

.result-pill {
    background: rgba(20, 34, 53, 0.08);
}

.result-win {
    color: var(--color-win);
    font-weight: 600;
}

.result-loss {
    color: var(--color-loss);
    font-weight: 600;
}

.result-pill.result-win {
    background: rgba(22, 163, 74, 0.14);
}

.result-pill.result-loss {
    background: rgba(220, 38, 38, 0.12);
}

.note-cell {
    position: relative;
    cursor: pointer;
}

.note-icon {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--color-accent-strong);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--color-text);
    transition: all 0.15s ease;
}

.page-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

.page-current {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.page-current:hover {
    background: var(--color-accent);
    color: #fff;
}

.page-ellipsis {
    padding: 0.35rem 0.3rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.favorite-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    color: var(--color-muted);
    transition: color 0.15s ease, transform 0.15s ease;
    border-radius: 999px;
}

.favorite-btn:hover {
    color: #fbbf24;
    transform: scale(1.08);
}

.favorite-btn[data-favorite="true"] {
    color: #fbbf24;
}

.empty-state {
    margin-top: 2rem;
    padding: 2rem;
    color: var(--color-muted);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.76);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-soft);
}

.empty-state a { color: var(--color-accent); }

.th-tip {
    cursor: default;
    border-bottom: 1px dashed var(--color-border);
}

.header-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    background: rgba(26, 26, 26, 0.93);
    color: #fff;
    padding: 0.3rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 1000;
}

.header-tooltip.is-visible {
    opacity: 1;
}

.note-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateY(-100%);
    background: rgba(26, 26, 26, 0.95);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 400;
    white-space: pre-wrap;
    max-width: 250px;
    word-wrap: break-word;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.note-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(26, 26, 26, 0.95);
}

.note-loading {
    color: #999;
    font-style: italic;
}

.col-fav {
    width: 36px;
    padding-right: 0;
}

.col-new {
    width: 44px;
    text-align: center;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.badge-new {
    display: inline-block;
    padding: 0.1rem 0.38rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: var(--color-accent);
    color: #fff;
    border-radius: 999px;
    vertical-align: middle;
    box-shadow: 0 6px 14px rgba(15, 118, 110, 0.2);
}

.row-unread td {
    font-weight: 500;
    background: rgba(248, 252, 255, 0.92);
}

.col-stat {
    text-align: center;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.game-table th.col-stat {
    text-align: center;
}

.stat-bad {
    color: var(--color-loss);
    font-weight: 600;
}

.stat-good {
    color: var(--color-win);
}

.stat-mc {
    color: #db2777;
    font-weight: 600;
}

.stat-pending {
    color: var(--color-muted);
    letter-spacing: 0.08em;
    font-size: 0.75rem;
}

.stat-na {
    color: var(--color-border);
}

.detail-header {
    margin-bottom: 1rem;
}

.back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.85rem;
}

.detail-header h1 {
    margin-top: 0.25rem;
}

.game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.replay-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.board-container {
    flex-shrink: 0;
    overflow: auto;
}

.replay-sidebar {
    flex: 1;
    min-width: 240px;
}

.mso-shell {
    background: var(--mso-frame-mid);
    border-top: 3px solid var(--mso-frame-light);
    border-left: 3px solid var(--mso-frame-light);
    border-right: 3px solid var(--mso-frame-shadow);
    border-bottom: 3px solid var(--mso-frame-shadow);
    padding: 10px;
    box-shadow: 0 10px 24px rgba(20, 34, 53, 0.14);
}

.mso-panel {
    background: var(--mso-frame-mid);
    border-top: 3px solid var(--mso-frame-shadow);
    border-left: 3px solid var(--mso-frame-shadow);
    border-right: 3px solid var(--mso-frame-light);
    border-bottom: 3px solid var(--mso-frame-light);
}

.mso-counter {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 74px;
    padding: 4px 8px 2px;
    background: var(--mso-counter-bg);
    color: var(--mso-counter-fg);
    border-top: 2px solid var(--mso-frame-shadow);
    border-left: 2px solid var(--mso-frame-shadow);
    border-right: 2px solid var(--mso-frame-light);
    border-bottom: 2px solid var(--mso-frame-light);
    font-family: "Courier New", monospace;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-align: right;
    text-shadow: 0 0 2px rgba(255, 45, 45, 0.5);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    background: transparent;
    font-family: Tahoma, Verdana, "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    border: 0;
    position: relative;
    color: #111111;
    cursor: default;
}

.cell-closed {
    background: var(--color-closed);
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

.cell-opened {
    background: var(--color-opened);
    border-top: 1px solid #7b7b7b;
    border-left: 1px solid #7b7b7b;
    border-right: 1px solid #bdbdbd;
    border-bottom: 1px solid #bdbdbd;
}

.cell-flag {
    background: var(--color-closed);
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

.cell-mine {
    background: var(--color-opened);
    border-top: 1px solid #7b7b7b;
    border-left: 1px solid #7b7b7b;
    border-right: 1px solid #bdbdbd;
    border-bottom: 1px solid #bdbdbd;
}

.cell-mine-hit {
    background: #ff4444;
    border-top: 1px solid #7b7b7b;
    border-left: 1px solid #7b7b7b;
    border-right: 1px solid #bdbdbd;
    border-bottom: 1px solid #bdbdbd;
}

.cell-misflag {
    background: var(--color-opened);
    border-top: 1px solid #7b7b7b;
    border-left: 1px solid #7b7b7b;
    border-right: 1px solid #bdbdbd;
    border-bottom: 1px solid #bdbdbd;
}

.cell-selected-safe {
    background: var(--color-closed);
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

.cell-selected-safe::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid rgba(17, 124, 65, 0.95);
    box-shadow: inset 0 0 0 1px rgba(216, 247, 224, 0.95);
    pointer-events: none;
}

.cell-safe-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #117c41;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65);
    pointer-events: none;
}

.cell-clicked {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
    z-index: 1;
}

.cell-next-click {
    outline: 2px dashed #93c5fd;
    outline-offset: -2px;
    z-index: 1;
}

.cell-ng-start::before,
.cell-ng-start::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 78%;
    height: 3px;
    background: #111827;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
    pointer-events: none;
    z-index: 3;
}

.cell-ng-start::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cell-ng-start::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.cell-n1 { color: #0000ff; }
.cell-n2 { color: #008000; }
.cell-n3 { color: #ff0000; }
.cell-n4 { color: #000080; }
.cell-n5 { color: #800000; }
.cell-n6 { color: #008080; }
.cell-n7 { color: #000000; }
.cell-n8 { color: #808080; }

.board-preview-frame {
    max-width: 100%;
    overflow: auto;
    padding: 2px;
    background: #c0c0c0;
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}

.board-preview-grid {
    --preview-cell-size: 14px;
    display: grid;
    grid-template-columns: repeat(var(--preview-columns), var(--preview-cell-size));
    width: max-content;
}

.board-preview-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--preview-cell-size);
    height: var(--preview-cell-size);
    box-sizing: border-box;
    font-family: Tahoma, Verdana, "Segoe UI", sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.board-preview-cell.is-closed {
    background: var(--color-closed);
    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;
    border-right: 1px solid #808080;
    border-bottom: 1px solid #808080;
}

.board-preview-cell.is-open {
    background: var(--color-opened);
    border: 1px solid #a0a0a0;
}

.board-preview-cell.is-clicked {
    box-shadow: inset 0 0 0 2px var(--color-loss);
    z-index: 1;
}

.board-preview-cell.is-preferred {
    outline: 2px solid var(--color-win);
    outline-offset: -2px;
    z-index: 2;
}

.board-preview-cell.is-clicked.is-preferred {
    box-shadow: inset 0 0 0 2px var(--color-loss);
    outline-offset: -4px;
}

.board-preview-flag {
    width: 5px;
    height: 7px;
    background: var(--color-loss);
    clip-path: polygon(0 0, 100% 24%, 28% 50%, 28% 82%, 76% 82%, 76% 100%, 0 100%);
}

.cell-icon {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    transform: translateY(-1px);
    pointer-events: none;
}

.cell-icon-flag::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 0;
    width: 2px;
    height: 14px;
    background: #1a1a1a;
}

.cell-icon-flag {
    overflow: visible;
}

.cell-icon-flag::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 9px;
    height: 7px;
    background: linear-gradient(180deg, #ff4a4a 0%, var(--color-flag) 100%);
    clip-path: polygon(0 0, 100% 32%, 0 100%);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.cell-icon-flag.is-ghost {
    opacity: 0.48;
}

.cell-icon-mine {
    border-radius: 50%;
    background:
        radial-gradient(circle at 36% 34%, #ffffff 0 10%, transparent 11%),
        radial-gradient(circle at center, var(--color-mine) 0 42%, transparent 43%),
        linear-gradient(var(--color-mine), var(--color-mine)),
        linear-gradient(var(--color-mine), var(--color-mine)),
        linear-gradient(45deg, transparent 44%, var(--color-mine) 44% 56%, transparent 56%),
        linear-gradient(-45deg, transparent 44%, var(--color-mine) 44% 56%, transparent 56%);
    background-size: 100% 100%, 100% 100%, 2px 100%, 100% 2px, 100% 100%, 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.cell-icon-misflag-x {
    position: absolute;
    inset: 1px;
    pointer-events: none;
}

.cell-icon-misflag-x::before,
.cell-icon-misflag-x::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 15px;
    height: 2px;
    background: #cc0000;
    transform-origin: center;
}

.cell-icon-misflag-x::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cell-icon-misflag-x::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.replay-controls {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.control-buttons button {
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
}

.control-buttons button:hover {
    background: #ddd;
}

.slider-row {
    margin-bottom: 0.75rem;
}

.slider-row input[type="range"] {
    width: 100%;
}

.speed-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.speed-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.speed-btn.active {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.move-info {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 0.85rem;
}

.move-info h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.move-info .muted {
    color: var(--color-muted);
}

.move-info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
}

.move-info-grid dt {
    color: var(--color-muted);
}

.analyser-btn {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.analyser-btn:hover {
    background: #1d4ed8;
}

.analyser-btn-secondary {
    background: #64748b;
}

.analyser-btn-secondary:hover {
    background: #475569;
}

.analyser-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.replay-action-bar {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.replay-menu {
    position: relative;
    flex: 1;
}

.replay-menu > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.4rem;
    padding: 0.45rem 0.75rem;
    color: var(--color-text);
    font-size: 0.86rem;
    font-weight: 700;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.replay-menu > summary::-webkit-details-marker {
    display: none;
}

.replay-menu > summary:hover,
.replay-menu[open] > summary {
    background: var(--color-bg);
    border-color: var(--color-accent);
}

.replay-menu-icon {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.replay-menu-icon-dots {
    fill: currentColor;
    stroke: none;
}

.replay-menu-panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.35rem);
    left: 0;
    width: min(19rem, calc(100vw - 2rem));
    padding: 0.65rem;
    color: var(--color-text);
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.3);
    opacity: 1;
    backdrop-filter: none;
}

.replay-menu-align-right {
    right: 0;
    left: auto;
}

.replay-action-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    color: inherit;
    font: inherit;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: calc(var(--radius) / 2);
    cursor: pointer;
}

.replay-action-menu button:hover:not(:disabled) {
    background: var(--color-bg);
}

.replay-action-menu button:disabled,
.overlay-option-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.replay-menu-heading {
    margin: 0.3rem 0 0.2rem;
    padding: 0 0.65rem;
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.replay-menu-heading:first-child {
    margin-top: 0;
}

.menu-status {
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

.replay-view-menu {
    min-width: 5.5rem;
}

.replay-view-menu > summary {
    min-height: auto;
    padding: 0.4rem 0.7rem;
    font-family: Tahoma, Verdana, "Segoe UI", sans-serif;
    background: #c0c0c0;
    border: 2px outset #fff;
    border-radius: 0;
}

.replay-view-menu > summary:hover,
.replay-view-menu[open] > summary {
    background: #d5d5d5;
    border-color: #fff;
}

.replay-overlay-panel {
    left: 50%;
    width: min(20rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    font-family: var(--font-family, sans-serif);
}

.replay-overlay-panel fieldset {
    display: grid;
    gap: 0.42rem;
    margin: 0;
    padding: 0.55rem 0.4rem 0.65rem;
    border: 0;
    border-bottom: 1px solid var(--color-border);
}

.replay-overlay-panel fieldset:last-child {
    border-bottom: 0;
}

.replay-overlay-panel legend {
    padding: 0 0.15rem;
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.replay-overlay-panel label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.replay-overlay-panel label .menu-status {
    margin-left: auto;
}

.replay-overlay-panel input {
    margin: 0;
}

.replay-overlay-panel small {
    color: var(--color-muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.overlay-spoilers {
    background: color-mix(in srgb, #f59e0b 8%, transparent);
}

.cell-analysis {
    position: relative;
}

.cell-analysis-safe {
    background: rgba(34, 197, 94, 0.5) !important;
}

.cell-analysis-mine {
    background: rgba(239, 68, 68, 0.5) !important;
}

.cell-logic-tier {
    box-shadow: inset 0 0 0 3px rgba(20, 24, 31, 0.48);
}

.cell-logic-easy { background: #8ed8cf; }
.cell-logic-medium { background: #f1d36b; }
.cell-logic-hard { background: #ee9b55; }
.cell-logic-evil-plus { background: #d78bc6; }

.logic-tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.12rem;
    border-radius: 2px;
    color: #111827;
    font-size: 0.65rem;
    font-weight: 900;
    line-height: 1;
}

.logic-tier-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.55rem;
    margin-top: 0.45rem;
    font-size: 0.75rem;
}

.logic-tier-legend[hidden] {
    display: none;
}

.logic-tier-legend span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.logic-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid rgba(20, 24, 31, 0.55);
    border-radius: 3px;
    color: #111827;
    font-size: 0.65rem;
    font-style: normal;
    font-weight: 900;
}

.logic-swatch.logic-easy { background: #8ed8cf; }
.logic-swatch.logic-medium { background: #f1d36b; }
.logic-swatch.logic-hard { background: #ee9b55; }
.logic-swatch.logic-evil-plus { background: #d78bc6; }

.analysis-label {
    font-size: 11px;
    font-weight: 700;
    color: #000;
    text-shadow: 0 0 2px #fff, 0 0 2px #fff;
    line-height: 1;
    pointer-events: none;
}

.analysis-info {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 0.85rem;
}

.analysis-info h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.game-analysis {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.game-analysis h3 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.game-analysis .muted {
    color: var(--color-muted);
}

.mistake-nav,
.guess-nav,
.mine-count-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.mistake-nav button,
.guess-nav button,
.mine-count-nav button {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.mistake-nav button {
    background: var(--color-accent);
}

.mistake-nav button:hover {
    background: #1d4ed8;
}

.guess-nav button {
    background: #6366f1;
}

.guess-nav button:hover {
    background: #4f46e5;
}

.mine-count-nav button {
    background: #ec4899;
}

.mine-count-nav button:hover {
    background: #db2777;
}

.logic-map-navigation {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.logic-map-navigation[hidden] {
    display: none;
}

.logic-map-navigation button {
    padding-inline: 0.35rem;
    font-size: 0.72rem;
}

.logic-map-navigation span {
    white-space: nowrap;
    color: var(--color-muted);
    font-size: 0.72rem;
}

#mistake-counter,
#guess-counter,
#mine-count-counter {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.mistake-detail-card,
.guess-detail-card,
.mine-count-detail-card {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.analysis-perfect {
    color: var(--color-win);
    font-weight: 600;
    margin-top: 0.5rem;
}

.analysis-warning {
    color: var(--color-loss);
    font-weight: 600;
    margin-top: 0.5rem;
}

.analysis-error-banner {
    margin-bottom: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: color-mix(in srgb, var(--color-loss) 10%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-loss) 35%, var(--color-border));
    border-radius: var(--radius);
}

.analysis-progress p {
    margin-bottom: 0.4rem;
}

.analysis-progress .progress-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.analysis-progress .progress-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 0.3s;
}

.cell-mistake-player {
    outline: 3px solid var(--color-loss) !important;
    outline-offset: -3px;
    z-index: 2;
}

.cell-solver-best {
    outline: 3px solid var(--color-win) !important;
    outline-offset: -3px;
    z-index: 2;
}

.cell-solver-region-best {
    outline: 3px solid #f59e0b !important;
    outline-offset: -6px;
    z-index: 2;
}

.cell-dependent-safe {
    outline: 3px solid #a855f7 !important;
    outline-offset: -3px;
    z-index: 2;
}

.cell-dependent-mine {
    outline: 3px solid #f97316 !important;
    outline-offset: -3px;
    z-index: 2;
}

.cell-assistant-flag {
    background: var(--color-closed-hover);
    border-top: 2px solid #f5f5f5;
    border-left: 2px solid #f5f5f5;
    border-right: 2px solid #8a8a8a;
    border-bottom: 2px solid #8a8a8a;
}

.cell-actual-mine-ghost::after {
    content: "";
    position: absolute;
    inset: 24%;
    z-index: 3;
    opacity: 0.42;
    pointer-events: none;
    border-radius: 50%;
    background:
        linear-gradient(#111, #111) center / 2px 100% no-repeat,
        linear-gradient(90deg, #111, #111) center / 100% 2px no-repeat,
        radial-gradient(circle, #111 0 55%, transparent 58%);
}

@media (max-width: 900px) {
    .hero-card,
    .list-header-actions,
    .filter-bar,
    .replay-layout {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-card {
        padding: 1.25rem;
    }

    .hero-stat {
        width: fit-content;
    }

    .filter-select,
    .filter-input {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 1200px) {
    .navbar-site-tag {
        display: none;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1.2rem 0.85rem 2rem;
    }

    .navbar {
        padding: 0.6rem 0.85rem;
    }

    .navbar-inner {
        gap: 0.7rem;
    }

    .navbar-actions {
        gap: 0.55rem;
    }

    .navbar-auth-btn {
        padding: 0.42rem 0.72rem;
        font-size: 0.8rem;
    }

    .navbar-user-tag {
        display: none;
    }

    .hero-card h1 {
        font-size: 1.8rem;
    }

    .game-table th,
    .game-table td {
        padding: 0.72rem 0.7rem;
    }

    .page-btn {
        min-width: 1.8rem;
        padding: 0.3rem 0.5rem;
    }
}
