@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=EB+Garamond:wght@400;600&family=IM+Fell+English:ital,wght@0,400;0,700;1,400&display=swap');
@import url('https://fonts.cdnfonts.com/css/bagnard');

:root {
    --navy: #204e80;
    --gold: #bfa76f;
    --cream: #f7f3e8;
    --space-12: 12px;
    --space-16: 16px;
    --space-24: 24px;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(32, 78, 128, 0.08);
}

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

html, body {
    min-height: 100%;
}

body {
    font-family: 'Cinzel', 'EB Garamond', serif;
    background: url('background.jpg') no-repeat center center fixed;
    background-size: cover;
    margin: 0;
    min-height: 100vh;
    cursor: url('gladius-cursor.png'), auto;
    color: var(--navy);
}

.main-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100vh;
    width: 100%;
    max-width: 1280px;
    position: relative;
    background: rgba(255, 255, 255, 0.80);
    backdrop-filter: blur(8px);
    border-radius: 0;
    box-shadow: none;
    margin: 0 auto;
    padding: 16px 24px 24px;
}

/* HEADER */
.site-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    width: 100%;
    flex-shrink: 0;
}

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

.eyebrow {
    margin: 0 0 4px 0;
    font-family: 'Cinzel', serif;
    font-size: 0.62em;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
}

.main-title {
    font-family: 'Bagnard', 'IM Fell English', serif;
    font-size: 2.15em;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: 2px;
    line-height: 1.15;
    margin: 0;
    padding: 0 0 8px 0;
    border-bottom: 1px solid var(--gold);
    background: none;
    box-shadow: none;
    text-shadow: none;
    width: auto;
}

.toolbar {
    flex-shrink: 0;
    padding-bottom: 4px;
}

/* UNIFIED CARDS */
.panel {
    background: var(--cream);
    border: 1.5px solid var(--navy);
    border-top: 3px solid var(--gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 16px 28px 16px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel.quiet {
    opacity: 0.96;
}

.section-heading,
.stage-header,
.judges-header {
    font-family: 'Cinzel', serif;
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--navy);
    letter-spacing: 0.04em;
}

/* DRAG HANDLES — high-contrast grab corner */
.drag-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    color: var(--gold);
    border: 2px solid var(--gold);
    border-radius: 0 var(--radius) 0 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
    cursor: grab;
    user-select: none;
    opacity: 1;
    z-index: 12;
    touch-action: none;
    box-shadow: 0 1px 4px rgba(32, 78, 128, 0.35);
}

.draggable:hover .drag-handle {
    background: var(--gold);
    color: var(--navy);
}

.draggable:active .drag-handle,
.drag-handle:active {
    cursor: grabbing;
    background: var(--gold);
    color: var(--navy);
}

.will-bump {
    outline: 2px dashed var(--gold);
    outline-offset: -2px;
}

.shrink-toggle {
    position: absolute !important;
    top: auto !important;
    left: auto !important;
    right: 6px !important;
    bottom: 6px !important;
    inset: auto 6px 6px auto;
    width: 22px;
    height: 22px;
    min-width: 22px;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: auto;
    flex: none;
    background: #fff;
    color: var(--navy);
    border: 1.5px solid var(--navy);
    border-radius: 4px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    z-index: 13;
    cursor: pointer;
}

