:root {
    /* Color Palette - Classic Green Felt & Premium Accents */
    --felt-green: hsl(140, 40%, 25%);
    --felt-green-dark: hsl(140, 45%, 15%);
    --bg-primary: radial-gradient(circle at center, var(--felt-green) 0%, var(--felt-green-dark) 100%);

    --bg-secondary: hsla(0, 0%, 0%, 0.2);
    --bg-tertiary: hsla(0, 0%, 0%, 0.3);

    --accent-primary: hsl(52, 76%, 45%);
    /* Gold accent */
    --accent-secondary: hsl(200, 80%, 55%);
    --accent-gradient: linear-gradient(135deg, hsl(52, 76%, 45%), hsl(42, 80%, 38%));

    --text-primary: hsl(0, 0%, 95%);
    --text-secondary: hsla(0, 0%, 100%, 0.7);

    --card-bg: hsl(0, 0%, 100%);
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.6);

    --red-suit: hsl(0, 85%, 50%);
    --black-suit: hsl(220, 20%, 10%);

    --border-radius: 12px;
    --border-radius-sm: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    /* Card Dimensions - Single Source of Truth - Balanced Desktop Size */
    --card-width: clamp(60px, 7.5vw, 95px);
    /* Reduced max from 110px */
    --card-height: clamp(84px, 10.5vw, 133px);
    /* Reduced max from 154px */
    --card-font-size-standard: clamp(16px, 1.6vw, 20px);
    --card-font-size-large: clamp(18px, 2vw, 28px);
    --card-font-size: var(--card-font-size-standard);
    --card-suit-large-size: clamp(36px, 4.5vw, 65px);
    /* Reduced max from 70px */
    --card-v-offset: 1;
    /* This will be multiplied by the base offset in JS */
}

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

html {
    scrollbar-width: none; /* Firefox */
    overflow-x: hidden;
}

html::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--felt-green-dark);
    background-image:
        var(--bg-primary),
        url('https://www.transparenttextures.com/patterns/felt.png');
    /* Subtle felt texture */
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
}

body::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.game-wrapper {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 40px 24px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.site-footer-logo {
    height: 32px;
    opacity: 0.85;
}

.site-footer-links {
    display: flex;
    gap: 24px;
}

.site-footer-links a {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer-links a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.site-footer-copy {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.5;
}

body.large-font {
    --card-font-size: var(--card-font-size-large);
}

/* Header: Title & Stats */
.game-header {
    height: 48px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.game-stats {
    display: flex;
    gap: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Mode level picker (top header) */
#mode-stat {
    position: relative;
}
.mode-level-picker {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
}
.mode-level-arrow {
    opacity: 0.5;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.mode-level-picker.open .mode-level-arrow {
    transform: rotate(180deg);
}
.mode-level-menu {
    display: none;
    position: fixed;
    top: 48px;
    right: 12px;
    /* left is set by JS to align with the picker's left edge */
    background: var(--felt-green-dark, #1b3a28);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 4px;
    flex-direction: column;
    gap: 2px;
    z-index: 1000;
}
.mode-level-picker.open .mode-level-menu {
    display: flex;
}
.mode-level-item {
    padding: 7px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    text-align: center;
    color: rgba(255,255,255,0.6);
    transition: background 0.1s, color 0.1s;
}
.mode-level-item:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}
.mode-level-item.mode-level-active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Main Layout: Game (Left) & Sidebar (Right) */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 12px;
    gap: 12px;
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    align-items: flex-start;
}

#game-seed-display:hover {
    color: var(--accent-primary);
    text-shadow: 0 0 8px var(--accent-primary);
}

.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5vh;
    width: 100%;
    max-width: 900px;
    /* Reduced from 950px to match smaller cards */
}

/* Sidebar */
/* Sidebar Header */
.sidebar-header {
    display: none;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 4px;
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    font-family: 'Syne', sans-serif;
}

#social-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--accent-primary);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

#social-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1) translateY(-1px);
    text-shadow: 0 0 10px var(--accent-primary);
}

#social-toggle-btn:active {
    transform: scale(0.95);
}

.sidebar {
    position: relative;
    width: 360px;
    background: transparent;
    border-radius: var(--border-radius);
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 32px;
    cursor: pointer;
    z-index: 1002;
    line-height: 1;
    padding: 5px;
}

.sidebar-section {
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--border-radius);
    padding: 16px;
    border: 1px solid var(--glass-border);
}

.sidebar-section h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Profile section inside sidebar */
.sidebar-profile-section {
    padding: 14px 16px;
}

