@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600&display=swap');

/* ─── Tokens ────────────────────────────────────────────────────────────── */
:root {
    --text-main:   #f3f4f6;
    --text-muted:  #9ca3af;
    --btn-text:    #111827;
    --pass:        #10b981;
    --fail:        #ef4444;
}

/* Blue theme — Individual & Admin */
.theme-blue {
    --bg-body:      #111827;
    --bg-card:      #1f2937;
    --bg-input:     #111827;
    --bg-tile:      #1f2937;
    --border-color: #374151;
    --gold-accent:  #eab341;
    --tile-glow:    rgba(234, 179, 65, 0.45);
}

/* Brown theme — Team */
.theme-brown {
    --bg-body:      #1c1917;
    --bg-card:      #292524;
    --bg-input:     #1c1917;
    --bg-tile:      #292524;
    --border-color: #44403c;
    --gold-accent:  #d97706;
    --tile-glow:    rgba(217, 119, 6, 0.45);
}

/* ─── Reset / base ─────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    padding: 1.25rem 0.75rem;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    background-color: var(--bg-card);
    border-radius: 14px;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 720px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.admin-container { max-width: 1100px; }

/* ─── Header ───────────────────────────────────────────────────────────── */
.brand-header {
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
}

h1.brand-title {
    font-family: 'Playfair Display', serif;
    color: var(--gold-accent);
    text-align: center;
    font-size: 2.25rem;
    margin: 0 0 0.25rem 0;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.team-chip {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.3rem 0.85rem;
    background: var(--gold-accent);
    color: var(--btn-text);
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ─── Section titles & helpers ─────────────────────────────────────────── */
.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--gold-accent);
    padding-bottom: 0.4rem;
    margin: 0 0 1.25rem 0;
    display: inline-block;
    line-height: 1.2;
}

.helper-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.55;
    margin: 0 0 1.25rem 0;
}

.helper-text code {
    background: var(--bg-input);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--gold-accent);
}

.phase-tag {
    display: inline-block;
    background: var(--bg-input);
    color: var(--gold-accent);
    border: 1px solid var(--gold-accent);
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    margin-bottom: 0.75rem;
}

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

select, input {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--gold-accent) 50%),
        linear-gradient(135deg, var(--gold-accent) 50%, transparent 50%);
    background-position: calc(100% - 18px) center, calc(100% - 13px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.5rem;
    cursor: pointer;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--gold-accent);
    box-shadow: 0 0 0 3px var(--tile-glow);
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    background-color: var(--gold-accent);
    color: var(--btn-text);
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    width: 100%;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    margin-top: 1rem;
    letter-spacing: 0.03em;
    transition: transform 0.08s ease, opacity 0.15s ease;
    min-height: 48px;
}

.btn:hover:not(:disabled) { opacity: 0.92; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}
.btn-secondary:hover:not(:disabled) { color: var(--gold-accent); border-color: var(--gold-accent); opacity: 1; }

.btn-tiny {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}
.btn-tiny:hover { color: var(--gold-accent); border-color: var(--gold-accent); }
.btn-tiny.btn-danger:hover { color: var(--fail); border-color: var(--fail); }

/* ─── Team selection grid ──────────────────────────────────────────────── */
.team-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.team-tile {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 1.1rem 0.75rem;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    min-height: 64px;
    transition: border-color 0.15s ease, transform 0.08s ease;
}
.team-tile:hover { border-color: var(--gold-accent); color: var(--gold-accent); }
.team-tile:active { transform: scale(0.98); }

@media (min-width: 480px) {
    .team-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ─── Big-state (waiting screens) ──────────────────────────────────────── */
.big-state {
    text-align: center;
    padding: 3rem 1rem;
}
.big-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.big-state-title {
    font-family: 'Playfair Display', serif;
    color: var(--gold-accent);
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
}
.big-state-msg {
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 32rem;
    margin: 0 auto;
}

/* ─── Brief ────────────────────────────────────────────────────────────── */
.brief-body { line-height: 1.6; margin-bottom: 1.5rem; }
.brief-body p { margin: 0 0 0.85rem 0; }
.brief-body .quote {
    border-left: 3px solid var(--gold-accent);
    padding: 0.5rem 0 0.5rem 1rem;
    color: var(--text-main);
    font-style: italic;
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
}

/* ─── Picker counter ───────────────────────────────────────────────────── */
.picker-counter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 1.25rem 0;
}

