:root {
    --bg: #0f1117;
    --bg-elevated: #171b26;
    --bg-hover: #1e2433;
    --border: #2a3142;
    --text: #e8ecf4;
    --text-muted: #8b95a8;
    --accent: #e50914;
    --accent-soft: rgba(229, 9, 20, 0.15);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warn: #f59e0b;
    --error: #ef4444;
    --radius: 12px;
    --sidebar-w: 260px;
    --font: "DM Sans", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

code {
    font-size: 0.85em;
    background: var(--bg-hover);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

.muted {
    color: var(--text-muted);
}

/* App shell */
.app {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand strong {
    display: block;
    font-size: 1.05rem;
}

.sidebar-brand small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px 8px;
    overflow-y: auto;
}

.nav-section {
    margin-top: 14px;
}

.nav-section:first-of-type {
    margin-top: 4px;
}

.nav-section-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 10px 8px;
    font-weight: 600;
    opacity: 0.85;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 1px 0;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    box-sizing: border-box;
}

.nav-link-dashboard {
    margin-bottom: 6px;
}

.nav-link-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.92;
}

.nav-icon[data-icon="layout-dashboard"]::before {
    content: "🏠";
}

.nav-icon[data-icon="tv"]::before {
    content: "📺";
}

.nav-icon[data-icon="youtube"]::before {
    content: "▶";
    font-size: 0.75rem;
}

.nav-icon[data-icon="wallet"]::before {
    content: "₫";
    font-weight: 700;
}

.nav-icon[data-icon="dollar-sign"]::before {
    content: "$";
    font-weight: 600;
}

.nav-icon[data-icon="play"]::before {
    content: "▶";
    font-size: 0.7rem;
}

.nav-icon[data-icon="languages"]::before {
    content: "文";
    font-size: 0.85rem;
}

.nav-icon[data-icon="gamepad"]::before {
    content: "🎮";
    font-size: 0.85rem;
}

.nav-icon[data-icon="activity"]::before {
    content: "🏸";
    font-size: 0.85rem;
}

.nav-icon[data-icon="settings"]::before {
    content: "⚙";
}