.profile-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.user-avatar-circle {
    font-size: 44px;
    line-height: 1;
    background: none;
    border: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.user-avatar-circle:hover {
    background: none;
    transform: scale(1.07);
}

/* Avatar picker popup */
.avatar-picker {
    position: fixed;
    background: hsla(140, 42%, 11%, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    z-index: 9000;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
}

.avatar-option {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46px;
    line-height: 1;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.avatar-option:hover {
    background: rgba(255, 255, 255, 0.13);
    transform: scale(1.12);
}

.avatar-option.selected {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.1);
}

.btn-signout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.btn-signout:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.username {
    font-weight: 700;
    font-size: 16px;
}

.friend-code {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
}

.stats-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 14px 0;
}

/* Daily Stats Section */
.weekly-streak-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px 16px;
    margin-top: 10px;
    position: relative;
    z-index: 0;
}

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

.wsc-cal-icon {
    opacity: 0.45;
    flex-shrink: 0;
    color: var(--text-primary);
    cursor: pointer;
    transition: opacity 0.15s;
}
.wsc-cal-icon:hover {
    opacity: 0.8;
}

.wsc-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.wsc-details-btn {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--accent-primary);
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.wsc-level-picker {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0.85;
    transition: opacity 0.15s;
}

.wsc-level-picker:hover {
    opacity: 1;
}

.wsc-title-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.wsc-dropdown-arrow {
    opacity: 0.55;
    margin-left: 3px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.wsc-level-picker.open .wsc-dropdown-arrow {
    transform: rotate(180deg);
}

.wsc-level-menu {
    display: none;
    position: absolute;
    top: 46px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--felt-green-dark);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 12px 12px;
    padding: 6px;
    z-index: 500;
    box-shadow: inset 0 4px 12px rgba(0,0,0,0.25);
    flex-direction: column;
}

.wsc-level-picker.open .wsc-level-menu {
    display: flex;
}

.weekly-streak-card:has(.wsc-level-picker.open) #weekly-tracker,
.weekly-streak-card:has(.wsc-level-picker.open) .wsc-divider,
.weekly-streak-card:has(.wsc-level-picker.open) .wsc-footer {
    visibility: hidden;
}

.wsc-level-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.1s, color 0.1s;
    text-align: center;
}

.wsc-level-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.wsc-level-item.wsc-level-active {
    color: var(--accent-primary);
}

.wsc-details-btn:hover {
    opacity: 1;
}

.weekly-tracker {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
}

.weekly-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    position: relative;
    isolation: isolate;
}

.weekly-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: transparent;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
    z-index: 1;
}

.weekly-day:not(.future) {
    cursor: pointer;
}

.weekly-day:not(.future):hover .weekly-circle {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.12);
}

.weekly-day.played .weekly-circle {
    background: rgb(55, 130, 62);
    border-color: rgb(45, 110, 52);
    color: rgba(255, 255, 255, 0.9);
}

.weekly-day.played:hover .weekly-circle {
    background: rgb(65, 150, 73);
    border-color: rgb(55, 130, 62);
}

.weekly-today .weekly-circle {
    border-color: var(--accent-primary);
}

.weekly-today.played .weekly-circle {
    border-color: rgb(45, 110, 52);
}

.weekly-today.at-risk .weekly-circle {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(255, 192, 0, 0.35), 0 0 0 3px rgba(255, 192, 0, 0.1);
    animation: atRiskPulse 2s ease-in-out infinite;
}

@keyframes atRiskPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 192, 0, 0.25), 0 0 0 2px rgba(255, 192, 0, 0.08); }
    50%       { box-shadow: 0 0 16px rgba(255, 192, 0, 0.55), 0 0 0 4px rgba(255, 192, 0, 0.18); }
}

.weekly-day.future .weekly-circle {
    opacity: 0.3;
}

.weekly-day.future .weekly-label {
    opacity: 0.35;
}

.weekly-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.weekly-today .weekly-label {
    color: var(--text-primary);
}

/* Late-played day — dark green circle */
.weekly-day.played-late .weekly-circle {
    background: rgb(22, 52, 30);
    border-color: rgb(35, 70, 42);
    color: rgba(255, 255, 255, 0.35);
}

.weekly-day.played-late .weekly-label {
    color: rgba(255, 255, 255, 0.3);
}

/* Streak connector — right half */
.weekly-day.streak-right::after {
    content: none;
}

/* Streak connector — left half */
.weekly-day.streak-left::before {
    content: none;
}

.wsc-divider {
    height: 1px;
    background: var(--glass-border);
    margin-bottom: 12px;
}

.wsc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wsc-calendar-link {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 0.75;
    transition: opacity 0.15s;
}
.wsc-calendar-link:hover {
    opacity: 1;
    color: var(--text-primary);
}

