/* === Base Reset & Variables === */
:root {
    --gold: #e5be55;
    --bg: #0b0b0a;
    --text: #fffffe;
    --accent: #d5043d;
    --gold-dim: rgba(229, 190, 85, 0.15);
    --gold-glow: rgba(229, 190, 85, 0.4);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* === Flash Messages === */
.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
}

.flash {
    background: var(--gold);
    color: var(--bg);
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-weight: 600;
    animation: flashIn 0.3s ease;
}

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Buttons === */
.btn {
    display: inline-block;
    background: var(--gold);
    color: var(--bg);
    border: none;
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn:hover {
    background: #f0cc6a;
    box-shadow: 0 0 12px var(--gold-glow);
    transform: translateY(-1px);
}

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

.btn-subtle {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
}

.btn-subtle:hover {
    background: var(--gold-dim);
}

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

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

.btn-danger:hover {
    background: #e81c50;
    box-shadow: 0 0 12px rgba(213, 4, 61, 0.4);
}

/* === Inputs === */
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(229, 190, 85, 0.3);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

textarea {
    width: 100%;
    resize: vertical;
    font-family: inherit;
}

/* === Home === */
.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.home-title {
    font-size: 3rem;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow);
    margin-bottom: 0.5rem;
}

.home-game-name {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.8;
}

.qr-section {
    margin-bottom: 2rem;
}

.qr-section p {
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.qr-image {
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 0.5rem;
    background: var(--bg);
}

.buzz-url {
    font-size: 0.85rem;
    opacity: 0.5;
    margin-top: 0.5rem;
}

.home-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* === Center container (login, no game) === */
.center-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.center-container h1 {
    color: var(--gold);
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

/* === Buzz Screen === */
.buzz-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.buzz-title {
    color: var(--gold);
    font-size: 1.8rem;
    margin-bottom: 2rem;
}

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

.team-select p {
    font-size: 1.2rem;
    opacity: 0.8;
}

.team-btn {
    width: 220px;
    font-size: 1.1rem;
    padding: 0.8rem;
}

.buzzer-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.team-label {
    font-size: 1.3rem;
    opacity: 0.7;
}

.buzz-button {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text);
    font-size: 2.5rem;
    font-weight: 800;
    border: 4px solid var(--text);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.buzz-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(213, 4, 61, 0.6);
}

.buzz-button:active {
    transform: scale(0.95);
}

.buzz-button.locked {
    background: #333;
    border-color: #555;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
}

.buzz-button.winner {
    background: var(--gold);
    color: var(--bg);
    border-color: var(--gold);
    box-shadow: 0 0 40px var(--gold-glow);
    animation: pulse 0.6s ease 2;
}

.buzz-button.waiting {
    background: #222;
    border-color: #444;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
    opacity: 0.6;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.buzz-status {
    font-size: 1.2rem;
    min-height: 1.5em;
    color: var(--gold);
    font-weight: 600;
}

/* === Timer === */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
    transition: background 0.3s;
}

.timer-container.flash-red {
    /* kept for compat but no longer used */
}

.timer-setup h1 {
    color: var(--gold);
    margin-bottom: 1rem;
}

.timer-input {
    font-size: 3rem;
    width: 150px;
    text-align: center;
    margin-bottom: 0.5rem;
}

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

.timer-circle {
    position: relative;
    width: 300px;
    height: 300px;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-track {
    fill: none;
    stroke: rgba(229, 190, 85, 0.15);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--gold);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke 0.3s;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow);
}

/* === Admin === */
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

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

.admin-header h1 {
    color: var(--gold);
}

.admin-nav {
    display: flex;
    gap: 0.5rem;
}

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

.admin-section h2 {
    color: var(--gold);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--gold-dim);
    padding-bottom: 0.5rem;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(229, 190, 85, 0.1);
}

