/* Ensure fullscreen element background is correct */
.scoreghetti-public-container:fullscreen {
    background: var(--sg-bg) !important;
}
.scoreghetti-public-container:-webkit-full-screen {
    background: var(--sg-bg) !important;
}
.scoreghetti-public-container:-moz-full-screen {
    background: var(--sg-bg) !important;
}
.scoreghetti-public-container:-ms-fullscreen {
    background: var(--sg-bg) !important;
}
/* Ensure fullscreen background for game container as well */
.scoreghetti-game-container:fullscreen {
    background: var(--sg-bg) !important;
}
.scoreghetti-game-container:-webkit-full-screen {
    background: var(--sg-bg) !important;
}
.scoreghetti-game-container:-moz-full-screen {
    background: var(--sg-bg) !important;
}
.scoreghetti-game-container:-ms-fullscreen {
    background: var(--sg-bg) !important;
}
html.scoreghetti-fullscreen, body.scoreghetti-fullscreen {
    background-color: var(--sg-bg) !important;
}
/* Ensure grl.svg overlay on login page uses the correct color */
.scoreghetti-login-outer .scoreghetti-grl-overlay {
    color: var(--sg-grl-fill) !important;
}
/* Scoreghetti logo color (SVG uses fill="currentColor") */
.scoreghetti-logo-center svg,
.scoreghetti-logo svg,
.scoreghetti-login-outer svg {
    color: var(--sg-btn-bg) !important;
}

/* grl.svg bottom right overlay */
.scoreghetti-grl-overlay {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 68px !important;
    height: 68px !important;
    opacity: 1;
    z-index: 9999;
    color: var(--sg-grl-fill) !important;
    display: block !important;
}

/* Slightly lighter than background for grl.svg */
body {
    --sg-grl-bg: var(--sg-btn-bg);
}
/* Scoreghetti color variables for easy linking */
:root {
    --sg-bg: #AA2222;
    --sg-font: #FFFFF0;
    /* Dynamically calculate lightness for box backgrounds based on page bg */
    --sg-bg: #1a1a1a;
    --sg-bg-h: 0;
    --sg-bg-s: 0%;
    --sg-bg-l: 10%;
    /* If you change --sg-bg, update these HSL values to match its hue/sat/lightness */
    --sg-box-bg-light: hsl(var(--sg-bg-h), var(--sg-bg-s), calc(var(--sg-bg-l) + 5%));
    --sg-grl-fill: var(--sg-box-bg-light);
    --sg-btn-bg: #f0c040;
    --sg-btn-font: #1a1a1a;
    --sg-score-font: var(--sg-btn-bg);
}

/* Hide share button in fullscreen mode */
.scoreghetti-fullscreen #share-btn {
    display: none !important;
}
/* Import Caudex Bold from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Caudex:wght@700&display=swap');

 .scoreghetti-login-outer,
 .scoreghetti-game-container,
 .scoreghetti-public-container,
 .scoreghetti-header,
 .scoreghetti-actions,
 .scoreghetti-player-name-large,
 input,
 table,
 th,
 td {
     font-family: 'Caudex', serif !important;
     font-weight: 700 !important;
}


body,
body.scoreghetti-fullscreen,
.scoreghetti-public-container,
.scoreghetti-game-container {
    background-color: var(--sg-bg) !important;
    color: #F5ECD4;
}

h1, h2, h3 {
    color: #f0c040;
}

a {
    color: #f0c040;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--sg-box-bg-light) !important;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

button {
    background-color: #f0c040;
    color: #1a1a1a;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--sg-btn-bg-hover);
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #444;
    border-radius: 5px;
    background-color: var(--sg-box-bg-light);
    color: #F5ECD4;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: #f0c040;
    outline: none;
}

.scoreboard {
    margin-top: 20px;
    background-color: var(--sg-box-bg-light);
    padding: 15px;
    border-radius: 8px;
}

.score {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #444;
}

.score:last-child {
    border-bottom: none;
}

.scoreghetti-scores-large {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 60px;
    margin: 40px 0 20px 0;
}

.scoreghetti-score-block-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
}

.scoreghetti-score-large {
    font-size: 30rem;
    height: 400px;
    font-weight: bold;
    background: var(--sg-box-bg-light);
    color: var(--sg-score-font);
    border-radius: 60px;
    width: 540px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 54px;
    box-shadow: 0 0 20px #000a;
    cursor: pointer;
    user-select: none;
    overflow: hidden; /* Prevents click area from extending outside the box */
    line-height: 1;    /* Ensures no extra vertical clickable area */
    padding: 0;        /* Remove any default padding */
}