.wsc-streak-label {
    font-size: 13px;
    color: var(--text-secondary);
}
.wsc-streak-label.streak-cta {
    cursor: pointer;
    transition: color 0.15s;
}
.wsc-streak-label.streak-cta:hover {
    color: var(--text-primary);
}

.wsc-streak-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.mode-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.mode-stat-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    padding: 12px 10px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
}

.mode-stat-card #standard-stat-body,
.mode-stat-card #easy-stat-body {
    min-height: 52px;
    flex-shrink: 0;
}

.mode-stat-card .mode-play-btn {
    margin-top: auto;
    flex-shrink: 0;
    padding: 5px 8px !important;
    font-size: 11px !important;
}

.mode-stat-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mode-stat-icon {
    font-size: 11px;
}

.no-games-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.mode-stat-score {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 2px;
}

.mode-stat-score-suffix {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 3px;
}

.mode-stat-detail {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-bottom: 6px;
}

.mode-play-btn {
    width: 100%;
    justify-content: center;
    font-size: 11px;
    padding: 5px 8px;
    margin-top: 8px;
}

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

.empty-state {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

/* Challenge Inbox Items */
.challenge-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.challenge-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.challenge-item.compact {
    padding: 8px;
    margin-bottom: 0;
    gap: 0;
    min-height: 40px;
}

.challenge-item.completed-compact {
    padding: 6px 10px;
}

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

.challenge-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
}

.ch-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ch-sender {
    font-weight: 600;
}

.ch-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.difficulty-tag {
    font-weight: 600;
}

.difficulty-tag.easy {
    color: var(--accent-primary);
}

.difficulty-tag.standard {
    color: var(--text-secondary);
}

.challenge-badge.draw {
    background: #9E9E9E;
}

.challenge-badge.won {
    background: #4CAF50;
}

.challenge-badge.lost {
    background: #f44336;
}

.challenge-badge.progress {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    border: 1px solid var(--accent-primary);
}

.challenge-badge.waiting {
    background: #FF9800;
}

/* Challenge card v2 — two-player layout */
.challenge-item.card-v2 {
    padding: 0;
    overflow: hidden;
    position: relative;
}

.cc-mode-badge {
    position: absolute;
    top: 7px;
    right: 10px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
    color: var(--text-secondary);
    opacity: 0.8;
    padding: 2px 6px;
    border-radius: 4px;
}

.cc-mode-badge.easy {
    background: rgba(76, 175, 80, 0.2);
}

.cc-mode-badge.standard {
    background: rgba(255, 152, 0, 0.2);
}

.cc-body {
    padding: 12px 14px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.cc-right {
    flex-direction: row-reverse;
}

.cc-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    line-height: 1;
    overflow: hidden;
    flex-shrink: 0;
    font-weight: 700;
}

.cc-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.cc-crown {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    line-height: 1;
    pointer-events: none;
}

.cc-player-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.cc-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: capitalize;
}

.cc-score {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.cc-vs-text {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cc-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.07);
    margin: 0;
}

.cc-footer {
    padding: 7px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cc-time {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.cc-status-text {
    font-size: 10px;
    font-weight: 700;
}

.cc-avatar-btn {
    cursor: pointer;
    display: inline-flex;
    border-radius: 50%;
    transition: transform 0.15s, box-shadow 0.15s;
}

.cc-avatar-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Head-to-Head Modal */
.h2h-content {
    width: 300px;
    padding: 28px 24px 24px;
    text-align: center;
}

.h2h-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.h2h-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.h2h-player .cc-avatar {
    width: 64px;
    height: 64px;
    font-size: 64px;
}

.h2h-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.h2h-vs {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0 4px;
}

.h2h-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 16px;
}

.h2h-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.h2h-stat-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.h2h-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.h2h-bar-wrap {
    margin-bottom: 12px;
}

.h2h-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: flex;
}

.h2h-bar-you {
    background: #5DBB63;
    transition: width 0.4s;
}

.h2h-bar-draw {
    background: rgba(255, 255, 255, 0.2);
    transition: width 0.4s;
}

.h2h-bar-them {
    background: var(--accent-primary);
    transition: width 0.4s;
}

.h2h-total {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
}

.h2h-empty {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    font-style: italic;
}