.counter-pill {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.counter-pill.met {
    background: var(--gold-accent);
    color: var(--btn-text);
    border-color: var(--gold-accent);
}

.picker-heading {
    font-family: 'Playfair Display', serif;
    color: var(--gold-accent);
    font-size: 1.15rem;
    margin: 1.25rem 0 0.65rem 0;
    letter-spacing: 0.04em;
}

/* ─── Element stacks ───────────────────────────────────────────────────── */
.stacks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 720px) {
    .stacks { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
    .stacks { grid-template-columns: repeat(4, 1fr); }
}

.stack {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
}

.stack-head {
    margin: 0 0 0.65rem 0;
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: var(--gold-accent);
    letter-spacing: 0.04em;
}
.stack-emoji { font-size: 1.1rem; margin-right: 0.3rem; }

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

.tile {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-tile);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
    min-height: 64px;
    line-height: 1.35;
}
.tile:hover { border-color: var(--gold-accent); }
.tile:active { transform: scale(0.99); }
.tile.selected {
    border-color: var(--gold-accent);
    background: linear-gradient(0deg, var(--tile-glow) 0%, var(--bg-tile) 100%);
    box-shadow: 0 0 0 2px var(--tile-glow);
}
.tile.glitch { border-style: dashed; }
.tile.glitch.selected { border-color: var(--fail); box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35); background: linear-gradient(0deg, rgba(239, 68, 68, 0.18), var(--bg-tile)); }

.tile.burnt {
    opacity: 0.42;
    cursor: not-allowed;
    background: repeating-linear-gradient(
        135deg,
        var(--bg-tile),
        var(--bg-tile) 8px,
        rgba(0, 0, 0, 0.2) 8px,
        rgba(0, 0, 0, 0.2) 16px
    );
    border-style: dashed;
    position: relative;
}
.tile.burnt:hover { border-color: var(--border-color); transform: none; }
.tile.burnt .tile-text { text-decoration: line-through; }
.tile.burnt .tile-id   { background: rgba(0, 0, 0, 0.3); color: var(--text-muted); }

.tile-badge {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    letter-spacing: 0.1em;
}

.tile.limit {
    animation: shake 0.32s ease;
    border-color: var(--fail);
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%     { transform: translateX(-4px); }
    75%     { transform: translateX(4px); }
}

.tile-id {
    display: inline-block;
    background: var(--bg-card);
    color: var(--gold-accent);
    border: 1px solid var(--border-color);
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    margin-right: 0.5rem;
    letter-spacing: 0.04em;
}
.tile-text { font-size: 0.88rem; font-style: italic; opacity: 0.95; }

/* ─── Result / feedback ────────────────────────────────────────────────── */
.result-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: 10px;
    border: 2px solid var(--gold-accent);
    background-color: var(--bg-input);
    text-align: left;
}
.result-card h4 {
    margin: 0 0 0.6rem 0;
    font-family: 'Playfair Display', serif;
    font-size: 1.45rem;
    line-height: 1.2;
}
.result-card p { margin: 0.4rem 0; line-height: 1.55; }
.result-card hr { border: none; border-top: 1px solid var(--border-color); margin: 1rem 0; }
.result-card.burnout { border-color: var(--fail); }
.result-card.safe    { border-color: var(--pass); }

.result-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0.85rem 0 0.4rem 0;
}

.card-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}
.card-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    line-height: 1.45;
}
.card-list li:last-child { border-bottom: none; }
.card-list li.muted { color: var(--text-muted); font-style: italic; }