.scoreghetti-player-name-large {
    font-size: 4.5rem;
    text-align: center;
    width: 540px;
    background: var(--sg-box-bg-light) !important;
    color: var(--sg-font) !important;
    border: none;
    border-radius: 60px; /* Increased from 30px to 60px */
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
}

.scoreghetti-decrement-large {
    font-size: 4rem;
    width: 120px;
    height: 90px;
    margin-bottom: 24px;
    margin-top: -30px;
    background: #f0c040;
    color: #1a1a1a;
    border-radius: 20px;
    border: none;
    box-shadow: 0 0 10px #0006;
    font-weight: bold;
    transition: background 0.2s;
}

.scoreghetti-decrement-large:hover {
    background: #d0a030;
}

.scoreghetti-game-container,
.scoreghetti-public-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

body.scoreghetti-fullscreen {
    background-color: var(--sg-bg) !important;
}
body.scoreghetti-fullscreen .scoreghetti-game-container,
body.scoreghetti-fullscreen .scoreghetti-public-container {
    min-height: 100vh;
    height: 100vh;
    overflow-y: auto;
    padding-bottom: 60px;
    justify-content: flex-start;
    background: transparent !important;
}

body.scoreghetti-fullscreen .scoreghetti-actions {
    margin-bottom: 40px;
}

/* Header layout for access code and logout */
.scoreghetti-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
}
.scoreghetti-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.scoreghetti-header-center {
    flex: 1;
    text-align: center;
    font-size: 2.2rem;
}
.scoreghetti-logout-btn {
    margin-left: 12px;
    background: #f0c040;
    color: #1a1a1a;
    border: none;
    border-radius: 5px;
    padding: 8px 18px;
    font-size: 1.6rem;
    font-family: 'Caudex', serif;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    height: 48px;
    line-height: 1.2;
    box-sizing: border-box;
}
.scoreghetti-logout-btn:hover {
    background: #d0a030;
}

/* Center the action buttons below player names */
.scoreghetti-actions {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 10px;
    margin-bottom: 10px;
}

/* Public page: access code input and view button inline */
.scoreghetti-public-access {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* Center access code and game# text */
.scoreghetti-header-center, .scoreghetti-public-header-center {
    text-align: center;
    width: 100%;
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.scoreghetti-game-number {
    font-size: clamp(1rem, 4vw, 2rem);
    font-weight: 700;
    text-align: center;
    margin: 0 auto 7px auto;
    display: block;
    letter-spacing: 2px;
    color: var(--sg-font) !important;
}

/* Logo size and SVG color rendering */
.scoreghetti-logo {
/* Ensure SVG logo is visible and sized */
.scoreghetti-logo svg {
    width: 68px;
    height: auto;
    display: block;
}
    max-width: 34px;
    height: auto;
    display: block;
    margin: 0 auto 18px auto;
}
.scoreghetti-logo [fill="#f0c040"] {
    fill: var(--sg-btn-bg) !important;
}

/* Remove gold filter/fill for .scoreghetti-logo-gold to allow SVG to render natively */
.scoreghetti-logo-gold {
    filter: none !important;
    fill: none !important;
}

/* Responsive tweaks */
@media (max-width: 600px) {
    .scoreghetti-scores-large {
        flex-direction: column;
        gap: 40px;
    }
    .scoreghetti-score-large, .scoreghetti-player-name-large {
        width: 100%;
        max-width: 98vw;
        font-size: 3.5rem;
        height: auto;
    }
    body.scoreghetti-fullscreen .scoreghetti-game-container,
    body.scoreghetti-fullscreen .scoreghetti-public-container {
        padding-bottom: 80px;
    }
    .scoreghetti-header-row { flex-direction: column; align-items: flex-start; }
    .scoreghetti-header-center { text-align: left; margin-top: 8px; }
    .scoreghetti-actions { flex-direction: column; align-items: center; }
    .scoreghetti-header-flex, .scoreghetti-public-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .scoreghetti-game-number {
        margin-left: 0;
    }
}

/* New styles for header flex alignment */
.scoreghetti-header-flex, .scoreghetti-public-header-flex {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    margin-bottom: 18px;
    width: 100%;
}
.scoreghetti-header-left-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}
.scoreghetti-header-center-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 300px !important;
    flex-wrap: nowrap;
    width: 100%;
    /* Remove padding if present */
}
.scoreghetti-header-center-group .scoreghetti-game-number {
    font-size: clamp(1rem, 4vw, 2rem) !important;
    white-space: nowrap;
}
@media (max-width: 900px) {
    .scoreghetti-header-center-group {
        gap: 4vw;
    }
    .scoreghetti-header-center-group .scoreghetti-game-number {
        font-size: clamp(1rem, 4vw, 2rem) !important;
    }
}
@media (max-width: 600px) {
    .scoreghetti-header-center-group {
        gap: 2vw;
    }
    .scoreghetti-header-center-group .scoreghetti-game-number {
        font-size: clamp(1rem, 4vw, 2rem) !important;
    }
}
@media (max-width: 700px) {
    .scoreghetti-header-center-group {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 0 8px;
    }
    .scoreghetti-header-center-group .scoreghetti-game-number {
        text-align: left;
    }
}