.h2h-history {
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.h2h-history::-webkit-scrollbar {
    width: 4px;
}

.h2h-history::-webkit-scrollbar-track {
    background: transparent;
}

.h2h-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.h2h-game-row {
    display: grid;
    grid-template-columns: 46px 58px 1fr 22px;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 12px;
}

.h2h-game-date {
    color: var(--text-secondary);
}

.h2h-game-type {
    color: var(--text-secondary);
    font-size: 11px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 4px;
    padding: 1px 5px;
    text-align: center;
}

.h2h-game-scores {
    display: grid;
    grid-template-columns: 1fr 24px 1fr;
    align-items: center;
}

.h2h-game-score {
    color: var(--text-primary);
}

.h2h-score-right {
    text-align: right;
}

.h2h-score-left {
    text-align: left;
}

.h2h-score-winner {
    color: #5DBB63;
    font-weight: 600;
}

.h2h-game-sep {
    color: var(--text-secondary);
    font-size: 10px;
    text-align: center;
}

.h2h-game-result {
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.h2h-result-win {
    background: rgba(93, 187, 99, 0.25);
    color: #5DBB63;
}

.h2h-result-draw {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.h2h-result-loss {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
}

.ad-space {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ad-placeholder {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    border: 1px dashed var(--glass-border);
    padding: 8px;
    text-align: center;
}

.ad-label {
    font-size: 9px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.ad-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Top Area */
.top-area {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    flex-direction: row-reverse;
    /* Default: FreeCells on Right */
}

.top-area.swapped-layout {
    flex-direction: row;
    /* Swapped: FreeCells on Left */
}

.free-cells,
.foundations {
    display: flex;
    gap: 4px;
}

/* Cell Styling */
.cell {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--border-radius-sm);
    background: rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.suit-icon {
    font-size: 30px;
    opacity: 0.2;
    pointer-events: none;
}

.foundation.celebrate {
    animation: foundation-pop 0.3s ease-out;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

@keyframes foundation-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

/* Tableau */
.tableau {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: 1fr;
    gap: 2px;
    position: relative;
}

.column {
    position: relative;
    z-index: 0;
    height: 100%;
    min-height: var(--card-height);
}

/* Card Styling */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    padding: 5px;
    position: absolute;
    user-select: none;
    touch-action: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.card:hover:not(.selected) {
    z-index: 50 !important;
}

.card.selected {
    transform: translateY(-12px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border: 2px solid var(--accent-primary);
}

/* Button variants */
.btn-xs {
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 4px;
    line-height: 1.4;
}

.card.highlight {
    box-shadow: 0 0 0 3px var(--accent-secondary);
}

.card.hint {
    animation: hintPulse 1.5s infinite;
    border: 2px solid var(--accent-primary);
}

@keyframes hintPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0px var(--accent-primary);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px var(--accent-primary);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0px var(--accent-primary);
    }
}

.card-corner {
    display: flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
}

.card-rank {
    font-size: var(--card-font-size);
    font-weight: 800;
}

.card-suit {
    font-size: var(--card-font-size);
    font-weight: 700;
}

.card-suit-large {
    font-size: var(--card-suit-large-size);
    position: absolute;
    bottom: 3px;
    right: 3px;
    line-height: 1;
    opacity: 0.9;
}

.card.red {
    color: var(--red-suit);
}

.card.black {
    color: var(--black-suit);
}

/* Footer Controls */
.game-footer {
    padding: 5px 16px calc(5px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    background: #1F3724;
    border-top: 1px solid var(--glass-border);
    z-index: 100;
}

.footer-group {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.new-game-container {
    position: relative;
    display: flex;
}

.btn {
    padding: 6px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    background: var(--glass-bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-sm {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 10px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: black;
    box-shadow: 0 4px 12px rgba(255, 191, 0, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(255, 191, 0, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-green {
    background: linear-gradient(135deg, #F7CB53 0%, #F19E39 100%);
    border: none;
    color: var(--felt-green-dark);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-green:hover {
    background: linear-gradient(135deg, #f9d468 0%, #f3ab50 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Footer ctrl tiles */
.ctrl-btn {
    flex-direction: column;
    justify-content: flex-end;
    gap: 1px;
    padding: 7px 12px;
    min-width: 50px;
    border-radius: 10px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    font-weight: 400;
    color: rgb(215, 229, 215);
}

.ctrl-icon {
    font-size: 25px;
    line-height: 1;
    display: block;
}

.ctrl-icon svg {
    width: 1em;
    height: 1em;
    display: block;
}

.ctrl-label {
    font-size: 9px;
    font-weight: 1000;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(215, 229, 215, 0.8);
    white-space: nowrap;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: none;
}

.ctrl-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: none;
}

#undo {
    background: transparent;
    border-color: transparent;
    color: rgb(215, 229, 215);
}

#undo .ctrl-icon {
    background: linear-gradient(135deg, #F7CB53 0%, #F19E39 100%);
    color: var(--felt-green-dark);
    border-radius: 7px;
    width: 25px;
    height: 25px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: 25px;
    line-height: 1;
}

#undo .ctrl-icon svg {
    width: 17px;
    height: 17px;
}

#undo .ctrl-label {
    background: linear-gradient(135deg, #F7CB53 0%, #F19E39 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#undo:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: transparent;
    transform: translateY(-1px);
}

#undo:hover .ctrl-icon {
    background: linear-gradient(135deg, #f9d468 0%, #f3ab50 100%);
}

#undo:active {
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(0);
}

#undo:active .ctrl-icon {
    background: linear-gradient(135deg, #e8bc47 0%, #e08e2c 100%);
}

/* Notifications */
.notification {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    border: 1px solid var(--glass-border);
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Move notifications to bottom on mobile to avoid game area */
@media (max-width: 768px) {
    .notification {
        top: auto;
        bottom: 100px;
        transform: translateX(-50%) translateY(100px);
    }

    .notification.show {
        transform: translateX(-50%) translateY(0);
    }
}

/* Modals */
.settings-modal,
.win-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.settings-modal.show,
.win-message.show {
    display: flex;
}

.settings-content,
.auth-modal-content,
.win-content {
    background: linear-gradient(135deg, var(--felt-green-dark) 0%, #000 100%);
    padding: 20px 24px;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    max-width: 420px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: winPopupEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Social Modal Restricted Overlay */
#social-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
    /* Only content should be interactive */
}

#social-modal.show {
    display: flex !important;
    pointer-events: auto;
}

.settings-content.social-content {
    background: var(--bg-primary);
    /* Match sidebar background */
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    flex-direction: column;
}

#social-modal.show .social-content {
    transform: translateX(0);
}

/* Hide sidebar scroll and close button when social overlay is open */
.sidebar:has(#social-modal.show) {
    overflow: hidden;
}

.sidebar:has(#social-modal.show)>.sidebar-header {
    visibility: hidden;
}

.settings-content.social-content .sidebar-section {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 12px;
}

.settings-content.social-content h3 {
    margin-bottom: 8px;
    opacity: 0.8;
}

@keyframes winPopupEntrance {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(40px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* New Game Popup Card */
.new-game-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
}

.new-game-backdrop.show {
    display: block;
}

.new-game-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 1000;
    width: 280px;
    background: linear-gradient(135deg, var(--felt-green-dark) 0%, #000 100%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.new-game-popup.show {
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
    animation: popupEntrance 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popupEntrance {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.new-game-popup-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    padding: 0 2px;
}

.new-game-popup-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 4px;
    overflow: hidden;
}

.new-game-option {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.new-game-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.new-game-option:active {
    background: rgba(255, 255, 255, 0.04);
}

.new-game-option-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
}

.new-game-option-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.new-game-popup-resume {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.new-game-popup-resume:hover {
    background: rgba(255, 255, 255, 0.12);
}

.new-game-popup-resume:active {
    background: rgba(255, 255, 255, 0.04);
}

.new-game-popup-cancel {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.new-game-popup-cancel:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Mode cards (used by splash screen) */
.mode-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.mode-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateX(5px);
}

.mode-icon {
    font-size: 24px;
    min-width: 32px;
    display: flex;
    justify-content: center;
}

.mode-info h3 {
    font-size: 15px;
    margin: 0;
    color: var(--accent-primary);
    font-weight: 700;
}

.mode-info p {
    font-size: 11px;
    margin: 2px 0 0;
    color: var(--text-secondary);
    line-height: 1.3;
}

.win-icon {
    font-size: 60px;
    margin-bottom: 8px;
    animation: winIconPulse 2s infinite ease-in-out;
}

@keyframes winIconPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px var(--accent-primary));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 20px var(--accent-primary));
    }
}

.challenge-overlay-content {
    background: linear-gradient(135deg, var(--felt-green-dark) 0%, #000 100%);
    padding: 22px 24px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 360px;
    position: relative;
}

.win-content h2 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 20px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.win-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.win-stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.win-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.win-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

/* Head-to-head player card on win screen */
.win-h2h-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.win-h2h-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    flex-shrink: 0;
    padding: 0 2px;
}

.win-h2h-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 0;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.win-h2h-player.win-h2h-winner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 165, 0, 0.1));
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.12);
}

.win-h2h-avatar-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.win-h2h-crown {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
}

.win-h2h-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    text-transform: capitalize;
}

.win-h2h-score {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    line-height: 1;
}

.win-h2h-player.win-h2h-winner .win-h2h-score {
    color: #FFD700;
}

.win-h2h-details {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.btn-large {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    justify-content: center;
    border-radius: 10px;
}

/* Pause Overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(25px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    transition: var(--transition);
}

body.paused .pause-overlay {
    display: flex;
}

.pause-content {
    background: var(--felt-green-dark);
    padding: 40px;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.pause-content h2 {
    font-size: 32px;
    margin-bottom: 12px;
}

.pause-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

@keyframes card-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 25px rgba(255, 255, 255, 0.4);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
    }
}

.card.flying-clone {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin: 0 !important;
}

/* Mobile Adjustments */
@media (min-width: 1025px) {
    .ctrl-btn {
        padding: 2px 12px;
    }

    .ctrl-icon {
        font-size: 15px;
    }

    .ctrl-icon svg {
        width: 3em;
        height: 1.6em;
    }

    #new-game .ctrl-icon svg {
        width: 30px;
        height: 30px;
    }

    #settings {
        gap: 1.75px;
    }
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: block !important;
    }

    .sidebar-close {
        display: block !important;
    }

    .sidebar-header {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: -360px;
        /* Hidden by default */
        height: 100dvh;
        z-index: 1001;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        border-left: 1px solid var(--glass-border);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
        background: var(--bg-primary);
    }

    .sidebar.show {
        right: 0;
    }

    .sidebar-backdrop.show {
        display: block !important;
    }
}

@media (max-width: 600px) {
    :root {
        --card-width: clamp(35px, 10.5vw, 60px);
        --card-height: clamp(50px, 14.7vw, 84px);
        --card-font-size-standard: clamp(10px, 2.5vw, 14px);
        --card-font-size-large: clamp(12px, 3.5vw, 18px);
        --card-suit-large-size: clamp(24px, 6vw, 40px);
        --card-v-offset: 1.25;
    }

    .game-header {
        padding: 0 12px;
        height: 44px;
    }

    .header-logo {
        height: 30px;
    }

    .game-stats {
        gap: 12px;
    }

    .stat-label {
        font-size: 8px;
    }

    .stat-value {
        font-size: 14px;
    }

    .main-layout {
        padding: 6px;
        gap: 6px;
    }

    .game-board {
        gap: 1.5vh;
        max-width: none;
    }

    .top-area {
        gap: 6px;
    }

    .free-cells,
    .foundations {
        gap: 4px;
    }

    .tableau {
        gap: 4px;
    }

    .card {
        padding: 3px;
    }

    .game-footer {
        padding: 7px 10px calc(10px + env(safe-area-inset-bottom, 0px));
        justify-content: space-between;
    }

    .footer-group {
        gap: 5px;
    }

    .ctrl-btn {
        padding: 7px 8px;
        min-width: 44px;
    }

    .ctrl-icon {
        font-size: 25px;
    }

    .ctrl-label {
        font-size: 8px;
    }

    #new-game .ctrl-icon svg {
        width: 30px;
        height: 30px;
        stroke-width: 1.5;
    }

    #new-game {
        gap: 0.75px;
    }

    #settings {
        gap: 1.75px;
    }

    .card-corner {
        gap: 2px;
    }
}