.card-id {
    display: inline-block;
    background: var(--bg-card);
    color: var(--gold-accent);
    border: 1px solid var(--border-color);
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    margin-right: 0.4rem;
    letter-spacing: 0.04em;
}

.dom-badge {
    background: var(--gold-accent);
    color: var(--btn-text);
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.counts-row {
    margin-top: 0.65rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.glitch-callout {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    line-height: 1.5;
}

.prompt {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 0.65rem !important;
}

.standup-cta {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--fail);
    padding: 0.75rem 0.9rem;
    border-radius: 4px;
    line-height: 1.55;
}

/* ─── Final outcome / debrief ──────────────────────────────────────────── */
.final-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 0.5rem 0 0 0;
}
@media (min-width: 640px) {
    .final-summary { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}
.final-summary-block { min-width: 0; }

.muted-small {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.3rem;
}

.people-summary {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}
.big-stat-cell {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.7rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.big-stat {
    font-family: 'Playfair Display', serif;
    font-size: 1.85rem;
    line-height: 1;
    font-weight: 700;
    margin-bottom: 0.2rem;
}
.big-stat.pass  { color: var(--pass); }
.big-stat.fail  { color: var(--fail); }
.big-stat.muted { color: var(--text-muted); }
.big-stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.phase-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}
.phase-pip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.65rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    font-family: ui-monospace, monospace;
}
.phase-pip.pass  { color: var(--pass); border-color: var(--pass); }
.phase-pip.fail  { color: var(--fail); border-color: var(--fail); }
.phase-pip.muted { color: var(--text-muted); }

.stat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.stat-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
.stat-list li:last-child { border-bottom: none; }
.stat-list strong { color: var(--gold-accent); font-size: 1.1rem; margin-right: 0.4rem; }

.debrief-card {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    border-radius: 10px;
}
.debrief-card h4 {
    margin: 0 0 0.65rem 0;
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--gold-accent);
}
.debrief-card p { margin: 0.4rem 0; line-height: 1.55; font-size: 0.92rem; }
.debrief-card .muted { font-size: 0.85rem; }

/* ─── Admin ────────────────────────────────────────────────────────────── */
.phase-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
@media (min-width: 720px) {
    .phase-controls { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1000px) {
    .phase-controls { grid-template-columns: repeat(7, 1fr); }
}

.phase-btn {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.85rem 0.5rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
    min-height: 48px;
}
.phase-btn:hover { border-color: var(--gold-accent); }
.phase-btn.active {
    background: var(--gold-accent);
    color: var(--btn-text);
    border-color: var(--gold-accent);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}
th, td {
    padding: 0.65rem 0.5rem;
    border: 1px solid var(--border-color);
    text-align: center;
}
th {
    background: var(--bg-input);
    color: var(--gold-accent);
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 0.85rem;
}
.pass { color: var(--pass); font-weight: 700; }
.fail { color: var(--fail); font-weight: 700; }

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.825rem;
}

.live-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--pass);
    border-radius: 50%;
    margin-right: 0.4rem;
    animation: pulse 1.6s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.login-error {
    margin-top: 0.85rem;
    padding: 0.65rem 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--fail);
    color: var(--fail);
    border-radius: 6px;
    font-size: 0.875rem;
}

/* ─── Mobile tightening ────────────────────────────────────────────────── */
@media (max-width: 600px) {
    body { padding: 0.75rem 0.5rem; }
    .app-container { padding: 1.5rem 1rem; border-radius: 10px; }
    h1.brand-title { font-size: 1.85rem; }
    .section-title { font-size: 1.25rem; }
    .result-card { padding: 1.15rem; }
    .result-card h4 { font-size: 1.2rem; }
    .stack { padding: 0.7rem; }
    .tile { min-height: 60px; padding: 0.6rem 0.75rem; }
    .tile-text { font-size: 0.85rem; }
    th, td { padding: 0.45rem 0.3rem; font-size: 0.78rem; }
    th { font-size: 0.72rem; }
}