/* Topbar flex styles */
.scoreghetti-topbar-flex {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 12px;
}
.scoreghetti-topbar-flex .scoreghetti-logo {
    margin-bottom: 0;
}
@media (max-width: 600px) {
    .scoreghetti-topbar-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

h1.scoreghetti-title { display: none !important; }

/* New styles for access bar and logo centering */
.scoreghetti-accessbar-flex {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    justify-content: flex-start !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100%;
    max-width: none;
    position: static;
    left: auto;
    transform: none;
    text-align: left;
    box-sizing: border-box;
}
.scoreghetti-logo-center {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
}
@media (max-width: 600px) {
    .scoreghetti-accessbar-flex {
        width: 100vw;
        max-width: 100vw;
        left: 50%;
        transform: translateX(-50%);
    }
}

.scoreghetti-header-center-group .scoreghetti-header-access {
    font-size: 1.6rem;
    color: #f0c040;
    padding-left: 32px;
}
.scoreghetti-btn,
.scoreghetti-actions .scoreghetti-logout-btn {
    font-size: 1.6rem !important;
    padding: 12px 28px !important;
    border-radius: 18px !important;
    font-family: 'Caudex', serif !important;
    font-weight: 700 !important;
    height: 48px !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
    background-color: var(--sg-btn-bg) !important;
    color: var(--sg-btn-font) !important;
    border: none !important;
    display: inline-block !important;
    transition: background 0.3s !important;
}
.scoreghetti-btn:hover,
.scoreghetti-actions .scoreghetti-logout-btn:hover {
    background-color: var(--sg-btn-bg-hover) !important;
}

.scoreghetti-header {
    margin-top: 8px !important;
    margin-bottom: 8px !important;
}

#public-access-code {
    cursor: text !important;
    position: relative;
    z-index: 2;
}
#public-access-btn {
    z-index: 1;
}
.scoreghetti-header-left-group {
    position: relative;
    z-index: auto;
}
/* Fix button overlay issue: ensure button is not overlapping input */
#public-access-btn {
    margin-left: 0 !important;
}
#public-access-code {
    width: 340px !important;
    max-width: 90vw !important;
}
/* Remove any accidental negative margin or absolute positioning on the button */
#public-access-btn {
    position: static !important;
}
@media (max-width: 900px) and (orientation: landscape) {
    .scoreghetti-public-header-flex,
    .scoreghetti-header-flex {
        flex-direction: row !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 0 8px !important;
    }
    .scoreghetti-header-left-group {
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        margin-right: 0 !important;
        min-width: 0;
    }
    .scoreghetti-header-center-group {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 16px !important;
        margin: 0 !important;
        min-width: 0;
    }
    #public-access-code {
        width: 160px !important;
        font-size: 1.1rem !important;
        min-width: 0;
    }
    #public-access-btn {
        font-size: 1.1rem !important;
        padding: 8px 14px !important;
        height: 38px !important;
    }
    .scoreghetti-game-number {
        font-size: 1.1rem !important;
    }
    #live-indicator {
        font-size: 1.1rem !important;
        margin-left: 8px !important;
    }
    .scoreghetti-scores-large {
        flex-direction: row !important;
        gap: 16px !important;
        margin: 12px 0 8px 0 !important;
    }
    .scoreghetti-score-block-large {
        width: 48vw !important;
        min-width: 120px;
        max-width: 180px;
        position: relative !important;
        /* Add padding to prevent overlap */
        padding-top: 60px !important;
    }
    .scoreghetti-score-large {
        font-size: 6vw !important;
        width: 100% !important;
        min-width: 0;
        height: 80px !important;
        margin-bottom: 12px !important;
        border-radius: 18px !important;
    }
    .scoreghetti-decrement-large {
        position: absolute !important;
        top: 8px !important;
        left: 8px !important;
        right: auto !important;
        z-index: 3 !important;
        width: 48px !important;
        height: 48px !important;
        font-size: 2rem !important;
        margin: 0 !important;
    }
    .scoreghetti-score-block-large .scoreghetti-decrement-p2 {
        left: auto !important;
        right: 8px !important;
    }
    .scoreghetti-player-name-large {
        font-size: 1.1rem !important;
        width: 100% !important;
        min-width: 0;
        border-radius: 60px !important; /* Fully rounded on all screens */
    }
    .scoreghetti-actions {
        flex-direction: row !important;
        gap: 8px !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }
    .scoreghetti-btn {
        font-size: 1.1rem !important;
        padding: 8px 14px !important;
        height: 38px !important;
        border-radius: 10px !important;
    }