/* Splash Screen / Main Menu */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    background-image: var(--bg-primary), url('https://www.transparenttextures.com/patterns/felt.png');
    z-index: 2000;
    /* Higher than header/footer */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    transition: var(--transition);
}

.splash-content {
    max-width: 340px;
    width: 100%;
    padding: 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    animation: splashFadeIn 0.8s ease-out;
}

@keyframes splashFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.splash-logo {
    font-size: 60px;
    margin-bottom: 16px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

.splash-content h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 6px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.splash-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.splash-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-large {
    padding: 16px 24px;
    font-size: 16px;
    border-radius: 12px;
}

.splash-mode-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.splash-mode-selection .mode-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
}

.splash-mode-selection .mode-card:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.splash-footer {
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Landscape optimization for small heights */
@media (max-height: 600px) and (orientation: landscape) {
    .game-header {
        height: 40px;
        padding: 0 12px;
    }

    .header-logo {
        height: 26px;
    }

    .game-stats {
        gap: 16px;
    }

    .stat-value {
        font-size: 14px;
    }

    .main-layout {
        padding: 6px;
        gap: 6px;
    }

    .game-board {
        gap: 1vh;
        max-width: 800px;
        /* Reduced from 850px for smaller cards */
    }

    .game-footer {
        padding: 4px 12px calc(4px + env(safe-area-inset-bottom, 0px));
    }

    .ctrl-btn {
        padding: 4px 8px;
        min-width: 40px;
        gap: 2px;
    }

    .ctrl-icon {
        font-size: 14px;
    }

    .ctrl-label {
        display: none;
    }
}

/* Drag Avatar */
.drag-avatar {
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.5));
}