.shrink-toggle:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.shrunk-label {
    display: none;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel.shrunk {
    align-self: start;
    min-height: 44px;
    padding: 8px 36px 8px 12px;
    justify-content: center;
}

.panel.shrunk > *:not(.drag-handle):not(.shrink-toggle):not(.shrunk-label) {
    display: none !important;
}

.panel.shrunk .shrunk-label {
    display: block !important;
}

.draggable {
    position: relative;
    cursor: grab;
}

.draggable:active {
    cursor: grabbing;
}

.draggable.dragging {
    position: fixed;
    z-index: 1200;
    opacity: 0.92;
    pointer-events: none;
    margin: 0;
    box-shadow: 0 12px 28px rgba(32, 78, 128, 0.28);
}

/* BUTTONS */
button {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.92em;
    letter-spacing: 0.02em;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary,
.reset button,
.stage-controls button,
.winner-btn {
    background: var(--navy);
    color: #fff;
    border: 1.5px solid var(--navy);
}

.reset button {
    padding: 14px 28px;
    font-size: 1.1em;
}

.btn-primary:hover,
.reset button:hover,
.stage-controls button:hover,
.winner-btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.btn-ghost,
.vote-btn,
.decision-btn {
    background: transparent;
    color: var(--navy);
    border: 1.5px solid var(--navy);
}

.btn-ghost:hover,
.vote-btn:hover,
.decision-btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.decision-btn.selected {
    background: var(--gold);
    color: var(--navy);
    border-color: var(--gold);
}

/* 12-COLUMN GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 16px;
    width: 100%;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    justify-items: stretch;
}

.participants-section {
    grid-column: 1 / 6;
    grid-row: 1;
    text-align: center;
}

.resolution {
    grid-column: 6 / -1;
    grid-row: 1;
    min-height: 0;
    color: var(--navy);
    font-size: 1.12em;
    font-family: 'EB Garamond', serif;
    font-weight: 600;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    resize: both;
    overflow: auto;
    cursor: grab;
}

.resolution:active {
    cursor: grabbing;
}

.resolution::-webkit-resizer {
    background: var(--gold);
    border: 2px solid var(--navy);
    border-radius: 2px;
    width: 18px;
    height: 18px;
}

.resolution.empty:before {
    content: attr(data-placeholder);
    color: #8aa0c0;
    opacity: 1;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-size: 1em;
    font-weight: 400;
    letter-spacing: 0.06em;
}

.debate-stage-section {
    grid-column: 1 / 5;
    grid-row: 2 / 4;
    text-align: left;
    min-height: 0;
}

.timer {
    grid-column: 5 / 8;
    grid-row: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 16px 28px 16px;
}

.coin-flip {
    grid-column: 8 / 10;
    grid-row: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 16px 28px 16px;
}

.declare-winner {
    grid-column: 10 / -1;
    grid-row: 2;
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px 16px 28px 16px;
    align-items: center;
    justify-content: center;
}

.vote-count {
    grid-column: 5 / 9;
    grid-row: 3;
    text-align: center;
    color: var(--navy);
}

.judges-section {
    grid-column: 9 / -1;
    grid-row: 3;
    text-align: center;
}

.reset {
    position: relative;
}

/* PARTICIPANTS */
.participants-display {
    font-family: 'Cinzel', serif;
    font-size: 1.55em;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: 0.03em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.participants-label {
    font-family: 'Cinzel', serif;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin: 2px 0 4px 0;
}

.participants-input-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-12);
    opacity: 0.78;
}

.participant-input,
.judge-name,
.timer-input {
    border: 1.5px solid var(--navy);
    border-radius: 6px;
    font-size: 0.92em;
    color: var(--navy);
    background: rgba(255, 255, 255, 0.55);
    padding: 4px 8px;
    font-family: 'EB Garamond', serif;
}

.participant-input {
    width: 160px;
}

.vs-label {
    font-weight: 700;
    color: var(--gold);
    font-size: 0.85em;
    margin: 0 8px;
    font-family: 'Cinzel', serif;
}

.participants-display .vs-label {
    font-size: 0.7em;
}

.vs-quiet {
    font-size: 0.85em;
    font-weight: 600;
}

/* COIN */
.coin-result {
    font-size: 1em;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 6px;
    min-height: 0;
    letter-spacing: 1px;
    text-align: center;
    font-family: 'Cinzel', serif;
}

.coin {
    width: 56px;
    height: 56px;
    background: var(--navy);
    border: 2px solid var(--gold);
    border-radius: 50%;
    margin: 0 auto 6px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 28px;
    box-shadow: var(--shadow);
    perspective: 600px;
    color: #fff;
}

.coin.flipping {
    animation: coin-flip-y 1s cubic-bezier(.36,2.01,.68,.54);
}

@keyframes coin-flip-y {
    0% { transform: rotateY(0deg); }
    30% { box-shadow: 0 8px 24px #204e80; }
    50% { transform: rotateY(1800deg); }
    100% { transform: rotateY(3600deg); }
}

/* TIMER */
.timer-display {
    font-family: 'Cinzel', serif;
    font-size: 2.8em;
    color: var(--navy);
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: 2px;
    max-width: 100%;
    line-height: 1;
}

.timer-input-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-bottom: 6px;
}

.timer-input {
    width: 64px;
    text-align: center;
}

.timer-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* STAGES */
.stage-controls {
    display: flex;
    justify-content: flex-start;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
}

.stage-list {
    list-style: decimal inside;
    padding-left: 0;
    margin: 0;
    text-align: left;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
}

.stage-list li {
    padding: 6px 12px;
    font-size: 0.92em;
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    border-left: 3px solid transparent;
    margin-left: 0;
    transition: background 0.2s, border-color 0.2s;
}

.stage-current {
    background: rgba(32, 78, 128, 0.08);
    border-left: 3px solid var(--gold);
    font-weight: 600;
    font-family: 'Cinzel', serif;
    color: var(--navy);
}

.stage-complete {
    color: var(--gold);
    opacity: 0.7;
}

/* VOTES */
.vote-count h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.82em;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin: 6px 0 4px 0;
    color: var(--navy);
}

.vote-count h3:first-of-type {
    margin-top: 0;
}

.vote-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.vote-btn {
    padding: 10px 24px;
    font-size: 1em;
}

.vote-count p {
    text-align: center;
    margin: 6px 0 0 0;
    font-family: 'EB Garamond', serif;
    font-size: 0.95em;
}

.winner-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.winner-btn {
    font-size: 1em;
    padding: 10px 24px;
}

@keyframes confetti {
    0% { opacity: 0; transform: translateY(-40px) scale(0.7) rotate(-10deg); }
    50% { opacity: 1; transform: translateY(0) scale(1.1) rotate(10deg); }
    100% { opacity: 0; transform: translateY(40px) scale(0.7) rotate(-10deg); }
}

.confetti {
    position: absolute;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    font-size: 2em;
    pointer-events: none;
    animation: confetti 1.2s ease-in-out;
    z-index: 2;
}

/* JUDGES */
.judge-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.judge-name {
    flex: 1;
    min-width: 0;
    font-size: 0.88em;
}

.judge-decision {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.decision-btn {
    padding: 6px 12px;
    font-size: 0.9em;
    min-width: 45px;
}

.judges-result {
    margin-top: var(--space-12);
    padding: 8px var(--space-12);
    background: rgba(32, 78, 128, 0.06);
    border: 1.5px solid var(--gold);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92em;
    color: var(--navy);
    min-height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .participants-section,
    .resolution,
    .debate-stage-section,
    .timer,
    .coin-flip,
    .declare-winner,
    .vote-count,
    .judges-section {
        grid-column: 1;
        grid-row: auto;
    }

    .main-title {
        font-size: 1.6em;
    }

    .site-header {
        flex-wrap: wrap;
    }
}