/* Remove duplicate and media-query logo size overrides */
    .scoreghetti-public-container, .scoreghetti-game-container {
        padding: 4px !important;
    }
    #public-history-popup, #history-popup {
        width: 98vw !important;
        left: 1vw !important;
        right: 1vw !important;
        max-width: 98vw !important;
        font-size: 1rem !important;
    }
    #public-history-content table, #history-content table {
        font-size: 0.9rem !important;
    }
}

/* --- Starter Player Highlight Styles --- */
.scoreghetti-player-name-large.starter {
    /* Remove background override, only border should highlight */
    box-shadow: 0 0 10px #fff70055;
    border: 3px solid #fff700 !important;
    z-index: 2;
}
.scoreghetti-player-name-large.not-starter {
    /* Remove background override, only border should highlight */
    border: 1px solid #333 !important;
    box-shadow: none !important;
    z-index: 1;
}
/* Hide old starter indicator and selection UI styles if present */
.scoreghetti-starter-indicator, .scoreghetti-starter-select-ui { display: none !important; }

/* --- Active Access Codes Popup Styles --- */
#scoreghetti-active-codes-popup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scoreghetti-active-codes-modal {
    background: var(--sg-box-bg-light);
    color: #fff;
    border-radius: 18px;
    padding: 32px 24px 24px 24px;
    min-width: 320px;
    max-width: 96vw;
    box-shadow: 0 0 32px #000a;
    text-align: center;
    position: relative;
}
#scoreghetti-active-codes-list {
    margin: 18px 0 18px 0;
    max-height: 50vh;
    overflow-y: auto;
}
.scoreghetti-active-codes-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
}
.scoreghetti-active-codes-table th, .scoreghetti-active-codes-table td {
    border: 1px solid #444;
    padding: 8px 16px;
    font-size: 1.2rem;
}
.scoreghetti-active-codes-table th {
    background: var(--sg-box-bg-light);
    color: #f0c040;
}
.scoreghetti-active-codes-table td {
    background: var(--sg-box-bg-light);
}
#scoreghetti-close-active-codes {
    margin-top: 12px;
    min-width: 120px;
}
@media (max-width: 600px) {
    .scoreghetti-active-codes-modal {
        padding: 12px 4vw 12px 4vw;
        min-width: 0;
    }
    .scoreghetti-active-codes-table th, .scoreghetti-active-codes-table td {
        font-size: 1rem;
        padding: 6px 4px;
    }
}