.auto-complete-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    animation: pulse 2s infinite;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }
}

@media (max-width: 600px) {
    .auto-complete-btn {
        bottom: 80px;
        /* Above mobile footer controls */
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    @keyframes pulse {
        0% {
            transform: translateX(-50%) scale(1);
        }

        50% {
            transform: translateX(-50%) scale(1.05);
        }

        100% {
            transform: translateX(-50%) scale(1);
        }
    }
}

/* Avatar Badge - personalized initial circles */
.avatar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    margin-right: 4px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.avatar-badge.sm {
    width: 35px;
    height: 35px;
    font-size: 20px;
    margin-right: 3px;
}

/* Feedback type button toggle */
.feedback-type-btn.active {
    background: rgba(255, 215, 0, 0.2) !important;
    border-color: rgba(255, 215, 0, 0.5) !important;
    color: #FFD700 !important;
}

.completed-toggle:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 215, 0, 0.3) !important;
    color: var(--accent-primary);
}

/* ── Daily Calendar ─────────────────────────────────── */
.mode-stat-card {
    cursor: pointer;
}

.mode-stat-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.cal-hint {
    float: right;
    font-size: 11px;
    opacity: 0.45;
    transition: opacity 0.15s;
}

.mode-stat-card:hover .cal-hint {
    opacity: 0.9;
}

