/* ============================================
   YAHTZEE MULTIPLAYER - CSS STYLES
   Dark theme with neon accents
   ============================================ */

:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #121a2a;
    --bg-tertiary: #1a2540;
    --bg-card: #0f1626;

    --text-primary: #e8edf5;
    --text-secondary: #8892a8;
    --text-muted: #5a6478;

    --accent-primary: #00f0ff;
    --accent-secondary: #ff00aa;
    --accent-success: #00ff88;
    --accent-warning: #ffaa00;
    --accent-danger: #ff3366;

    --border-color: #2a3550;
    --border-glow: rgba(0, 240, 255, 0.3);

    /* Dice colors */
    --dice-bg: #1a2540;
    --dice-held: #2a4050;
    --dice-dot: #00f0ff;
    --dice-border: #3a4560;

    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.4;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(0, 240, 255, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(255, 0, 170, 0.05) 0%, transparent 50%);
}

.hidden {
    display: none !important;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #0088aa);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.5);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-secondary:hover {
    background: rgba(0, 240, 255, 0.1);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* ============================================
   MODAL STYLES
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 0 50px rgba(0, 240, 255, 0.1),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.modal-body {
    margin-top: 1rem;
}

/* ============================================
   AUTH MODAL
   ============================================ */

.auth-modal-content {
    width: 400px;
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.game-title {
    font-size: 3rem;
    color: var(--accent-primary);
    text-shadow:
        0 0 10px var(--accent-primary),
        0 0 20px var(--accent-primary),
        0 0 40px var(--accent-primary);
    margin-bottom: 0.25rem;
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.game-subtitle {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--accent-secondary);
    letter-spacing: 0.5em;
}

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.auth-tab::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-primary);
    transform: scaleX(0);
    transition: transform var(--transition-fast);
}

.auth-tab.active {
    color: var(--accent-primary);
}

.auth-tab.active::after {
    transform: scaleX(1);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.auth-error {
    color: var(--accent-danger);
    font-size: 0.85rem;
    min-height: 1.2rem;
}

/* ============================================
   APP HEADER
   ============================================ */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Hamburger menu button - hidden by default */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all var(--transition-fast);
    flex-direction: column;
    gap: 4px;
    width: 32px;
    height: 32px;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1000;
    border-radius: 4px;
}

.hamburger-btn:hover {
    color: var(--accent-danger);
    background: rgba(255, 51, 102, 0.1);
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: currentColor;
    transition: all var(--transition-fast);
    border-radius: 2px;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile menu - hidden by default */
.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 999;
    padding: 1rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    visibility: hidden;
}

@media (max-width: 768px) {
    .mobile-menu {
        visibility: visible;
    }
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-header h3 {
    font-size: 1rem;
    color: var(--accent-primary);
    font-family: var(--font-display);
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    border-radius: 4px;
}

.mobile-menu-close:hover {
    color: var(--accent-danger);
    background: rgba(255, 51, 102, 0.1);
}

.mobile-menu-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 4px;
    transition: all var(--transition-fast);
    width: 100%;
}

.mobile-menu-item.btn {
    display: flex;
    justify-content: center;
}

.mobile-menu-item.hidden {
    display: none !important;
}