.nav-group {
    margin: 2px 0 4px;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 0;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.nav-group-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-group--active .nav-group-toggle {
    color: var(--text);
}

.nav-group-title {
    flex: 1;
    min-width: 0;
}

.nav-chevron {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.15s ease;
    line-height: 1;
}

.nav-group--open .nav-chevron {
    transform: rotate(0deg);
}

.nav-group:not(.nav-group--open) .nav-chevron {
    transform: rotate(-90deg);
}

.nav-group-panel {
    display: none;
    padding: 2px 0 4px 2.35rem;
}

.nav-group--open .nav-group-panel {
    display: block;
}

.nav-link-sub {
    display: block;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link-sub:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-link-sub.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-link:hover,
.nav-group-toggle:focus-visible {
    background: var(--bg-hover);
    color: var(--text);
    outline: none;
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-manage:not(:empty) {
    padding: 0 10px 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.nav-link-manage {
    margin-top: 8px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-chip span {
    display: block;
    font-size: 0.85rem;
}

.user-chip small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.topbar {
    padding: 28px 32px 0;
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.content {
    padding: 24px 32px 48px;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Cards */
.hero-card {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, #1a2030 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 24px;
}

.hero-card h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.hero-card p {
    margin: 0;
    color: var(--text-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}

.feature-card:not(.disabled):hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.feature-card.disabled {
    opacity: 0.5;
    cursor: default;
}

.feature-card h3 {
    margin: 12px 0 6px;
    font-size: 1rem;
}

.feature-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.feature-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.feature-icon.netflix {
    background: var(--accent-soft);
    color: var(--accent);
}

.feature-icon.muted {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.feature-icon.money {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.feature-icon.manage {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.feature-icon.shopee {
    background: rgba(238, 77, 45, 0.15);
    color: #ee4d2d;
}

.feature-icon.expense {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    font-weight: 700;
}

.feature-icon.youtube {
    background: rgba(255, 0, 0, 0.12);
    color: #ff0000;
    font-weight: 700;
}

.feature-icon.media {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    font-weight: 700;
}

.feature-icon.video-translate {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-weight: 700;
}

.feature-icon.games {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    font-weight: 700;
}

/* Games — phone shell / immersive */
body.games-immersive .sidebar {
    display: none;
}

body.games-immersive .main {
    margin-left: 0;
}

body.games-immersive .topbar {
    display: none;
}

body.games-immersive .content,
body.games-immersive .main > main {
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background: #0a0c12;
}

.games-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.games-logout {
    margin: 0;
}

.games-logout .btn-ghost {
    font-size: 0.72rem;
    padding: 4px 8px;
    white-space: nowrap;
}

.games-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.games-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.games-check:hover {
    border-color: var(--primary);
}

.games-phone {
    width: 100%;
    max-width: 430px;
    min-height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.games-top {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
}

.games-top h1 {
    margin: 0;
    font-size: 1.1rem;
}

.games-coin {
    font-weight: 700;
    color: #fbbf24;
    font-size: 0.95rem;
}

.games-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.games-tabs button {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.games-tabs button.active {
    color: var(--text);
    border-bottom: 2px solid var(--primary);
}

.games-body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.games-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 12px;
    background: var(--bg-elevated);
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
}

.games-card:hover {
    border-color: var(--primary);
}

.games-card h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.games-card p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.games-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Bầu cua — bàn đỏ cam + đĩa + lưới 2×3 */
.bau-arena {
    margin: 8px 0 12px;
    padding: 14px 12px 16px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 35%, #ffe08a 0%, transparent 42%),
        repeating-conic-gradient(from 0deg at 50% 40%, #ff8a2b 0deg 8deg, #ff6a00 8deg 16deg);
    box-shadow: inset 0 0 40px rgba(120, 40, 0, 0.25);
}

.bau-plate-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.bau-plate {
    width: min(100%, 280px);
    min-height: 110px;
    padding: 18px 16px 14px;
    border-radius: 50% / 42%;
    background: linear-gradient(180deg, #fff 0%, #f3f3f3 55%, #e8e8e8 100%);
    box-shadow:
        0 8px 0 #d4d4d4,
        0 12px 20px rgba(0, 0, 0, 0.25),
        inset 0 2px 8px rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bau-die {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: #fff;
    border: 2px solid #e5e5e5;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.bau-die-hidden {
    background: linear-gradient(145deg, #fff, #f5f5f5);
}

.bau-die-q {
    font-size: 1.6rem;
    font-weight: 900;
    color: #e11d48;
    line-height: 1;
}

.bau-die-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.bau-die-label {
    font-size: 0.55rem;
    font-weight: 800;
    color: #444;
}

.bau-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0 0 12px;
}

.bau-face {
    aspect-ratio: 1;
    border-radius: 12px;
    border: 2px solid #dc2626;
    background: #fffef8;
    color: #1a1a1a;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    box-shadow: 0 2px 0 rgba(180, 40, 20, 0.35);
    padding: 4px;
}

.bau-face:active {
    transform: translateY(1px);
}

.bau-face.selected {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.55), 0 2px 0 rgba(180, 40, 20, 0.35);
    background: #fff8e1;
}

.bau-face-icon {
    font-size: 1.85rem;
    line-height: 1;
}

.bau-face-name {
    font-size: 0.72rem;
    font-weight: 800;
    color: #7f1d1d;
}

.bau-face-bet {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 22px;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #1a1205;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.bau-controls {
    background: rgba(20, 12, 8, 0.45);
    border-radius: 12px;
    padding: 10px;
}

.bau-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.bau-chip {
    border: 2px solid #fbbf24;
    border-radius: 999px;
    min-width: 48px;
    padding: 6px 10px;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
    color: #fff8e1;
    background: radial-gradient(circle at 30% 30%, #3b82f6, #1d4ed8);
}

.bau-chip.selected {
    background: radial-gradient(circle at 30% 30%, #fbbf24, #d97706);
    color: #1a1205;
    border-color: #fff;
}

.bau-amt-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: #ffe4c4;
}

.bau-amt-label .field-input {
    background: #fff;
    color: #111;
}

.btn-bau-roll {
    border: none;
    border-radius: 10px;
    padding: 12px 14px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.bau-bets-log {
    margin: 10px 2px 0;
    font-size: 0.75rem;
    color: #fff3e0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.games-invite-banner {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--primary);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

/* Xì dách — bàn bài */
.xd-table {
    position: relative;
    margin: 10px 0 14px;
    padding: 16px 12px 18px;
    border-radius: 18px;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.08), transparent 55%),
        linear-gradient(160deg, #1a6b3c 0%, #0f4a28 45%, #0a3320 100%);
    box-shadow: inset 0 0 0 3px rgba(212, 175, 55, 0.35), inset 0 0 40px rgba(0, 0, 0, 0.35);
    min-height: 220px;
    overflow: hidden;
}

.xd-table-label {
    text-align: center;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 10px;
}

.xd-seat {
    margin: 12px 0;
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.xd-seat.turn {
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.45);
}

.xd-seat.me {
    background: rgba(59, 130, 246, 0.18);
}

.xd-seat-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #f3f4f6;
    font-size: 0.85rem;
}

.xd-seat-head strong {
    font-size: 0.92rem;
}

.xd-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

.xd-score {
    font-weight: 700;
    color: #fde68a;
}

.xd-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    min-height: 88px;
    align-items: flex-end;
    padding-left: 4px;
}

.pcard {
    position: relative;
    width: 58px;
    height: 84px;
    margin-left: -14px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    transform: rotate(var(--tilt, 0deg));
    transition: transform 0.25s ease, margin 0.25s ease;
    flex-shrink: 0;
    user-select: none;
}

.pcard:first-child {
    margin-left: 0;
}

.pcard.face {
    background: linear-gradient(165deg, #fffef8 0%, #f3efe4 100%);
    border: 1px solid #d4c4a8;
    color: #1a1a1a;
    font-family: "Georgia", "Times New Roman", serif;
}

.pcard.face.red {
    color: #c41e3a;
}

.pcard.face.black {
    color: #111;
}

.pcard .pc-rank {
    position: absolute;
    top: 5px;
    left: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
}

.pcard .pc-suit-sm {
    position: absolute;
    top: 20px;
    left: 6px;
    font-size: 0.75rem;
    line-height: 1;
}

.pcard .pc-suit-lg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
}

.pcard .pc-rank-br {
    position: absolute;
    bottom: 5px;
    right: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    transform: rotate(180deg);
}

.pcard.back {
    background:
        repeating-linear-gradient(45deg, #1e3a8a 0 6px, #1e40af 6px 12px),
        linear-gradient(145deg, #1d4ed8, #1e3a8a);
    border: 2px solid #93c5fd;
}

.pcard.back::after {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.2), transparent 60%);
}

.xd-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.xd-actions .btn-primary,
.xd-actions .btn-ghost {
    flex: 1 1 40%;
}

.xd-deal-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 3;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.xd-deal-cards {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.xd-deal-cards .pcard {
    margin-left: 0;
    animation: xd-deal-fly 0.55s ease both;
}

.xd-deal-cards .pcard:nth-child(2) { animation-delay: 0.12s; }
.xd-deal-cards .pcard:nth-child(3) { animation-delay: 0.24s; }
.xd-deal-cards .pcard:nth-child(4) { animation-delay: 0.36s; }
.xd-deal-cards .pcard:nth-child(5) { animation-delay: 0.48s; }
.xd-deal-cards .pcard:nth-child(6) { animation-delay: 0.6s; }

@keyframes xd-deal-fly {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.6) rotate(-12deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

.pcard.deal-in {
    animation: xd-card-in 0.4s ease both;
}

@keyframes xd-card-in {
    from {
        opacity: 0;
        transform: translateY(-24px) rotate(-8deg);
    }
    to {
        opacity: 1;
        transform: rotate(var(--tilt, 0deg));
    }
}

.pcard.face.selected {
    outline: 2px solid #fbbf24;
    transform: translateY(-14px) rotate(var(--tilt, 0deg));
    z-index: 2;
}

/* —— Tiến lên arena (casino landscape) —— */
.tl-arena {
    position: relative;
    margin: 4px 0 8px;
    border-radius: 12px;
    overflow: hidden;
    background: #06351c;
    min-height: 320px;
    cursor: pointer;
    user-select: none;
}

.tl-arena-bg {
    position: relative;
    min-height: 240px;
    padding: 8px;
    background:
        radial-gradient(ellipse at 50% 45%, #1a8f4a 0%, #0d5c30 45%, #052816 100%);
}

.tl-oval {
    position: relative;
    margin: 0 auto;
    width: 100%;
    min-height: 220px;
    border-radius: 50% / 42%;
    border: 3px solid rgba(120, 255, 160, 0.55);
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.35),
        0 0 18px rgba(80, 220, 120, 0.25);
    background:
        repeating-radial-gradient(ellipse at 50% 50%, transparent 0, transparent 18px, rgba(140, 255, 170, 0.06) 19px, transparent 22px),
        radial-gradient(ellipse at 50% 45%, #249a52 0%, #0f6a36 55%, #0a4a26 100%);
}

.tl-info-box {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.35;
    padding: 6px 10px;
    border-radius: 8px;
    pointer-events: none;
}

.tl-info-cuoc {
    color: #fbbf24;
}

.tl-center-play {
    position: absolute;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 70px;
}

.tl-center-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
}

.tl-table-cards {
    display: flex;
    justify-content: center;
}

.tl-table-cards .pcard {
    width: 44px;
    height: 62px;
    margin-left: -16px;
    border-radius: 5px;
}

.tl-table-cards .pcard:first-child {
    margin-left: 0;
}

.tl-slot {
    position: absolute;
    z-index: 4;
}

.tl-slot-top { top: 6%; left: 50%; transform: translateX(-50%); }
.tl-slot-right { top: 42%; right: 4%; }
.tl-slot-left { top: 42%; left: 4%; }
.tl-slot-self { bottom: 4%; left: 4%; }

.tl-hud {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tl-hud.self {
    flex-direction: column;
    align-items: flex-start;
}

.tl-hud-avatar-wrap {
    position: relative;
}

.tl-hud-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(145deg, #7dd3fc, #2563eb);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tl-hud-avatar.plus {
    background: rgba(0, 0, 0, 0.25);
    border: 2px dashed rgba(120, 255, 160, 0.65);
    color: #86efac;
    font-size: 1.4rem;
    font-weight: 400;
}

.tl-hud.turn .tl-hud-avatar {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.55), 0 0 16px rgba(251, 191, 36, 0.65);
}

.tl-ring-timer {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    border-radius: 999px;
    background: #166534;
    border: 2px solid #bbf7d0;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

.tl-ring-timer.warn {
    background: #b91c1c;
    border-color: #fecaca;
}

.tl-hud-meta {
    background: rgba(0, 0, 0, 0.55);
    border-radius: 999px;
    padding: 3px 10px;
    text-align: center;
    line-height: 1.2;
}

.tl-hud-name {
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.tl-hud-coin {
    color: #fbbf24;
    font-size: 0.68rem;
    font-weight: 700;
}

.tl-card-count {
    position: relative;
    width: 28px;
    height: 38px;
}

.tl-card-count .pcard {
    width: 28px;
    height: 38px;
    margin: 0;
}

.tl-count-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    text-shadow: 0 1px 2px #000;
}

.tl-dock {
    position: relative;
    z-index: 6;
    padding: 0 8px 8px;
    margin-top: -8px;
}

.tl-action-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tl-btn {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 6px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    min-width: 96px;
}

.tl-btn:disabled {
    opacity: 0.55;
    cursor: default;
    filter: grayscale(0.2);
}

.tl-btn-pass {
    background: linear-gradient(180deg, #f87171, #dc2626 55%, #b91c1c);
    color: #fff;
}

.tl-btn-pass.active {
    opacity: 1;
    filter: none;
}

.tl-btn-hint,
.tl-btn-play {
    background: linear-gradient(180deg, #f3f4f6, #d1d5db 55%, #9ca3af);
    color: #374151;
}

.tl-btn-play.active {
    background: linear-gradient(180deg, #86efac, #22c55e 55%, #15803d);
    color: #fff;
    opacity: 1;
    filter: none;
}

.tl-my-hand {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding: 18px 8px 6px;
    min-height: 88px;
    cursor: default;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

.tl-my-hand .pcard {
    width: 52px;
    height: 74px;
    margin-left: -10px;
    cursor: pointer;
    border-radius: 6px;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
    will-change: transform;
    position: relative;
}

/* Vùng chạm rộng hơn lá bài */
.tl-my-hand .pcard::before {
    content: "";
    position: absolute;
    inset: -10px -4px -6px;
    z-index: -1;
}

.tl-my-hand .pcard:first-child {
    margin-left: 0;
}

.tl-my-hand .pcard.face:active {
    transform: translateY(-6px) rotate(var(--tilt, 0deg)) scale(1.04);
}

.tl-my-hand .pcard.face.selected {
    transform: translateY(-18px) rotate(var(--tilt, 0deg));
    outline: 2px solid #fbbf24;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
    z-index: 3;
}

.tl-fab-stack {
    position: absolute;
    right: 8px;
    bottom: 12px;
    z-index: 8;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tl-fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    padding: 0;
    line-height: 1;
}

.tl-fab-exit {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 8;
    background: linear-gradient(180deg, #4ade80, #16a34a);
}

.tl-fab-chat {
    background: linear-gradient(180deg, #4ade80, #16a34a);
}

.tl-fab-sort {
    background: linear-gradient(180deg, #60a5fa, #2563eb);
    height: 52px;
    width: 48px;
    border-radius: 14px;
}

.tl-fab-lbl {
    font-size: 0.55rem;
    font-weight: 800;
    margin-top: 2px;
}

.tl-fab:disabled {
    opacity: 0.45;
    cursor: default;
}

.tl-arena .pcard .pc-rank {
    top: 3px;
    left: 4px;
    font-size: 0.72rem;
}

.tl-arena .pcard .pc-suit-sm {
    top: 15px;
    left: 4px;
    font-size: 0.55rem;
}

.tl-arena .pcard .pc-suit-lg {
    font-size: 1.05rem;
}

.tl-arena .pcard .pc-rank-br {
    font-size: 0.72rem;
}

/* Compact phone shell */
@media (min-width: 720px) {
    .games-phone {
        max-width: 420px;
    }
}

/* —— Fullscreen mobile: phủ kín + xoay ngang —— */
html.games-fs-landscape,
html.games-fs-landscape body {
    overflow: hidden !important;
    overscroll-behavior: none;
    background: #042616 !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
}

html.games-fs-landscape .sidebar,
html.games-fs-landscape .topbar,
html.games-fs-landscape .games-top,
html.games-fs-landscape #room-meta,
html.games-fs-landscape #members,
html.games-fs-landscape #join-bar,
html.games-fs-landscape #invite-panel,
html.games-fs-landscape #btn-copy-code,
html.games-fs-landscape #btn-leave,
html.games-fs-landscape #play-err {
    display: none !important;
}

html.games-fs-landscape .app,
html.games-fs-landscape .main,
html.games-fs-landscape .content,
html.games-fs-landscape .games-phone,
html.games-fs-landscape .games-body,
html.games-fs-landscape #game-panel {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border: none !important;
    background: #042616 !important;
    overflow: hidden !important;
}

.tl-fs-scale {
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: inherit;
    position: relative;
}

.tl-fab-exit {
    display: none;
}

.tl-arena.games-table-fs {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #042616 !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: default !important;
    box-sizing: border-box !important;
}

.tl-arena.games-table-fs .tl-fab-exit {
    display: flex !important;
    top: 8px;
    right: 8px;
    z-index: 30;
    background: linear-gradient(180deg, #f87171, #dc2626);
    border-color: rgba(255, 255, 255, 0.55);
}

.tl-arena.games-table-fs .tl-fs-scale {
    width: 880px;
    height: 495px;
    flex-shrink: 0;
    transform-origin: center center;
    overflow: hidden;
    background: #06351c;
    position: relative;
    border-radius: 0;
}

.tl-arena.games-table-fs .tl-arena-bg {
    flex: 1;
    min-height: 0;
    height: 68%;
    display: flex;
    padding: 4px 6px 0;
}

.tl-arena.games-table-fs .tl-oval {
    flex: 1;
    min-height: 0;
    border-radius: 48% / 40%;
    border-width: 3px;
}

.tl-arena.games-table-fs .tl-dock {
    margin-top: 0;
    padding: 2px 8px 4px;
    height: 32%;
    box-sizing: border-box;
    overflow: hidden;
}

.tl-arena.games-table-fs .tl-my-hand .pcard {
    width: 50px;
    height: 70px;
    margin-left: -11px;
}

.tl-arena.games-table-fs .tl-my-hand {
    padding: 20px 10px 8px;
    touch-action: pan-x;
}

.tl-arena.games-table-fs .tl-table-cards .pcard,
.tl-arena.games-table-fs .xd-seat-cards .pcard {
    width: 36px;
    height: 50px;
}

.tl-arena.games-table-fs .tl-hud-avatar {
    width: 42px;
    height: 42px;
    font-size: 1rem;
}

.tl-arena.games-table-fs .tl-btn {
    padding: 9px 16px;
    font-size: 0.78rem;
    min-width: 96px;
}

.tl-arena.games-table-fs .tl-info-box {
    font-size: 0.72rem;
    padding: 5px 9px;
}

.tl-arena.games-table-fs .tl-fab {
    width: 42px;
    height: 42px;
}

.tl-arena.games-table-fs .tl-fab-sort {
    width: 46px;
    height: 50px;
}

/* Native :fullscreen cùng style phủ kín */
.tl-arena:fullscreen,
.tl-arena:-webkit-full-screen {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #042616 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}

.tl-start-in-arena {
    width: auto !important;
    margin: 0 0 6px !important;
    min-width: 160px;
}

.games-fs-exit {
    display: none;
}

.xd-seat-cards .pcard {
    width: 22px;
    height: 32px;
}

.score-table input,
.score-table select {
    width: 100%;
    font-size: 0.8rem;
}

.score-matrix-wrap {
    overflow-x: auto;
    margin: 8px 0 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.score-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 280px;
}

.score-matrix th,
.score-matrix td {
    border-bottom: 1px solid var(--border);
    padding: 8px 6px;
    text-align: center;
    white-space: nowrap;
}

.score-matrix th:first-child,
.score-matrix td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg, #0f1219);
    z-index: 1;
}

.score-matrix thead th {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 700;
}

.score-matrix tfoot th {
    background: rgba(251, 191, 36, 0.08);
}

.score-matrix .pos {
    color: #4ade80;
    font-weight: 700;
}

.score-matrix .neg {
    color: #f87171;
    font-weight: 700;
}

.score-matrix .xd-draw {
    color: #94a3b8;
    font-weight: 700;
}

.score-matrix .dealer {
    color: #fbbf24;
    font-weight: 800;
    background: rgba(251, 191, 36, 0.12);
}

.xd-result-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.xd-result-name {
    flex: 0 0 72px;
    font-size: 0.85rem;
    font-weight: 600;
}

.xd-result-row .field-input {
    flex: 1;
    min-width: 0;
}

.xd-x2-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    cursor: pointer;
    user-select: none;
}

.xd-x2-toggle input {
    accent-color: #fbbf24;
    margin: 0;
}

.xd-x2-toggle:has(input:checked) {
    background: rgba(251, 191, 36, 0.22);
    border-color: rgba(251, 191, 36, 0.55);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25);
}

.xd-x2 {
    display: inline-block;
    margin-left: 2px;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #1a1205;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    vertical-align: middle;
    line-height: 1.3;
}

.xd-summary-bar {
    margin-top: 12px;
}

.xd-summary {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 10px;
    background: rgba(251, 191, 36, 0.06);
}

.xd-summary h4 {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

.xd-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.xd-summary-row:last-child {
    border-bottom: none;
}

.xd-add-players {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
}

.xd-player-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.xd-player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-xd-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.btn-xd-add:hover {
    filter: brightness(1.05);
}

.btn-xd-remove {
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.btn-xd-remove:hover:not(:disabled) {
    filter: brightness(1.08);
}

.btn-xd-remove:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Video translate */
.vt-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    align-items: end;
}

.vt-field-full {
    grid-column: 1 / -1;
}

.vt-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.vt-mode-field {
    grid-column: 1 / -1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0;
}

.vt-mode-field legend {
    padding: 0 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vt-radio {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    cursor: pointer;
}

.vt-form-actions {
    grid-column: 1 / -1;
}

.vt-progress-wrap {
    margin: 8px 0 12px;
}

.vt-progress-bar {
    height: 10px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.vt-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), #22c55e);
    transition: width 0.35s ease;
}

.vt-progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9rem;
}

.vt-result {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vt-result video {
    width: 100%;
    max-height: 420px;
    background: #000;
    border-radius: 8px;
}

@media (max-width: 700px) {
    .vt-form {
        grid-template-columns: 1fr;
    }
}

/* OTP */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

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

.toolbar-actions form {
    margin: 0;
    display: inline-flex;
}

.toolbar-actions-otp {
    gap: 12px;
}

.toolbar-actions .btn-ghost,
.toolbar-actions a.btn-ghost {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 16px;
}

.toolbar-actions .btn-primary {
    min-height: 40px;
    padding: 10px 20px;
}

.btn-show-mail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid rgba(229, 9, 20, 0.45);
    background: linear-gradient(180deg, var(--accent-soft) 0%, rgba(229, 9, 20, 0.08) 100%);
    color: #ff6b6b;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-show-mail:hover {
    background: rgba(229, 9, 20, 0.22);
    border-color: var(--accent);
    color: #ffb4b4;
    transform: translateY(-1px);
}

.btn-show-mail:active {
    transform: translateY(0);
}

.btn-show-mail-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    font-size: 0.95rem;
    opacity: 0.95;
}

.btn-show-mail-back {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-muted);
    box-shadow: none;
}

.btn-show-mail-back:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text);
    transform: translateY(-1px);
}

.household-details {
    margin: 8px 0 0;
    padding-left: 18px;
}

.shopee-link-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 720px;
}

.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.field-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary);
}

.shopee-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

.shopee-result {
    margin-top: 20px;
}

.shopee-result-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.shopee-result-row .field-input {
    flex: 1;
}

.shopee-help {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

.shopee-help summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
}

.shopee-help-steps {
    margin: 12px 0 8px;
    padding-left: 20px;
}

.shopee-help-steps li {
    margin-bottom: 6px;
}

.otp-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.otp-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.otp-code {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.otp-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
}

.show-mail-page .show-mail-hint {
    margin: 0;
    font-size: 0.82rem;
    max-width: 36rem;
}

.mail-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 620px;
}

.mail-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.mail-card-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.mail-card-badge {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mail-card-titles {
    flex: 1;
    min-width: 0;
}

.mail-card-header h3 {
    margin: 0 0 6px;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.mail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 0.72rem;
    align-items: center;
}

.mail-meta-from {
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-meta time {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.mail-details {
    margin-top: 10px;
}

.mail-details summary {
    cursor: pointer;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.mail-body-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
    line-height: 1.45;
    max-height: 220px;
    overflow: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin: 0 0 8px;
}

.mail-preview-shell {
    border-radius: 10px;
    padding: 10px;
    background: linear-gradient(160deg, #1c2230 0%, #12151c 55%, #0f1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mail-html-viewport {
    max-width: 100%;
    max-height: 440px;
    overflow: auto;
    border-radius: 8px;
    background: #eef1f6;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    scrollbar-width: thin;
}

.mail-html-viewport::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.mail-html-viewport::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}

.mail-plain-preview {
    margin-top: 12px;
}

.mail-html-label {
    font-size: 0.7rem;
    margin: 0 0 4px;
}

.mail-html-frame {
    width: 100%;
    min-height: 180px;
    border: none;
    background: transparent;
    display: block;
    pointer-events: auto;
    vertical-align: top;
}

.mail-raw-html {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.68rem;
    line-height: 1.4;
    max-height: 240px;
    overflow: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    font-size: 0.9rem;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-sm {
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn-copy {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
}

.btn-copy.copied {
    border-color: var(--success);
    color: var(--success);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.alert-warn {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fcd34d;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at top, #1a2030 0%, var(--bg) 60%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
}

.register-card {
    max-width: 440px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand .brand-icon {
    margin: 0 auto 12px;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.4rem;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-card label {
    display: block;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.login-card input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-hint {
    margin-top: 20px;
    font-size: 0.75rem;
    text-align: center;
}

/* Money Sharing */
.money-main-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
}

.money-sharing-grid {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 20px;
    min-width: 0;
}

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

.save-name-input {
    width: 160px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

.save-name-input:focus {
    outline: none;
    border-color: var(--primary);
}

.viewer-banner {
    margin: 0 0 16px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    font-size: 0.9rem;
}

.viewer-empty-hint {
    margin: 16px 0 0;
    text-align: center;
    font-size: 0.9rem;
}

.money-sharing-readonly input[readonly] {
    cursor: default;
    opacity: 0.85;
    background: var(--bg-hover);
}

.money-sharing-readonly .input-paid:disabled {
    cursor: default;
    opacity: 1;
}

.panel-header h2,
.money-extras-panel h2 {
    margin: 0;
    font-size: 1.1rem;
}

.panel-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

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

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table .col-member {
    width: 100px;
    max-width: 100px;
}

.data-table .col-member .input-member {
    max-width: 96px;
    padding: 6px 8px;
    font-size: 0.85rem;
}

.data-table .col-num {
    width: 88px;
    text-align: right;
}

.data-table .col-num .input-qty {
    max-width: 72px;
    margin-left: auto;
    text-align: right;
}

.data-table .col-money {
    width: 120px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--success);
}

.data-table .col-paid {
    width: 40px;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
}

.data-table .col-paid input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--success);
}

.data-table thead .col-paid {
    font-size: 0;
    line-height: 0;
    color: transparent;
}

.member-row.row-paid .col-money {
    color: var(--text-muted);
}

.member-row.row-paid .input-member {
    opacity: 0.75;
}

.data-table .col-action {
    width: 36px;
    padding-left: 4px;
    padding-right: 4px;
}

.data-table input[type="text"],
.data-table input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.data-table input:focus {
    outline: none;
    border-color: var(--primary);
}

.data-table .row-total td {
    border-bottom: none;
    padding-top: 14px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

.btn-icon:hover {
    color: var(--error);
}

.money-extras-panel .field {
    display: block;
    margin-bottom: 14px;
}

.money-extras-panel .field span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.money-extras-panel input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.money-extras-panel input:focus {
    outline: none;
    border-color: var(--primary);
}

.extras-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-row strong {
    color: var(--success);
    font-size: 1.1rem;
}

.money-payment-panel {
    padding: 16px;
    min-width: 0;
}

.payment-inline {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
}

.payment-inline h3 {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.qr-block,
.momo-block {
    flex: 0 0 auto;
    min-width: 0;
}

.qr-frame {
    background: #fff;
    border-radius: 10px;
    padding: 8px;
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-frame img {
    max-width: 100%;
    height: auto;
    display: block;
}

.qr-placeholder {
    flex-direction: column;
    text-align: center;
    padding: 16px;
    font-size: 0.75rem;
    color: #333;
}

.bank-info {
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    font-size: 0.8rem;
}

.bank-info.compact {
    max-width: 160px;
}

.bank-info dt {
    color: var(--text-muted);
    margin: 0;
}

.bank-info dd {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.momo-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.momo-card.compact {
    padding: 14px;
    width: 100%;
    max-width: 166px;
}

.momo-logo {
    display: inline-block;
    background: linear-gradient(135deg, #a50064, #d82d8b);
    color: #fff;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.momo-card dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: 0.9rem;
}

.momo-card dt {
    color: var(--text-muted);
    margin: 0;
}

.momo-card dd {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.momo-phone {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.momo-card.compact .momo-phone {
    font-size: 0.95rem;
}

.momo-card.compact dl {
    gap: 6px 10px;
    font-size: 0.8rem;
}

.save-toast {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 100;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.save-toast-ok {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid var(--success);
    color: #86efac;
}

.save-toast-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--error);
    color: #fca5a5;
}

.history-panel {
    margin-top: 24px;
}

.history-panel h2 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-hint {
    margin: 0 0 12px;
    font-size: 0.8rem;
}

.history-list li,
.history-list .history-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 10px 12px;
    margin: 0 -12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    border-radius: 8px;
    transition: background 0.15s;
}

.history-item-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
}

.btn-history-delete {
    flex-shrink: 0;
    color: var(--error);
}

.btn-history-delete:hover {
    border-color: var(--error);
}

.history-list li:hover,
.history-list .history-item:hover {
    background: var(--bg-hover);
}

.history-list li.active,
.history-list .history-item.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: transparent;
}

.history-list li:last-child {
    border-bottom: none;
}

.history-id {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    color: var(--primary);
}

/* Manage */
.manage-title {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.manage-desc {
    margin: 0;
    font-size: 0.85rem;
}

.manage-header .panel-header {
    align-items: flex-start;
}

.manage-users-table .perm-cell {
    max-width: 360px;
}

.perm-tag {
    display: inline-block;
    font-size: 0.7rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    margin: 2px 4px 2px 0;
    font-family: ui-monospace, monospace;
}

.badge-muted {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 6px;
    text-transform: uppercase;
}

.manage-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.btn-danger-text {
    color: var(--error);
}

.manage-form-panel h2 {
    margin: 0 0 20px;
}

.manage-user-form .form-row {
    margin-bottom: 16px;
}

.manage-user-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.manage-user-form input[type="text"],
.manage-user-form input[type="password"] {
    display: block;
    width: 100%;
    max-width: 400px;
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
}

.perm-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 24px 0;
}

.perm-fieldset legend {
    padding: 0 8px;
    font-weight: 600;
}

.perm-feature-block {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.perm-feature-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.perm-feature-block h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.perm-checks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.perm-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.perm-key {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.feature-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.feature-ref-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.feature-ref-card h4 {
    margin: 0 0 6px;
}

.feature-ref-card ul {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 0.8rem;
}

.manage-features-ref h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

/* Expense Management */
.expense-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 20px;
    padding: 20px 24px;
}

.expense-summary-item .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.expense-summary-item strong {
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.expense-out strong {
    color: #f87171;
}

.expense-in strong {
    color: var(--success);
}

.expense-balance strong {
    color: var(--primary);
}

.expense-month-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.expense-month-input {
    width: auto;
    min-width: 150px;
}

.expense-form-panel h2,
.expense-list-panel h2 {
    margin: 0 0 16px;
    font-size: 1rem;
}

.expense-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px 16px;
    align-items: end;
}

.expense-form .field-wide {
    grid-column: 1 / -1;
}

.expense-days {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.expense-day-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.expense-day-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.expense-day-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
}

.exp-out {
    color: #f87171;
}

.exp-in {
    color: var(--success);
}

.exp-bal {
    color: var(--text-muted);
}

.expense-day-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.expense-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.expense-item:last-child {
    border-bottom: none;
}

.expense-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.expense-item-amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.expense-item-expense .expense-item-amount {
    color: #f87171;
}

.expense-item-income .expense-item-amount {
    color: var(--success);
}

.expense-item-desc {
    font-size: 0.95rem;
}

.expense-item-cat {
    font-size: 0.8rem;
}

/* YouTube channels */
.youtube-page {
    max-width: 100%;
    overflow-x: hidden;
}

.youtube-manage-panel h2,
.youtube-list-panel h2,
.youtube-owner-panel h2,
.youtube-range-panel h2 {
    margin: 0 0 14px;
    font-size: 1rem;
}

.youtube-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

.youtube-add-form .field-input {
    flex: 1;
    min-width: 160px;
}

.yt-table-wrap--menu {
    position: relative;
}

.yt-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.yt-filter-count {
    font-size: 0.8rem;
    white-space: nowrap;
}

.youtube-table tr.yt-row-filtered-out {
    display: none;
}

.youtube-table thead th.yt-th-menu {
    position: relative;
    vertical-align: middle;
    padding-top: 6px;
    padding-bottom: 6px;
}

.yt-th-inner {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: 100%;
}

.yt-th-inner--end {
    justify-content: flex-end;
    width: 100%;
}

.yt-th-label {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yt-th-menu-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.yt-th-menu:hover .yt-th-menu-btn,
.yt-th-menu-btn:focus-visible {
    opacity: 1;
}

.yt-th-menu-btn--active,
.yt-th-sorted .yt-th-menu-btn,
.yt-th-filtered .yt-th-menu-btn {
    opacity: 1;
    color: var(--primary);
}

.yt-th-menu-btn:hover {
    background: var(--bg-hover);
    opacity: 1;
}

.yt-col-popover {
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    z-index: 30;
    min-width: 168px;
    max-width: min(240px, 90vw);
    padding: 6px 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.yt-col-popover--end {
    left: auto;
    right: 0;
}

.yt-pop-heading {
    padding: 6px 12px 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}

.yt-pop-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.yt-pop-item:hover {
    background: var(--bg-hover);
}

.yt-pop-item--active {
    color: var(--primary);
    font-weight: 600;
}

.yt-pop-search {
    display: block;
    width: calc(100% - 16px);
    margin: 4px 8px 8px;
    padding: 8px 10px;
    font-size: 0.8125rem;
}

.yt-owner-filter-list {
    max-height: 180px;
    overflow-y: auto;
}

.yt-pop-item--filter {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.youtube-table,
.youtube-owner-table {
    width: 100%;
    table-layout: fixed;
}

.youtube-table {
    min-width: 920px;
}

.youtube-table th,
.youtube-table td,
.youtube-owner-table th,
.youtube-owner-table td {
    padding: 8px 6px;
    font-size: 0.85rem;
    vertical-align: middle;
}

.youtube-table .yt-col-channel {
    width: 20%;
    min-width: 140px;
}

.youtube-table .yt-col-updated {
    width: 8%;
    min-width: 72px;
    white-space: nowrap;
}

.youtube-table .yt-col-owner,
.youtube-table .yt-col-actions {
    vertical-align: middle;
}

.youtube-table .yt-col-owner {
    width: 16%;
    min-width: 128px;
}

.youtube-table .yt-col-actions {
    width: 150px;
    min-width: 150px;
    white-space: nowrap;
}

.youtube-table .yt-note-cell {
    overflow: hidden;
}

.youtube-table .yt-channel-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.yt-channel-meta {
    min-width: 0;
    overflow: hidden;
}

.yt-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.yt-thumb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.yt-handle {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yt-note {
    font-size: 0.75rem;
    margin-top: 2px;
}

.yt-action-group {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
}

.yt-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.yt-icon-btn:hover {
    transform: translateY(-1px);
}

.yt-icon-btn:active {
    transform: translateY(0);
}

.yt-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.yt-icon-btn--range {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
}

.yt-icon-btn--range:hover {
    color: #dbeafe;
    background: rgba(59, 130, 246, 0.32);
    border-color: #60a5fa;
}

.yt-icon-btn--refresh {
    color: #86efac;
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.45);
}

.yt-icon-btn--refresh:hover {
    color: #dcfce7;
    background: rgba(34, 197, 94, 0.3);
    border-color: #4ade80;
}

.yt-icon-btn--delete {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.45);
}

.yt-icon-btn--delete:hover {
    color: #fee2e2;
    background: rgba(239, 68, 68, 0.32);
    border-color: #f87171;
}

.yt-icon-btn svg {
    display: block;
    flex-shrink: 0;
}

.yt-account-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.yt-account-list li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.yt-account-list form {
    margin-left: auto;
}

.score-name-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-name-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.score-name-label {
    font-size: 0.75rem;
    font-weight: 600;
}

.score-name-input-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.score-name-row .score-name-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 12px;
    background: #1a2030;
    border: 2px solid #4a5568;
    color: #f1f5f9;
    -webkit-text-fill-color: #f1f5f9;
}

.score-name-row .score-name-input::placeholder {
    color: #94a3b8;
    opacity: 1;
}

.score-name-row .score-name-input:focus {
    border-color: var(--primary);
    background: #1e2638;
}

.score-name-row .score-name-rm {
    flex: 0 0 auto;
    width: auto;
    min-width: 2.5rem;
    min-height: 44px;
    padding: 0 10px;
    font-size: 1.25rem;
    line-height: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
}

.score-name-row .score-name-rm:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.score-name-add .score-name-input-wrap {
    margin-top: 6px;
}

.badminton-page .panel {
    margin-bottom: 16px;
}

.bm-name-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.bm-name-grid .bm-name-cell,
.bm-name-grid .score-name-input {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    font-size: 15px;
    padding: 8px 6px;
}

.bm-session-link {
    display: block;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
}

.bm-grid-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding-bottom: 4px;
}

.bm-grid {
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 100%;
}

.bm-grid th,
.bm-grid td {
    border: 1px solid var(--border);
    padding: 4px;
    text-align: center;
    vertical-align: middle;
}

.bm-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-elevated);
    text-align: left;
    max-width: 5.5rem;
    min-width: 4.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-player-name {
    font-weight: 600;
    font-size: 0.72rem;
}

.bm-cell-td {
    padding: 2px;
}

.bm-cell-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    margin: 0;
    cursor: pointer;
}

.bm-grid-chk {
    width: 1.35rem;
    height: 1.35rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.bm-sum-col {
    font-weight: 700;
    background: rgba(251, 191, 36, 0.08);
    min-width: 2rem;
}

.bm-col-warn {
    color: #fbbf24;
    font-weight: 700;
}

.bm-suggest-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.82rem;
    margin: 0 0 12px;
}

.bm-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.bm-finish-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bm-ended-banner {
    font-size: 0.78rem;
    margin: 0 0 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
}

.bm-save-hint {
    font-size: 0.75rem;
    margin: 0;
    opacity: 0.85;
}

.bm-save-hint--busy {
    color: var(--text-muted);
}

.bm-save-hint--ok {
    color: var(--success);
    font-weight: 600;
}

.bm-grid-chk--saved {
    outline: 1px solid rgba(34, 197, 94, 0.45);
    outline-offset: 1px;
}

.login-card label.login-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
}

.login-card label.login-remember input {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0;
    accent-color: var(--primary);
}

.badminton-stat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.badminton-stat-row {
    display: grid;
    grid-template-columns: minmax(4rem, 28%) 1fr 2rem;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
}

.badminton-stat-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badminton-stat-bar-wrap {
    height: 10px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
}

.badminton-stat-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    border-radius: 999px;
    min-width: 2px;
    transition: width 0.12s ease-out;
}

.badminton-stat-num {
    font-weight: 700;
    text-align: right;
}

.badminton-match-log {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.85rem;
}

.badminton-match-log li {
    margin-bottom: 8px;
}

.feature-icon.badminton {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.score-adj-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-adj-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.score-adj-field {
    flex: 1 1 7rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-adj-field .muted {
    font-size: 0.75rem;
}

.score-adj-row .score-adj-remove {
    flex: 0 0 auto;
    font-size: 1.1rem;
    line-height: 1;
    min-width: 2rem;
    margin-bottom: 2px;
}

.btn-adj-plus,
.btn-adj-minus {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.btn-adj-plus {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(74, 222, 128, 0.45);
    color: #86efac;
}

.btn-adj-plus:hover {
    background: rgba(34, 197, 94, 0.28);
    border-color: #4ade80;
    color: #bbf7d0;
}

.btn-adj-minus {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fca5a5;
}

.btn-adj-minus:hover {
    background: rgba(239, 68, 68, 0.26);
    border-color: #f87171;
    color: #fecaca;
}

.linkish {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    max-width: 100%;
}

.yt-external {
    font-size: 0.75rem;
}

.yt-note-edit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.yt-note-edit .yt-save-note {
    padding: 6px 10px;
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
}

.youtube-table .field-input.yt-note-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 0.8rem;
    padding: 6px 8px;
    min-height: 34px;
    box-sizing: border-box;
}

.yt-note-view {
    display: block;
    font-size: 0.85rem;
    line-height: 1.35;
    padding: 2px 0;
}

.yt-note-view,
.yt-owner-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.yt-videos-header h2,
.youtube-videos-panel h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.yt-video-groups {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
    min-width: 0;
}

.yt-video-group {
    min-width: 0;
    overflow: hidden;
}

.yt-video-group .data-table {
    table-layout: fixed;
    width: 100%;
}

.yt-video-group .data-table td:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yt-range-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.yt-range-form .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.yt-range-form .field span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.yt-range-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.yt-range-stat {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
}

.yt-range-stat .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.yt-range-stat .value {
    font-weight: 600;
    font-size: 1rem;
}

@media (max-width: 1100px) {
    .yt-video-groups {
        grid-template-columns: 1fr;
    }
}

.media-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.media-form .field-input {
    flex: 1;
    min-width: 260px;
}

.media-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: flex-end;
    margin-top: 16px;
}

.media-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-speeds {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.media-speeds button {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-family: inherit;
}

.media-speeds button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.media-width input[type="range"] {
    width: 220px;
}

.media-window {
    position: relative;
    display: inline-block;
    margin-top: 16px;
    padding: 22px 28px 26px;
    box-sizing: content-box;
    background: #071433 url("/images/media-frame.png") center / cover no-repeat;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.media-close {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 3;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    cursor: pointer;
}

.media-floating {
    position: fixed;
    z-index: 80;
    margin: 0;
    left: 24px;
    top: 24px;
    cursor: grab;
}

.media-frame {
    width: 720px;
    height: 405px;
    background: #000;
    position: relative;
    z-index: 1;
}

.media-frame iframe,
#media-player {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
}

.media-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #38bdf8 50%);
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main {
        margin-left: 0;
    }

    .app {
        flex-direction: column;
    }

    .otp-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .money-main-layout {
        grid-template-columns: 1fr;
    }

    .money-sharing-grid {
        grid-template-columns: 1fr;
    }

    .payment-inline {
        align-items: center;
    }

    .expense-summary {
        grid-template-columns: 1fr 1fr;
    }

    .expense-month-filter {
        grid-column: 1 / -1;
    }

    .yt-video-groups {
        grid-template-columns: 1fr;
    }
}