.calendar-content {
    width: 320px;
    max-width: 95vw;
    padding: 24px 20px 20px;
    position: relative;
}

.calendar-mode-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-primary);
    font-weight: 700;
    margin-bottom: 14px;
    text-align: center;
}

.cal-mode-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-primary);
    font-weight: 700;
    margin-bottom: 14px;
}

.cal-mode-arrow {
    opacity: 0.7;
    margin-left: 3px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.cal-mode-picker.open .cal-mode-arrow {
    transform: rotate(180deg);
}

.cal-mode-title {
    color: var(--accent-primary);
    text-transform: none;
    letter-spacing: 0;
    font-size: 18px;
}

.cal-mode-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--felt-green-dark);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 4px;
    min-width: 110px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    text-transform: none;
    letter-spacing: 0;
}

.cal-mode-picker.open .cal-mode-menu {
    display: block;
}

.cal-mode-item {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.1s;
}

.cal-mode-item:hover {
    background: rgba(255,255,255,0.08);
}

.cal-mode-item.cal-mode-active {
    color: var(--accent-primary);
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.calendar-nav span {
    font-size: 15px;
    font-weight: 700;
}

.cal-nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.cal-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}

.cal-nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
    text-align: center;
}

.calendar-weekdays span {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 3px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-day {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    cursor: default;
    transition: var(--transition);
    border: 1px solid transparent;
}

.cal-day.cal-future {
    color: rgba(255, 255, 255, 0.18);
}

.cal-day.cal-today {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
    color: var(--accent-primary);
}

.cal-day.cal-won {
    background: rgba(76, 175, 80, 0.22);
    border-color: rgba(76, 175, 80, 0.4);
    color: #81c784;
    cursor: pointer;
}

.cal-day.cal-won:hover {
    background: rgba(76, 175, 80, 0.38);
}

.cal-day.cal-unplayed {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
    cursor: pointer;
}

.cal-day.cal-unplayed:hover {
    background: rgba(255, 255, 255, 0.13);
    color: var(--text-primary);
}

.cal-day.cal-today.cal-won {
    outline: 2px solid var(--accent-primary);
}

.cal-day.cal-late {
    background: rgba(22, 52, 30, 0.9);
    border-color: rgb(35, 70, 42);
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
}

.cal-day.cal-late:hover {
    background: rgb(28, 62, 36);
}

.cal-day.cal-today.cal-late {
    outline: 2px solid rgb(35, 70, 42);
}

.cal-day-score {
    font-size: 8px;
    opacity: 0.85;
    margin-top: 1px;
    color: #81c784;
    line-height: 1;
}

.cal-day.cal-late .cal-day-score {
    color: rgba(255, 255, 255, 0.35);
}

.calendar-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.cal-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
    vertical-align: middle;
}

.cal-dot-won {
    background: #81c784;
}

.cal-dot-late {
    background: rgb(35, 70, 42);
}

.cal-dot-unplayed {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.cal-loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 18px 0;
    grid-column: span 7;
}

/* ============ TUTORIAL ============ */

.tutorial-panel {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 22, 8, 0.97);
    border: 2px solid var(--accent-primary);
    border-radius: 16px;
    padding: 16px 20px;
    z-index: 8500;
    max-width: 400px;
    width: calc(100% - 32px);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.2), 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: tutorialSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tutorialSlideUp {
    from {
        transform: translateX(-50%) translateY(16px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@media (min-width: 768px) {
    .tutorial-panel {
        bottom: auto;
        top: 50%;
        right: 20px;
        left: auto;
        transform: translateY(-50%);
        width: 280px;
        animation: tutorialSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@keyframes tutorialSlideIn {
    from {
        transform: translateY(-50%) translateX(16px);
        opacity: 0;
    }

    to {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
    }
}

@media (min-width: 768px) {
    .sidebar {
        transition: filter 0.3s ease;
    }

    .tutorial-active .sidebar {
        filter: blur(4px);
        pointer-events: none;
    }
}

.tutorial-step-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
}

.tutorial-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 7px;
}

.tutorial-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 12px;
}

.tutorial-btn-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.tutorial-skip-btn,
.tutorial-back-btn {
    font-size: 11px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 14px;
    cursor: pointer;
    border-radius: 20px;
    transition: var(--transition);
}

.tutorial-skip-btn:hover,
.tutorial-back-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.35);
}