.mobile-menu-item.user-info {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

/* Ensure hamburger button is always clickable */
.app-header {
    position: relative;
    z-index: 1001;
}

.app-header .hamburger-btn {
    z-index: 1002;
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.user-display {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-display.clickable {
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.user-display.clickable:hover {
    color: var(--accent-primary);
    background: rgba(0, 240, 255, 0.1);
}

.user-display.clickable:hover .user-icon {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 4px var(--accent-primary));
}

.user-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    filter: drop-shadow(0 0 2px rgba(0, 240, 255, 0.3));
}

.user-name {
    display: inline-block;
}

/* ============================================
   LOBBY VIEW
   ============================================ */

.lobby-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.lobby-header h2 {
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.current-game-section {
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

.current-game-section h3 {
    font-size: 0.9rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.current-games-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.current-game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
}

.current-game-info .game-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.game-status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.game-status.status-waiting {
    color: var(--accent-warning);
}

.game-status.status-in-progress {
    color: var(--accent-success);
}

.current-game-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-danger {
    background: var(--accent-danger);
    color: var(--text-primary);
    border: 1px solid var(--accent-danger);
}

.btn-danger:hover {
    background: #ff1a4d;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
}

.btn-success {
    background: #00cc66;
    color: var(--text-primary);
    border: 1px solid #00cc66;
}

.btn-success:hover {
    background: #00e673;
    box-shadow: 0 0 15px rgba(0, 204, 102, 0.3);
}

.games-list-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.games-list-container h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.no-games {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.game-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.game-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.game-host {
    font-weight: 600;
    color: var(--text-primary);
}

.game-players {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.game-series-info {
    font-size: 0.75rem;
    color: var(--accent-warning);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: bold;
}

.stats-preview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.stats-preview h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   LEADERBOARD
   ============================================ */

.leaderboard-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.leaderboard-container h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.leaderboard-controls {
    display: flex;
    align-items: center;
}

/* Neon Checkbox Styles */
.neon-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.neon-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 0;
    height: 0;
}

.neon-checkbox .checkbox-mark {
    position: relative;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.neon-checkbox:hover .checkbox-mark {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.neon-checkbox input[type="checkbox"]:checked~.checkbox-mark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.neon-checkbox input[type="checkbox"]:checked~.checkbox-mark::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 10px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    top: 2px;
}

.neon-checkbox .checkbox-label {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color var(--transition-fast);
}

.neon-checkbox:hover .checkbox-label {
    color: var(--accent-primary);
}

.leaderboard-table-wrapper {
    overflow-x: auto;
}

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

.leaderboard-table thead {
    background: var(--bg-secondary);
}

.leaderboard-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}

.leaderboard-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
    padding-right: 1.5rem;
}

.leaderboard-table th.sortable:hover {
    color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.leaderboard-table th.sortable.active {
    color: var(--accent-primary);
}

.leaderboard-table th.sortable.asc .sort-indicator,
.leaderboard-table th.sortable.desc .sort-indicator {
    color: var(--accent-primary);
}

.sort-indicator {
    position: absolute;
    right: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.leaderboard-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.leaderboard-table tbody tr:hover:not(.section-break) {
    background: var(--bg-secondary);
}

.leaderboard-table tbody tr.dimmed {
    opacity: 0.5;
    color: var(--text-muted);
}

.leaderboard-table tbody tr.section-break {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

.leaderboard-table tbody tr.section-break td {
    padding: 0.75rem 1rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
}

.leaderboard-table td {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
}

.leaderboard-table tbody tr.dimmed td {
    color: var(--text-muted);
}

.leaderboard-table .loading-message,
.leaderboard-table .error-message,
.leaderboard-table .no-data {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

.leaderboard-table .ai-icon {
    width: 16px;
    height: 16px;
    margin-left: 0.5rem;
    vertical-align: middle;
    fill: var(--accent-primary);
    filter: drop-shadow(0 0 3px var(--accent-primary));
    display: inline-block;
}

/* ============================================
   WAITING ROOM
   ============================================ */

.waiting-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 3rem 2rem;
    text-align: center;
}

.waiting-container h2 {
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.game-code {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.game-code span:last-child {
    color: var(--accent-primary);
}

.series-type-selector {
    margin: 1.5rem 0;
    text-align: center;
}

.series-type-selector label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.series-type-dropdown {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
}

.series-type-dropdown:hover:not(:disabled) {
    border-color: var(--accent-primary);
}

.series-type-dropdown:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.players-waiting {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.players-waiting h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.players-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.players-list li {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.players-list .host-badge {
    font-size: 0.7rem;
    color: var(--accent-warning);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.players-list .ai-badge {
    font-size: 0.7rem;
    color: var(--accent-warning);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.waiting-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.waiting-message {
    color: var(--text-muted);
    font-style: italic;
    margin-top: 1rem;
}

/* ============================================
   GAME VIEW
   ============================================ */

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .game-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
        align-items: stretch;
    }

    .turn-indicator {
        grid-column: 1 / -1;
    }
}

.turn-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

#current-turn-text {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#current-player-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--accent-primary);
}

/* ============================================
   DICE AREA
   ============================================ */

.dice-area {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.dice-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.dice-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Prevent dice wrapping on mobile - ensure all 5 fit on one row */
@media (max-width: 768px) {
    .dice-container {
        flex-wrap: nowrap;
        gap: 0.5rem;
        width: 100%;
        justify-content: space-between;
        padding: 0 0.5rem;
    }

    .dice-area {
        padding: 1.5rem 1rem;
    }

    /* Reduce padding and gap on die-face to prevent overflow, similar to roll history */
    .die-face {
        padding: 4px;
        gap: 2px;
    }

    /* Adjust dot size proportionally */
    .die-dot {
        width: 8px;
        height: 8px;
    }

    /* Scale down roll button and clear held button on mobile */
    #roll-btn {
        font-size: 0.8rem;
        padding: 0.64rem 1.6rem;
        min-width: 128px;
    }

    .btn-clear-held {
        width: 33.6px;
        height: 33.6px;
    }

    .clear-held-icon {
        width: 16px;
        height: 16px;
    }
}

.die {
    width: 70px;
    height: 70px;
    background: var(--dice-bg);
    border: 2px solid var(--dice-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.die:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
}

.die.held {
    background: var(--dice-held);
    border-color: var(--accent-success);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.die.held::after {
    content: 'HOLD';
    position: absolute;
    bottom: -20px;
    font-size: 0.6rem;
    color: var(--accent-success);
    font-family: var(--font-display);
    letter-spacing: 0.1em;
}

.die.rolling {
    animation: dice-roll 0.5s ease-out;
}

@keyframes dice-roll {
    0% {
        transform: rotateX(0) rotateY(0) scale(1);
    }

    25% {
        transform: rotateX(180deg) rotateY(90deg) scale(0.9);
    }

    50% {
        transform: rotateX(360deg) rotateY(180deg) scale(1.1);
    }

    75% {
        transform: rotateX(540deg) rotateY(270deg) scale(0.95);
    }

    100% {
        transform: rotateX(720deg) rotateY(360deg) scale(1);
    }
}

.die-face {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 10px;
    gap: 4px;
}

.die-dot {
    width: 12px;
    height: 12px;
    background: var(--dice-dot);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--dice-dot);
}

.dice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.controls-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-clear-held {
    position: absolute;
    right: 10%;
    top: 7%;
    width: 42px;
    height: 42px;
    padding: 0;
    background: #00cc66;
    border: 1px solid #00e673;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-clear-held:hover {
    background: #00e673;
    box-shadow: 0 0 15px rgba(0, 204, 102, 0.3);
    transform: translateY(-1%);
}

.btn-clear-held:active {
    transform: translateY(0);
}

.clear-held-icon {
    width: 20px;
    height: 20px;
    fill: white;
}

.rolls-counter {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   ODDS DISPLAY
   ============================================ */

.odds-display {
    width: 100%;
    margin-top: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.odds-header {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.odds-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.odds-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
}

.odds-hand-name {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.odds-right-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    min-width: 140px;
    text-align: right;
}

.odds-percentage {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-primary);
    font-weight: 600;
    text-align: right;
    min-width: 50px;
    display: inline-block;
}

.odds-score-range {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-secondary);
    font-weight: 600;
    text-align: right;
    min-width: 60px;
    display: inline-block;
}

.odds-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem;
}

.odds-score-now-btn {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--accent-success), #00aa66);
    color: var(--bg-primary);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    min-width: 50px;
    text-align: center;
}

.odds-score-now-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
    background: linear-gradient(135deg, #00ff99, #00cc77);
}

.odds-score-now-btn:active {
    transform: translateY(0);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

/* ============================================
   ROLL HISTORY
   ============================================ */

.roll-history {
    width: 100%;
    margin-top: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.roll-history-header {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.roll-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.roll-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-secondary);
}

.roll-history-dice {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.roll-history-die {
    width: 32px;
    height: 32px;
    background: var(--dice-bg);
    border: 1px solid var(--dice-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    position: relative;
}

.roll-history-die.held {
    background: var(--dice-held);
    border-color: var(--accent-success);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.roll-history-die-face {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}

.roll-history-die-dot {
    width: 5px;
    height: 5px;
    background: var(--dice-dot);
    border-radius: 50%;
    box-shadow: 0 0 3px var(--dice-dot);
}

.roll-history-max-score {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-secondary);
    font-weight: 600;
}

.roll-history-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem;
}

/* ============================================
   GAME CHAT
   ============================================ */

.game-chat {
    width: 100%;
    margin-top: auto;
    margin-bottom: 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    height: 250px;
    flex-shrink: 0;
    overflow: hidden;
}

.game-chat-header {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.game-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
    margin-bottom: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) var(--bg-tertiary);
}

.game-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.game-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.game-chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 3px;
}

.game-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

.game-chat-message {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 2px solid var(--accent-primary);
    animation: slideIn 0.2s ease;
    gap: 0.5rem;
}

.game-chat-message.own-message {
    border-left-color: var(--accent-success);
    background: rgba(0, 255, 136, 0.05);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.game-chat-content {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.game-chat-username {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.game-chat-message.own-message .game-chat-username {
    color: var(--accent-success);
}

.game-chat-timestamp {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    white-space: nowrap;
    flex-shrink: 0;
}

.game-chat-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

.game-chat-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem;
}

.game-chat-input-form {
    display: flex;
    gap: 0.5rem;
}

.game-chat-input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.game-chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.game-chat-input::placeholder {
    color: var(--text-muted);
}

.game-chat-send-btn {
    padding: 0.6rem 0.75rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 4px;
    color: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-chat-send-btn:hover {
    background: var(--accent-secondary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.game-chat-send-btn:active {
    transform: scale(0.95);
}

.game-chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   SCORECARD
   ============================================ */

.scorecard-area {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.scorecard-wrapper {
    overflow-x: auto;
}

.scorecard {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.scorecard th,
.scorecard td {
    padding: 0.6rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.scorecard th {
    background: var(--bg-tertiary);
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scorecard .category-col {
    text-align: left;
    min-width: 140px;
}

.scorecard .player-col {
    min-width: 80px;
}

.section-header td {
    background: var(--bg-tertiary);
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--accent-secondary);
    letter-spacing: 0.15em;
    text-align: left;
    padding: 0.5rem 0.75rem;
}

.category-name {
    text-align: left;
    font-weight: 600;
    position: relative;
}

.category-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Tooltip styles */
.category-tooltip {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    max-width: 280px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%) translateX(-10px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    box-shadow:
        0 0 20px rgba(0, 240, 255, 0.3),
        inset 0 0 10px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

.category-tooltip.visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.category-tooltip::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--accent-primary);
}

.category-tooltip::after {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--bg-secondary);
}

.category-tooltip.tooltip-left::before {
    left: auto;
    right: -8px;
    border-right: none;
    border-left: 8px solid var(--accent-primary);
}

.category-tooltip.tooltip-left::after {
    left: auto;
    right: -7px;
    border-right: none;
    border-left: 8px solid var(--bg-secondary);
}

.score-cell {
    font-family: var(--font-display);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    background-color: transparent;
    position: relative;
}

.score-cell.available {
    cursor: pointer;
    color: var(--accent-primary);
    background: rgba(0, 240, 255, 0.15);
}

.score-cell.available:hover {
    background: rgba(0, 240, 255, 0.25);
}

.score-cell.scored {
    color: var(--text-secondary);
}

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

.score-cell.current-player {
    background: rgba(0, 240, 255, 0.08);
}

.score-cell.available.current-player {
    background: rgba(0, 240, 255, 0.15);
}

.score-cell.available.current-player:hover {
    background: rgba(0, 240, 255, 0.25);
}

/* Override background colors when highlight is active to ensure visibility */
.score-cell.score-highlight.current-player,
.score-cell.score-highlight.available,
.score-cell.score-highlight.available.current-player {
    background: transparent;
}

/* Score highlight animation - use pseudo-element to avoid conflicts */
.score-cell.score-highlight {
    position: relative;
}

.score-cell.score-highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 240, 255, 0.6);
    z-index: 0;
    animation: scoreHighlightFade 2.5s ease-out;
    pointer-events: none;
    border-radius: 4px;
}

@keyframes scoreHighlightFade {
    0% {
        opacity: 0;
    }

    14.3% {
        /* 0.5s / 3.5s = 14.3% - peak brightness after fade-in */
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.subtotal-row td,
.bonus-row td {
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.8rem;
}

.total-row td {
    background: var(--bg-tertiary);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-primary);
}

/* Forfeited player styles */
.score-cell.forfeited,
.subtotal-row .forfeited,
.bonus-row .forfeited,
.total-row .forfeited {
    position: relative;
}

.score-cell.forfeited::after,
.subtotal-row .forfeited::after,
.bonus-row .forfeited::after,
.total-row .forfeited::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right,
            transparent calc(50% - 1px),
            var(--text-muted) calc(50% - 1px),
            var(--text-muted) calc(50% + 1px),
            transparent calc(50% + 1px));
    pointer-events: none;
}

.scorecard th.forfeited-player {
    text-decoration: line-through;
    opacity: 0.6;
}

/* ============================================
   GAME OVER MODAL
   ============================================ */

.game-over-content {
    width: 500px;
    text-align: center;
}

/* ============================================
   ADMIN MODAL
   ============================================ */

.admin-modal-content {
    width: 600px;
    max-width: 90%;
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    border-radius: 4px;
}

.btn-close:hover {
    color: var(--accent-danger);
    background: rgba(255, 51, 102, 0.1);
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.admin-section h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-family: var(--font-display);
}

.admin-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-select {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    max-width: 400px;
    min-width: 200px;
    width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.admin-message {
    border-radius: 4px;
    font-size: 0.9rem;
}

.admin-message-error {
    padding: 0.75rem;
    background: rgba(255, 51, 102, 0.1);
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
}

.admin-message-success {
    padding: 0.75rem;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--accent-success);
    color: var(--accent-success);
}

.admin-current-game-info {
    margin-bottom: 1rem;
}

.admin-current-game-info p {
    margin: 0.5rem 0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.admin-no-game-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.admin-dice-controls {
    margin-top: 1rem;
}

.admin-dice-controls label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

.admin-dice-dropdowns {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-die-select {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.admin-die-select:hover {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.admin-die-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.admin-dice-warning {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.5);
    border-radius: 4px;
    color: rgba(255, 193, 7, 0.9);
    font-size: 0.85rem;
    text-align: center;
}

/* ============================================
   USER EDIT MODAL
   ============================================ */

.user-edit-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.user-edit-form .form-group {
    text-align: left;
}

.user-edit-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.user-edit-form .form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

.user-edit-form .form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

#game-over-title {
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
}

.winner-display {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-primary));
    border: 2px solid var(--accent-success);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.2);
}

.winner-label {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-success);
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}

.winner-name {
    display: block;
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.winner-score {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--accent-primary);
}

.final-scores {
    margin-bottom: 1.5rem;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.final-score-item.winner {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--accent-success);
}

.final-score-rank {
    font-family: var(--font-display);
    color: var(--text-muted);
    width: 30px;
}

.final-score-name {
    flex: 1;
    text-align: left;
}

.final-score-value {
    font-family: var(--font-display);
    color: var(--accent-primary);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    /* Show hamburger, hide regular buttons */
    .hamburger-btn {
        display: flex;
    }

    .header-right {
        display: none;
    }

    .mobile-menu {
        display: block;
    }

    .mobile-menu-overlay {
        display: block;
    }

    /* Keep header visible above modal overlay on mobile */
    .app-header {
        z-index: 1004 !important; /* Above modal overlay but below modal content */
    }
    
    /* Position modals below header on mobile */
    .modal {
        align-items: flex-start;
        padding-top: 70px; /* Account for header height */
        z-index: 1003; /* Higher than mobile menu (999) and overlay (998) */
    }
    
    /* Modal overlay should be below header */
    .modal {
        background: rgba(0, 0, 0, 0.85);
    }
    
    /* But modal content should be above header */
    .modal-content {
        position: relative;
        z-index: 1005; /* Above header */
        margin-top: 0;
        max-height: calc(100vh - 90px); /* Account for header and padding */
    }
    
    /* Ensure mobile menu overlay doesn't block modals */
    .mobile-menu-overlay {
        z-index: 997 !important; /* Lower than modals */
    }
    
    .mobile-menu-overlay:not(.active) {
        pointer-events: none !important;
        opacity: 0 !important;
    }
    
    .mobile-menu {
        z-index: 998; /* Lower than modals */
    }
    
    /* Ensure modals are always on top when visible */
    .modal:not(.hidden) {
        z-index: 1003 !important;
    }

    /* Stack current game info and buttons vertically on mobile */
    .current-game-info {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    /* Stack current game action buttons vertically on mobile */
    .current-game-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .current-game-actions .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .die {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }

    .die-dot {
        width: 14px;
        height: 14px;
    }

    .scorecard {
        font-size: 0.75rem;
    }

    .scorecard th,
    .scorecard td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }

    .auth-modal-content {
        width: 100%;
        margin: 1rem;
    }

    .lobby-header {
        flex-direction: column;
        gap: 1rem;
    }

    /* Make dice larger to fill width better */
    .die {
        width: 18%;
        max-width: 65px;
        min-width: 50px;
        aspect-ratio: 1;
        flex-shrink: 0;
    }

    .dice-container {
        gap: 0.25rem;
        padding: 0 0.25rem;
    }

    .dice-area {
        padding: 1rem 0.5rem;
    }

    /* Further reduce padding and gap on smaller screens */
    .die-face {
        padding: 3px;
        gap: 1.5px;
    }

    /* Adjust dot size for smaller dice */
    .die-dot {
        width: 10px;
        height: 10px;
    }

    .category-tooltip {
        max-width: 200px;
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.view {
    animation: fade-in 0.3s ease;
}

@keyframes pulse {

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

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

.your-turn #roll-btn {
    animation: pulse 1.5s infinite;
}

/* ============================================
   GAME LOG MODAL
   ============================================ */

.game-log-modal-content {
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
}

.game-log-content {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: auto;
    padding-left: 60px;
    position: relative;
}

.game-log-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-display);
    font-size: 0.9rem;
}

.game-log-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.game-log-table>thead th {
    padding: 1rem;
    text-align: left;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    white-space: nowrap;
}

.game-log-table>tbody>tr>td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.game-row {
    background: var(--bg-tertiary);
    transition: background-color var(--transition-fast);
}

.game-row:hover {
    background: rgba(0, 240, 255, 0.05);
}

.game-row.expanded {
    background: rgba(0, 240, 255, 0.1);
}

.game-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.action-cell {
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.toggle-scorecard-btn,
.view-history-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Scorecard container within main table */
.scorecard-container-row {
    background: var(--bg-primary);
}

.scorecard-container-cell {
    padding: 0 !important;
}

/* Nested scorecard table styles */
.scorecard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-display);
    font-size: 0.8rem;
    background: var(--bg-primary);
    font-stretch: condensed;
    letter-spacing: -0.02em;
}

.scorecard-table thead {
    background: var(--bg-secondary);
}

.player-name-header {
    font-size: 0.75rem;
    color: var(--accent-primary);
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.scorecard-row {
    background: var(--bg-tertiary);
}

.scorecard-row.ai-player-row {
    background: rgba(255, 136, 0, 0.05);
}

.scorecard-actions {
    width: 1%;
}

.player-name-cell {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    white-space: nowrap;
    border-right: 1px solid var(--border-color);
}

.category-header {
    font-size: 0.65rem;
    color: var(--accent-primary);
    padding: 0.5rem 0.2rem;
    text-align: center;
    white-space: nowrap;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    min-width: 40px;
}

.category-header.total-header {
    background: rgba(0, 240, 255, 0.08);
}

.category-header.final-total-header {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-primary);
}

.score-cell {
    text-align: center;
    padding: 0.5rem 0.2rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    border-bottom: 1px solid var(--border-color);
}

.score-cell.total-cell {
    background: rgba(0, 240, 255, 0.08);
    font-weight: 600;
}

.score-cell.final-total-cell {
    background: rgba(0, 240, 255, 0.15);
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.95rem;
}

.loading-cell,
.error-cell,
.empty-cell {
    text-align: center;
    padding: 2rem !important;
    color: var(--text-secondary);
    font-style: italic;
}

.error-cell {
    color: var(--accent-danger);
}

/* Series bracket overlay - positioned absolutely outside the table */
.series-bracket-overlay {
    position: absolute;
    left: 10px;
    width: 40px;
    pointer-events: none;
    z-index: 100;
}

/* Main vertical bracket line */
.bracket-line {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    box-shadow:
        0 0 10px var(--accent-primary),
        0 0 20px rgba(0, 240, 255, 0.5);
    border-radius: 2px;
}

/* Top horizontal cap of bracket */
.bracket-cap-top {
    position: absolute;
    left: 3px;
    top: 0;
    width: 18px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary) 0%, transparent 100%);
    box-shadow: 0 0 8px var(--accent-primary);
    border-radius: 0 2px 2px 0;
}

/* Bottom horizontal cap of bracket */
.bracket-cap-bottom {
    position: absolute;
    left: 3px;
    bottom: 0;
    width: 18px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-secondary) 0%, transparent 100%);
    box-shadow: 0 0 8px var(--accent-secondary);
    border-radius: 0 2px 2px 0;
}

/* Series label - rotated text */
.series-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
    white-space: nowrap;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-primary);
    text-transform: uppercase;
    text-align: center;
    text-shadow:
        0 0 10px var(--accent-primary),
        0 0 20px var(--accent-primary),
        0 0 30px rgba(0, 240, 255, 0.6);
    z-index: 5;
    pointer-events: none;
}

/* Adjust game row with bracket */
.game-row-with-bracket {
    background: var(--bg-tertiary);
    transition: background-color var(--transition-fast);
}

.game-row-with-bracket:hover {
    background: rgba(0, 240, 255, 0.05);
}

.game-row-with-bracket.expanded {
    background: rgba(0, 240, 255, 0.1);
}

/* ============================================
   GAME HISTORY MODAL
   ============================================ */

.game-history-modal-content {
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
}

.game-history-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem 0;
}

.game-history-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.history-move {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all var(--transition-fast);
}

.history-move:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

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

.move-number {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 1rem;
}

.move-player {
    font-weight: 500;
    color: var(--text-primary);
}

.move-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.move-body {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: center;
}

.move-body-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.move-body-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
}

.roll-history-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.1rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.roll-number {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 50px;
}

.move-body .roll-history-dice {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.move-dice {
    flex: 0 0 auto;
}

.move-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.move-category {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-display);
}

.move-score {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.95rem;
}

.score-label {
    color: var(--text-secondary);
}

.score-value {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 1.1rem;
}

.no-dice {
    color: var(--text-secondary);
    font-style: italic;
}

/* Score Graph */
.score-graph-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
    height: 300px;
    transition: all var(--transition-fast);
}