/* --- End Active Access Codes Popup Styles --- */

/* --- Public View History Modal Styles --- */
#public-history-popup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
#public-history-popup.hidden {
    display: none !important;
}
.public-history-modal {
    background: #232323;
    color: #fff;
    border-radius: 18px;
    padding: 32px 24px 24px 24px;
    min-width: 320px;
    max-width: 96vw;
    max-height: 90vh;
    box-shadow: 0 0 32px #000a;
    text-align: center;
    position: relative;
    overflow-y: auto;
}
#public-history-content {
    margin: 18px 0 18px 0;
    max-height: 50vh;
    overflow-y: auto;
    text-align: left;
}
.public-history-modal table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
}
.public-history-modal th, .public-history-modal td {
    border: 1px solid #444;
    padding: 8px 16px;
    font-size: 1.1rem;
}
.public-history-modal th {
    background: var(--sg-box-bg-light);
    color: #f0c040;
}
.public-history-modal td {
    background: #232323;
}
#public-history-export, #public-history-close {
    margin: 8px 8px 0 8px;
    min-width: 120px;
    font-size: 1.1rem;
    padding: 10px 18px;
    border-radius: 10px;
    background: #f0c040;
    color: #1a1a1a;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'Caudex', serif;
    font-weight: 700;
}
#public-history-export:hover, #public-history-close:hover {
    background: #d0a030;
}
@media (max-width: 600px) {
    .public-history-modal {
        padding: 12px 4vw 12px 4vw;
        min-width: 0;
        max-width: 98vw;
        font-size: 1rem;
    }
    .public-history-modal th, .public-history-modal td {
        font-size: 0.95rem;
        padding: 6px 4px;
    }
    #public-history-content {
        max-height: 40vh;
    }
}
/* --- End Public View History Modal Styles --- */

/* Remove legacy .scoreghetti-login-actions-col styles */
.scoreghetti-login-actions-col {
    display: none !important;
}

.scoreghetti-login-outer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    width: 100vw;
    background: var(--sg-bg) !important;
}

.scoreghetti-login-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--sg-box-bg-light) !important;
    border-radius: 16px;
    box-shadow: 0 0 16px #0007;
    padding: 32px 24px 24px 24px;
    margin: 0 auto;
    max-width: 420px;
    width: 100%;
}

#scoreghetti-login-form-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 18px;
}

#scoreghetti-login-form-inner input[type="text"],
#scoreghetti-login-form-inner input[type="password"] {
    width: 100%;
    max-width: 320px;
    font-size: 1.1em;
    height: 2.5em;
    margin: 0;
    background-color: var(--sg-btn-bg);
    color: var(--sg-btn-font);
    border: 1px solid #444;
    border-radius: 5px;
}
#scoreghetti-login-form-inner .login-action-btn {
    text-align: center !important;
    margin: 0 auto;
    display: block;
    height: 48px;
}

#scoreghetti-login-form-inner .login-action-btn {
    text-align: center !important;
    margin: 0 auto;
    display: block;
    height: 48px;
}

#scoreghetti-login-msg {
    margin-top: 12px;
    min-height: 24px;
    text-align: center;
    color: #f0c040;
    font-size: 1.1em;
}

@media (max-width: 600px) {
    .scoreghetti-login-form {
        padding: 16px 2vw 16px 2vw;
        max-width: 98vw;
    }
    #scoreghetti-login-form-inner input[type="text"],
    #scoreghetti-login-form-inner input[type="password"],
    #scoreghetti-login-form-inner .login-action-btn {
        max-width: 98vw;
        font-size: 1em;
    }
}

/* Custom styles for the switch button */
.scoreghetti-switch-btn {
    min-width: 180px;
    padding: 12px 24px !important;
    font-size: 1.2rem !important;
    border-radius: 18px !important;
    margin-right: 12px;
    margin-left: 0;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
}
@media (max-width: 600px) {
    .scoreghetti-switch-btn {
        min-width: 120px;
        font-size: 1rem !important;
        padding: 10px 8px !important;
    }
}
.scoreghetti-logout-btn-spaced {
    margin-left: 32px !important;
    margin-right: 0 !important;
}