/* Foundation glow for tutorial step 1 */
.foundation.tutorial-glow,
.free-cell.tutorial-glow {
    animation: tutorialFoundationGlow 1.5s ease-in-out infinite;
}

/* Column glow uses a pseudo-element so the column stays full grid-cell width
   (keeping equal gaps to neighbours) while the visible highlight is card-width and centred */
.column.tutorial-glow {
    align-self: stretch;
}

.column.tutorial-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: var(--tutorial-col-glow-height, 100%);
    width: var(--card-width);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    animation: tutorialFoundationGlow 1.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes tutorialFoundationGlow {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.5), 0 0 18px rgba(255, 215, 0, 0.25);
        border-color: rgba(255, 215, 0, 0.45);
    }

    50% {
        box-shadow: 0 0 22px rgba(255, 215, 0, 1), 0 0 44px rgba(255, 215, 0, 0.55), 0 0 0 3px rgba(255, 215, 0, 0.55);
        border-color: rgba(255, 215, 0, 1);
    }
}

.tutorial-next-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
    background: transparent;
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 5px 14px;
    cursor: pointer;
    transition: var(--transition);
    animation: tutorialNextPulse 1.5s ease-in-out infinite;
}

.tutorial-next-btn:hover {
    background: var(--accent-primary);
    color: #000;
    animation: none;
}

@keyframes tutorialNextPulse {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(255, 215, 0, 0.4), 0 0 14px rgba(255, 215, 0, 0.2);
        border-color: rgba(255, 215, 0, 0.6);
    }

    50% {
        box-shadow: 0 0 14px rgba(255, 215, 0, 0.9), 0 0 28px rgba(255, 215, 0, 0.5);
        border-color: rgba(255, 215, 0, 1);
    }
}

/* Ghost ace animation card */
.tutorial-ghost-card {
    border-radius: var(--border-radius);
    background: white;
    display: flex;
    flex-direction: column;
    padding: 5px;
    border: 2px solid rgba(255, 215, 0, 0.9) !important;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.75), 0 4px 14px rgba(0, 0, 0, 0.35);
    opacity: 0.78;
}

/* Tutorial card to move (gold pulse) */
.card.tutorial-hint {
    animation: tutorialCardPulse 1.15s ease-in-out infinite;
    border: 2px solid var(--accent-primary) !important;
    z-index: 60 !important;
}

@keyframes tutorialCardPulse {

    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.55), 0 0 10px rgba(255, 215, 0, 0.3);
        transform: translateY(0);
    }

    50% {
        box-shadow: 0 0 0 3px rgba(255, 215, 0, 1), 0 0 26px rgba(255, 215, 0, 0.7);
        transform: translateY(-6px);
    }
}

/* Tutorial destination card (blue pulse) */
.card.tutorial-dest-hint {
    animation: tutorialDestPulse 1.15s ease-in-out infinite;
    border: 2px solid var(--accent-secondary) !important;
}

@keyframes tutorialDestPulse {

    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(60, 170, 255, 0.55), 0 0 10px rgba(60, 170, 255, 0.25);
    }

    50% {
        box-shadow: 0 0 0 3px rgba(60, 170, 255, 1), 0 0 26px rgba(60, 170, 255, 0.65);
    }
}

/* ── Multiplayer feature flag ─────────────────────────────────────────────── */
/* When MULTIPLAYER_ENABLED = false, game.js adds this class to <body>.        */
/* Flip the flag in game.js (line 1) to restore all social/challenge features. */
body.multiplayer-hidden #social-modal,
body.multiplayer-hidden #social-toggle-btn,
body.multiplayer-hidden #friend-request-dot,
body.multiplayer-hidden #challenge-friend-win,
body.multiplayer-hidden #win-challenge-context,
body.multiplayer-hidden #challenge-overlay,
body.multiplayer-hidden #challenge-modal,
body.multiplayer-hidden #h2h-modal,
body.multiplayer-hidden #social-section,
body.multiplayer-hidden #username-warning,
body.multiplayer-hidden #wsc-compete-text {
    display: none !important;
}