.score-graph-container:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.score-graph {
    width: 100%;
    height: 100%;
    display: block;
}

.score-graph-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.graph-turn-label {
    transition: all var(--transition-fast);
}

.graph-turn-label:hover {
    fill: var(--accent-secondary) !important;
    font-size: 20px !important;
    text-shadow: 0 0 8px rgba(255, 0, 170, 0.6);
}

.player-line {
    transition: opacity var(--transition-fast);
}

.player-line:hover {
    opacity: 1;
    stroke-width: 3;
}

.player-point {
    transition: r var(--transition-fast);
}

.player-point:hover {
    r: 5;
}

/* Score Graph Tooltip */
.score-graph-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    pointer-events: none;
    z-index: 10000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 8px rgba(0, 240, 255, 0.3);
    white-space: nowrap;
}

/* Mobile responsiveness for game log and history modals */
@media (max-width: 768px) {

    .game-log-modal-content,
    .game-history-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .game-log-content,
    .game-history-content {
        max-height: 75vh;
    }

    .move-body {
        flex-direction: column;
        gap: 1rem;
    }

    .move-body-right {
        min-width: auto;
        width: 100%;
    }

    .game-log-table {
        font-size: 0.8rem;
    }

    .game-log-table th,
    .game-log-table td {
        padding: 0.5rem;
    }

    .action-cell {
        flex-direction: column;
        align-items: flex-start;
    }

    .category-header {
        font-size: 0.65rem;
        padding: 0.4rem !important;
    }

    .score-cell {
        font-size: 0.85rem;
        padding: 0.4rem !important;
    }

    .player-name-cell {
        font-size: 0.85rem;
        padding: 0.5rem !important;
    }

    .move-body {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-die {
        width: 40px;
        height: 40px;
    }

    .history-die .die-dot {
        width: 6px;
        height: 6px;
    }
}

/* ============================================
   SERIES TRANSITION OVERLAY
   ============================================ */

.series-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.series-transition-content {
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    animation: slideIn 0.5s ease;
}

.series-transition-content h2 {
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.series-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.series-standings {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.series-standings h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.series-standings ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.series-standings li {
    font-size: 1.1rem;
    color: var(--text-primary);
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 4px;
}

.series-countdown {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.series-countdown span {
    color: var(--accent-primary);
    font-weight: bold;
    font-size: 1.5rem;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

/* ============================================
   STATISTICS MODAL
   ============================================ */

.statistics-modal-content {
    width: 90%;
    max-width: 1400px;
    max-height: 90vh;
}

.statistics-controls {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.statistics-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem 0;
}

.statistics-section {
    margin-bottom: 2.5rem;
}

.statistics-section:last-child {
    margin-bottom: 0;
}

.statistics-section-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.chart-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    height: 400px;
    position: relative;
    width: 100%;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-container-small {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    height: 300px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-container-small canvas {
    flex: 1;
    max-height: calc(100% - 2rem);
    max-width: 100%;
}

.chart-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pie-charts-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: flex-start;
}

.pie-chart-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    height: 100%;
}

.pie-chart-label {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pie-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}

.pie-chart-labels {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.pie-label-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.pie-label-category {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 40px;
}

.pie-label-value {
    font-weight: 600;
    min-width: 50px;
}

/* Die labels for charts */
.chart-die-label {
    display: inline-block;
}

.chart-die-face {
    background: var(--dice-bg) !important;
    border: 1px solid var(--dice-border) !important;
}

.chart-die-dot {
    width: 6px;
    height: 6px;
    background: var(--dice-dot);
    border-radius: 50%;
    box-shadow: 0 0 3px var(--dice-dot);
}

.chart-die-x-label {
    pointer-events: none;
}

/* Mobile responsiveness for statistics modal */
@media (max-width: 768px) {
    .statistics-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .statistics-content {
        max-height: 75vh;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-container {
        height: 300px;
        padding: 1rem;
    }

    .chart-container-small {
        height: 250px;
        padding: 0.75rem;
    }

    .pie-charts-container {
        flex-direction: column;
        gap: 1rem;
    }

    .pie-chart-wrapper {
        max-width: 100%;
    }
}