:root {
    --ink: #07151c;
    --gold: #e0b04a;
    --gold-2: #c8942d;
    --cream: #f4efe4;
    --muted: #9ab0ba;
    --ok: #3cb98a;
    --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 80% 10%, #1b4d61 0%, transparent 36%),
        radial-gradient(circle at 10% 90%, #123241 0%, transparent 42%),
        var(--ink);
    color: var(--cream);
    font-family: "Tajawal", sans-serif;
}

#app {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 36px 40px;
    display: flex;
    flex-direction: column;
}

.tv-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: var(--ink);
    font-weight: 800;
    font-size: 1.5rem;
}

.brand strong, .brand small { color: #fff; display: block; }
.brand small { opacity: 0.85; font-size: 0.95rem; }

.tv-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.code-chip {
    font-size: 1.8rem;
    letter-spacing: 0.22em;
    background: var(--gold);
    color: var(--ink);
    border-radius: 14px;
    padding: 8px 18px;
    font-weight: 800;
}

.phase {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.status {
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(196, 73, 58, 0.18);
    color: #f0b4ad;
}

.status.is-on {
    background: rgba(47, 143, 107, 0.2);
    color: #9be3c4;
}

.screen { flex: 1; }
.screen[hidden], [hidden] { display: none !important; }

.join-card {
    max-width: 640px;
    margin: 8vh auto 0;
    background: rgba(255, 250, 241, 0.05);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 40px;
    text-align: center;
}

.join-card h1 { margin: 0 0 10px; font-size: 2.4rem; }
.join-card p { color: var(--muted); font-size: 1.2rem; }

#join-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-top: 28px;
}

input {
    width: 100%;
    border: 0;
    border-radius: 16px;
    padding: 18px 20px;
    font: inherit;
    font-size: 1.6rem;
    letter-spacing: 0.18em;
    text-align: center;
    background: #fffaf1;
    color: var(--ink);
    text-transform: uppercase;
}

.btn {
    border: 0;
    border-radius: 16px;
    padding: 18px 28px;
    font: inherit;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
}

.btn-gold { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--ink); }

.stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
    margin: 8px 0 28px;
}

.tv-letter {
    min-width: 22vh;
    min-height: 22vh;
    border-radius: 36px;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: var(--ink);
    font-size: 16vh;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.tv-timer {
    font-size: 14vh;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.04em;
}

.tv-timer.is-low { color: #ffb4aa; }

.tv-caption {
    margin: 12px 0 0;
    font-size: 1.6rem;
    color: var(--muted);
}

.tv-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.tv-player {
    background: rgba(255, 250, 241, 0.06);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 1.35rem;
}

.tv-player strong { font-size: 1.5rem; }
.tv-player .pts { color: var(--gold); font-weight: 800; }

.tv-player.is-sent {
    outline: 2px solid rgba(60, 185, 138, 0.7);
}

.tag {
    display: inline-block;
    margin-inline-start: 8px;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--gold);
    color: var(--ink);
    font-weight: 800;
}

.tv-board {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.tv-cat {
    background: rgba(255, 250, 241, 0.05);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 18px;
}

.tv-cat h3 {
    margin: 0 0 12px;
    font-size: 1.6rem;
    color: var(--gold);
}

.tv-answer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    font-size: 1.25rem;
}

.tv-answer em {
    color: var(--muted);
    font-style: normal;
}

.score-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.score-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 250, 241, 0.06);
    border-radius: 18px;
    padding: 16px 20px;
    font-size: 1.7rem;
}

.score-list li:first-child {
    background: linear-gradient(90deg, rgba(224, 176, 74, 0.38), transparent);
    font-size: 2.1rem;
}

.toast {
    background: #c4493a;
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
}

@media (max-width: 900px) {
    #app { padding: 16px; }
    .stage { flex-direction: column; gap: 16px; text-align: center; }
    .tv-letter { font-size: 22vw; min-width: 30vw; min-height: 30vw; }
    .tv-timer { font-size: 18vw; }
    #join-form { grid-template-columns: 1fr; }
}
