:root {
    --red-900: #7f1015;
    --red-800: #991b1b;
    --red-700: #b91c1c;
    --red-600: #d71920;
    --red-500: #ef3340;
    --red-100: #fee2e2;
    --red-50: #fff5f5;
    --white: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --green: #16a34a;
    --blue: #2563eb;
    --yellow: #f59e0b;
    --panel: #ffffff;
    --shadow: 0 18px 45px rgba(127, 16, 21, .14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: #f8fafc;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.nusantara-bg {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 15%, rgba(255,255,255,.18) 0 2px, transparent 3px) 0 0/28px 28px,
        linear-gradient(135deg, #b20f19, #ef3340 48%, #991b1b);
    position: relative;
    overflow: hidden;
}
.nusantara-bg::before,
.nusantara-bg::after {
    content: "";
    position: absolute;
    width: 380px;
    height: 380px;
    border: 52px solid rgba(255,255,255,.08);
    border-radius: 50%;
}
.nusantara-bg::before { left: -180px; top: -170px; }
.nusantara-bg::after { right: -210px; bottom: -180px; }

.landing-wrap {
    position: relative;
    z-index: 1;
    width: min(1160px, calc(100% - 32px));
    min-height: 100vh;
    margin: auto;
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 48px;
    align-items: center;
    padding: 40px 0;
}
.brand-panel { color: white; }
.brand-panel img { width: 260px; filter: brightness(0) invert(1); }
.brand-panel h1 { font-size: clamp(2.8rem, 6vw, 5.5rem); line-height: .95; margin: 28px 0 16px; letter-spacing: -.04em; }
.brand-panel h1 span { display:block; color:#ffe66d; }
.brand-panel p { font-size: 1.14rem; max-width: 640px; line-height: 1.7; color: rgba(255,255,255,.9); }
.feature-row { display:flex; flex-wrap:wrap; gap:12px; margin-top:28px; }
.feature-chip { padding:10px 14px; border:1px solid rgba(255,255,255,.3); background:rgba(255,255,255,.12); border-radius:999px; font-weight:700; }

.auth-card {
    background: rgba(255,255,255,.98);
    border-radius: 28px;
    padding: 30px;
    box-shadow: 0 28px 80px rgba(67, 8, 12, .34);
}
.auth-card h2 { margin:0 0 8px; color:var(--red-800); font-size:1.8rem; }
.auth-card p { margin:0 0 24px; color:var(--muted); line-height:1.6; }
.label { display:block; font-weight:800; margin-bottom:8px; }
.input, .select, .textarea {
    width:100%; border:1px solid #d1d5db; background:white; border-radius:14px; padding:13px 14px; outline:none;
}
.input:focus, .select:focus, .textarea:focus { border-color:var(--red-500); box-shadow:0 0 0 4px rgba(239,51,64,.12); }
.form-group { margin-bottom:18px; }
.btn {
    display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px;
    border:0; border-radius:13px; padding:11px 17px; font-weight:800; cursor:pointer; text-decoration:none;
    transition:transform .15s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:hover { transform:translateY(-1px); filter:brightness(.98); }
.btn:disabled { opacity:.5; cursor:not-allowed; transform:none; }
.btn-primary { background:var(--red-600); color:white; box-shadow:0 10px 24px rgba(215,25,32,.25); }
.btn-success { background:var(--green); color:white; }
.btn-blue { background:var(--blue); color:white; }
.btn-warning { background:var(--yellow); color:#3b2800; }
.btn-light { background:#fff; color:var(--red-700); border:1px solid var(--red-100); }
.btn-dark { background:#111827; color:white; }
.btn-block { width:100%; }
.inline-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.helper-link { display:block; text-align:center; margin-top:18px; color:var(--red-700); font-weight:700; }

.alert { border-radius:14px; padding:12px 14px; margin:0 0 16px; font-weight:650; }
.alert-error { background:#fef2f2; color:#991b1b; border:1px solid #fecaca; }
.alert-success { background:#f0fdf4; color:#166534; border:1px solid #bbf7d0; }
.alert-info { background:#eff6ff; color:#1d4ed8; border:1px solid #bfdbfe; }

.game-page { min-height:100vh; background:#f5f7fb; }
.game-header {
    background:
        linear-gradient(120deg, rgba(127,16,21,.95), rgba(215,25,32,.96)),
        repeating-linear-gradient(45deg, transparent 0 16px, rgba(255,255,255,.06) 16px 18px);
    color:white; padding:18px 24px; position:sticky; top:0; z-index:20; box-shadow:0 10px 30px rgba(127,16,21,.22);
}
.header-inner { max-width:1500px; margin:auto; display:flex; justify-content:space-between; align-items:center; gap:18px; }
.header-brand { display:flex; align-items:center; gap:14px; }
.header-brand img { width:190px; filter:brightness(0) invert(1); }
.header-title strong { display:block; font-size:1.15rem; }
.header-title small { color:rgba(255,255,255,.78); }
.group-badge { background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.22); padding:10px 14px; border-radius:14px; text-align:right; }
.group-badge strong { display:block; }

.game-shell { max-width:1500px; margin:0 auto; padding:22px; }
.status-grid { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:14px; margin-bottom:18px; }
.stat-card { background:white; border:1px solid #eef0f4; border-radius:18px; padding:16px; box-shadow:0 8px 24px rgba(31,41,55,.06); }
.stat-label { color:var(--muted); font-size:.86rem; font-weight:750; }
.stat-value { font-size:1.65rem; font-weight:900; margin-top:4px; }
.progress-track { height:9px; border-radius:99px; background:#e5e7eb; overflow:hidden; margin-top:9px; }
.progress-fill { height:100%; background:linear-gradient(90deg,var(--red-600),#ff7a7f); border-radius:inherit; transition:width .3s ease; }

.game-grid { display:grid; grid-template-columns:minmax(250px,.75fr) minmax(430px,1.5fr) minmax(250px,.65fr); gap:16px; align-items:start; }
.panel { background:white; border:1px solid #e8ebf0; border-radius:20px; box-shadow:0 9px 28px rgba(31,41,55,.07); overflow:hidden; }
.panel-head { padding:15px 17px; display:flex; align-items:center; justify-content:space-between; gap:10px; border-bottom:1px solid #edf0f4; }
.panel-head.red { background:linear-gradient(135deg,var(--red-700),var(--red-500)); color:white; border:0; }
.panel-head h2, .panel-head h3 { margin:0; font-size:1rem; }
.panel-body { padding:18px; }
.challenge-story { color:#374151; line-height:1.65; }
.challenge-category { display:inline-flex; padding:6px 9px; border-radius:999px; background:#fff3c4; color:#8a5900; font-size:.75rem; font-weight:900; text-transform:uppercase; }
.concept-box { padding:13px; border-radius:14px; background:var(--red-50); border:1px solid var(--red-100); color:var(--red-900); margin-top:16px; line-height:1.5; }

.code-panel { background:#111827; border-radius:18px; overflow:hidden; box-shadow:0 12px 30px rgba(17,24,39,.18); }
.code-toolbar { padding:11px 14px; background:#0b1220; color:#cbd5e1; display:flex; justify-content:space-between; align-items:center; font:700 .85rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-editor { width:100%; min-height:365px; resize:vertical; border:0; outline:0; padding:18px; background:#111827; color:#e5e7eb; font:15px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size:4; }
.console { margin-top:14px; background:#080d16; color:#d1fae5; border-radius:16px; overflow:hidden; }
.console-title { padding:10px 14px; color:#cbd5e1; border-bottom:1px solid #1f2937; font-weight:800; }
.console-output { min-height:100px; max-height:220px; overflow:auto; padding:14px; white-space:pre-wrap; font:14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.game-actions { display:grid; grid-template-columns:1.2fr 1.2fr .8fr; gap:10px; margin-top:14px; }
.feedback { margin-top:12px; padding:13px 14px; border-radius:14px; display:none; }
.feedback.show { display:block; }
.feedback.good { background:#ecfdf5; color:#166534; border:1px solid #a7f3d0; }
.feedback.bad { background:#fff7ed; color:#9a3412; border:1px solid #fed7aa; }

.leader-list { list-style:none; padding:0; margin:0; }
.leader-item { display:grid; grid-template-columns:30px 1fr auto; align-items:center; gap:8px; padding:11px 14px; border-bottom:1px solid #f0f1f4; }
.leader-item.me { background:#fff1f2; }
.rank { width:26px; height:26px; display:grid; place-items:center; border-radius:50%; background:#f3f4f6; font-weight:900; }
.leader-name { font-weight:750; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.leader-score { font-weight:900; color:var(--red-700); }
.session-message { text-align:center; padding:40px 20px; }
.session-message .icon { font-size:3rem; }

.admin-layout { min-height:100vh; display:grid; grid-template-columns:240px 1fr; background:#f5f7fb; }
.admin-sidebar { background:linear-gradient(180deg,#7f1015,#b91c1c); color:white; padding:24px 18px; position:sticky; top:0; height:100vh; }
.admin-logo { display:flex; align-items:center; gap:10px; margin-bottom:28px; }
.admin-logo img { width:165px; filter:brightness(0) invert(1); }
.admin-nav { display:grid; gap:7px; }
.admin-nav a { text-decoration:none; padding:11px 13px; border-radius:11px; color:rgba(255,255,255,.82); font-weight:750; }
.admin-nav a:hover, .admin-nav a.active { background:rgba(255,255,255,.15); color:white; }
.admin-main { min-width:0; }
.admin-topbar { background:white; border-bottom:1px solid #e5e7eb; padding:17px 24px; display:flex; justify-content:space-between; align-items:center; position:sticky; top:0; z-index:15; }
.admin-content { padding:24px; max-width:1500px; margin:auto; }
.page-title { margin:0; font-size:1.55rem; }
.page-subtitle { margin:5px 0 0; color:var(--muted); }
.admin-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin:20px 0; }
.metric { background:white; border:1px solid #e8ebef; border-radius:17px; padding:16px; }
.metric .value { font-size:1.75rem; font-weight:900; margin-top:5px; }
.metric .meta { color:var(--muted); font-size:.84rem; }
.admin-grid { display:grid; grid-template-columns:1.1fr .9fr; gap:16px; }
.card { background:white; border:1px solid #e5e7eb; border-radius:18px; overflow:hidden; }
.card-head { padding:15px 17px; border-bottom:1px solid #eceff3; display:flex; justify-content:space-between; align-items:center; gap:10px; }
.card-head h2 { margin:0; font-size:1rem; }
.card-body { padding:17px; }
.control-row { display:flex; gap:9px; flex-wrap:wrap; }
.table-wrap { width:100%; overflow:auto; }
table { width:100%; border-collapse:collapse; }
th, td { padding:12px 13px; border-bottom:1px solid #eceff3; text-align:left; white-space:nowrap; }
th { color:#475569; font-size:.78rem; text-transform:uppercase; letter-spacing:.04em; background:#f8fafc; }
.badge { display:inline-flex; align-items:center; border-radius:999px; padding:5px 9px; font-size:.75rem; font-weight:850; }
.badge-green { background:#dcfce7; color:#166534; }
.badge-red { background:#fee2e2; color:#991b1b; }
.badge-blue { background:#dbeafe; color:#1d4ed8; }
.badge-yellow { background:#fef3c7; color:#92400e; }
.badge-gray { background:#f3f4f6; color:#4b5563; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.form-grid .full { grid-column:1/-1; }
.code-mini { max-width:520px; white-space:pre-wrap; font:12px/1.45 ui-monospace,monospace; background:#111827; color:#e5e7eb; border-radius:10px; padding:10px; }
.empty-state { padding:30px; text-align:center; color:var(--muted); }

.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.6); display:none; place-items:center; padding:20px; z-index:50; }
.modal-backdrop.show { display:grid; }
.modal { width:min(560px,100%); background:white; border-radius:20px; overflow:hidden; box-shadow:0 30px 80px rgba(0,0,0,.3); }
.modal-head { padding:15px 18px; border-bottom:1px solid #e5e7eb; display:flex; justify-content:space-between; align-items:center; }
.modal-body { padding:18px; }
.hint-list { margin:0; padding-left:22px; line-height:1.7; }

@media (max-width: 1100px) {
    .game-grid { grid-template-columns:1fr 1.6fr; }
    .game-grid > :last-child { grid-column:1/-1; }
    .admin-metrics { grid-template-columns:repeat(2,1fr); }
    .admin-grid { grid-template-columns:1fr; }
}
@media (max-width: 820px) {
    .landing-wrap { grid-template-columns:1fr; padding:28px 0; }
    .brand-panel h1 { font-size:3.2rem; }
    .game-header { position:static; }
    .header-inner { align-items:flex-start; }
    .header-brand img { width:155px; }
    .status-grid { grid-template-columns:repeat(2,1fr); }
    .game-grid { grid-template-columns:1fr; }
    .game-grid > :last-child { grid-column:auto; }
    .game-actions { grid-template-columns:1fr; }
    .admin-layout { grid-template-columns:1fr; }
    .admin-sidebar { height:auto; position:static; }
    .admin-nav { display:flex; overflow:auto; }
    .admin-nav a { white-space:nowrap; }
    .form-grid { grid-template-columns:1fr; }
    .form-grid .full { grid-column:auto; }
}
@media (max-width: 520px) {
    .game-shell, .admin-content { padding:14px; }
    .status-grid, .admin-metrics { grid-template-columns:1fr; }
    .header-title { display:none; }
    .group-badge { font-size:.8rem; }
    .auth-card { padding:22px; }
}


/* v1.1 — Squad mode, member names, confidence meter, and celebration */
.status-grid-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.combo-card { background: linear-gradient(145deg, #fff, #fff7ed); border-color: #fed7aa; }
.lives-compact { font-size: 1.25rem; letter-spacing: -2px; }

.team-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 13px 16px;
    border: 1px solid #fecaca;
    border-radius: 18px;
    background:
        linear-gradient(120deg, rgba(255,255,255,.98), rgba(255,245,245,.98)),
        repeating-linear-gradient(45deg, transparent 0 14px, rgba(215,25,32,.05) 14px 16px);
    box-shadow: 0 8px 22px rgba(127, 16, 21, .07);
}
.team-banner > div:first-child { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.team-subtitle { color: var(--muted); font-size: .9rem; }
.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34,197,94,.13);
    animation: livePulse 1.4s infinite;
}
@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
    50% { box-shadow: 0 0 0 9px rgba(34,197,94,.02); }
}

.member-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.member-chip {
    display: inline-flex;
    align-items: center;
    max-width: 220px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #fecaca;
    color: var(--red-800);
    font-size: .77rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-member-chips { min-width: 310px; max-width: 500px; }
.admin-live-members { display: flex; flex-wrap: wrap; gap: 4px; max-width: 310px; margin-top: 7px; }
.admin-live-members span {
    display: inline-flex;
    padding: 3px 7px;
    border-radius: 999px;
    background: #fff1f2;
    color: #9f1239;
    font-size: .68rem;
    font-weight: 750;
}

.round-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 17px;
    padding-bottom: 14px;
    border-bottom: 1px dashed #fecaca;
    font-size: .86rem;
}
.round-badge {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--red-700), var(--red-500));
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .04em;
}
.numeric-prompt {
    white-space: pre-line;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
}

.confidence-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(100deg, #fff7ed, #fff);
    border: 1px solid #fed7aa;
}
.confidence-panel small { display: block; margin-top: 3px; color: var(--muted); }
.confidence-buttons { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.confidence-btn {
    border: 1px solid #fdba74;
    background: #fff;
    color: #9a3412;
    padding: 8px 10px;
    border-radius: 11px;
    font-weight: 800;
    cursor: pointer;
}
.confidence-btn:hover { background: #fff7ed; }
.confidence-btn.active {
    color: #fff;
    background: #ea580c;
    border-color: #ea580c;
    box-shadow: 0 7px 16px rgba(234, 88, 12, .2);
}

.fun-tip {
    margin: 14px;
    padding: 13px;
    border-radius: 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}
.fun-tip p { margin: 5px 0 0; line-height: 1.5; font-size: .86rem; }

.celebration {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .54);
}
.celebration.show {
    display: grid;
    animation: celebrationFade .22s ease-out;
}
.celebration-card {
    width: min(480px, 100%);
    padding: 30px;
    text-align: center;
    border: 5px solid #fff;
    border-radius: 28px;
    color: #fff;
    background:
        radial-gradient(circle at 20% 15%, rgba(255,255,255,.22) 0 4px, transparent 5px) 0 0/36px 36px,
        linear-gradient(135deg, #b91c1c, #ef3340 58%, #f59e0b);
    box-shadow: 0 30px 90px rgba(0,0,0,.35);
    animation: celebrationPop .32s cubic-bezier(.2,.8,.2,1);
}
.celebration-card h2 { margin: 12px 0 8px; font-size: 2rem; }
.celebration-card p { margin: 0; color: rgba(255,255,255,.9); }
.celebration-emoji { font-size: 3rem; letter-spacing: 8px; }
@keyframes celebrationFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes celebrationPop {
    from { opacity: 0; transform: scale(.78) rotate(-2deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

@media (max-width: 1200px) {
    .status-grid-five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .team-banner, .confidence-panel { align-items: flex-start; flex-direction: column; }
    .confidence-buttons { justify-content: flex-start; }
}
@media (max-width: 820px) {
    .status-grid-five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .member-chip { max-width: 100%; }
}
@media (max-width: 520px) {
    .status-grid-five { grid-template-columns: 1fr; }
    .confidence-buttons, .confidence-btn { width: 100%; }
}