.admin-table th {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.active-row {
    background: var(--gold-dim);
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
}

.badge.active {
    background: var(--gold);
    color: var(--bg);
}

.actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* === Edit page === */
.edit-category {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.edit-questions {
    margin-top: 0.75rem;
}

.question-edit {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
}

.question-edit summary {
    cursor: pointer;
    padding: 0.3rem;
    color: var(--gold);
    font-weight: 500;
}

.question-edit form {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-edit label {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* === Host View === */
.host-container {
    padding: 1rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

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

.host-header h1 {
    color: var(--gold);
    font-size: 1.5rem;
}

/* Scoreboard */
.scoreboard {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.score-card {
    background: var(--gold-dim);
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    text-align: center;
    min-width: 140px;
}

.score-name {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.score-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    transition: transform 0.3s, color 0.3s;
}

.score-value.score-flash {
    transform: scale(1.3);
    color: var(--text);
}

/* Buzzer indicator */
.buzzer-indicator {
    text-align: center;
    padding: 0.6rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(229, 190, 85, 0.1);
    transition: background 0.3s, border-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.buzzer-indicator.buzzed {
    background: rgba(213, 4, 61, 0.2);
    border-color: var(--accent);
}

#buzzerText {
    font-weight: 600;
}

/* Jeopardy Grid */
.jeopardy-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.grid-header {
    background: var(--gold);
    color: var(--bg);
    text-align: center;
    padding: 0.75rem 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 4px 4px 0 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.grid-cell {
    background: rgba(229, 190, 85, 0.08);
    border: 1px solid rgba(229, 190, 85, 0.2);
    text-align: center;
    padding: 1.5rem 0.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s, opacity 0.4s;
    border-radius: 2px;
}

.grid-cell:hover {
    background: var(--gold-dim);
    transform: scale(1.03);
    box-shadow: 0 0 12px var(--gold-glow);
    z-index: 1;
}

.grid-cell.answered {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
}

.cell-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-glow);
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.25s ease;
    padding: 1rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #1a1a19;
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 2rem;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-question {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-answer {
    font-size: 1.2rem;
    background: var(--gold-dim);
    border-left: 3px solid var(--gold);
    padding: 1rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.4s ease;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scoring-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

/* scoring-team and manual-score now defined in the section below */

/* Markdown content */
.md-content img.md-img {
    max-width: 100%;
    border-radius: 6px;
    margin: 0.5rem 0;
}

.md-content h1, .md-content h2, .md-content h3 {
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.md-content ul {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.md-content li {
    margin-bottom: 0.25rem;
}

/* === Answer Choices (host + display) === */
.answer-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4em;
    margin-top: 0.7em;
    width: 100%;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 0.4em;
    background: rgba(229, 190, 85, 0.07);
    border: 1px solid rgba(229, 190, 85, 0.22);
    border-radius: 6px;
    padding: 0.35em 0.6em;
    font-size: 0.92em;
}

.choice-letter {
    color: var(--gold);
    font-weight: 700;
    min-width: 1.3em;
    flex-shrink: 0;
}

.question-image {
    max-width: 100%;
    max-height: 280px;
    border: 2px solid var(--gold);
    border-radius: 8px;
    margin: 0.5rem auto;
    display: block;
}

/* === Buzz name input (jackbox) === */
.buzz-name-input {
    font-size: 1.3rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    width: 100%;
    max-width: 280px;
    text-align: center;
    margin-bottom: 0.75rem;
}

/* === Scoring improvements === */
.scoring-team {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
}

.scoring-team span {
    min-width: 110px;
    font-weight: 500;
}

.manual-score {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.manual-score select,
.manual-score input {
    flex: 1;
}

/* === Host timer & QR === */
.host-timer-panel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(229, 190, 85, 0.1);
    font-size: 0.9rem;
}

/* === Host modal two-column layout === */
.modal-overlay {
    /* Needed to contain the wider two-column layout */
    padding: 1rem;
}

.modal-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    max-width: 950px;
    width: 100%;
}

.buzz-side-panel {
    background: #1a1a19;
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 1.25rem;
    width: 210px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.buzz-side-panel h3 {
    color: var(--gold);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.buzz-order-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 60px;
}

.buzz-order-item {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    background: rgba(229,190,85,0.08);
    border: 1px solid rgba(229,190,85,0.2);
}

.buzz-order-item .pos {
    color: var(--gold);
    font-weight: 700;
    margin-right: 0.4em;
}

.buzz-order-empty {
    font-size: 0.8rem;
    opacity: 0.4;
    font-style: italic;
}

/* === Responsive === */
@media (max-width: 768px) {
    .jeopardy-grid {
        gap: 2px;
    }

    .grid-header {
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }

    .cell-value {
        font-size: 1.1rem;
    }

    .grid-cell {
        padding: 1rem 0.25rem;
    }

    .home-title {
        font-size: 2rem;
    }

    .buzz-button {
        width: 160px;
        height: 160px;
        font-size: 2rem;
    }

    .timer-circle {
        width: 220px;
        height: 220px;
    }

    .timer-text {
        font-size: 3.5rem;
    }
}
