/* The Turing Test - theme taken straight from the logo:
   orange #E8862A, dark grey #4A4A4A, light grey #C8C8C8, off-white #F4F4F4 */

:root {
    --orange: #E8862A;
    --orange-dark: #C96F1B;
    --orange-soft: #FBEEDF;
    --ink: #4A4A4A;
    --ink-deep: #333333;
    --grey: #C8C8C8;
    --grey-soft: #E7E7E7;
    --paper: #F4F4F4;
    --white: #FFFFFF;
    --human: #4A4A4A;
    --ai: #E8862A;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(51, 51, 51, .07);
    --max: 940px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--white);
    color: var(--ink-deep);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK",
                 "PingFang TC", "Microsoft JhengHei", "Noto Sans HK", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

body { padding-bottom: 78px; }

a { color: var(--orange-dark); }

/* ------------------------------------------------------------- top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--grey-soft);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--ink-deep);
    flex: 0 0 auto;
    transition: transform .15s ease;
}
.brand-logo:active { transform: scale(.94); }
.brand-logo .logo-slot { display: block; width: 100%; height: 100%; }
.brand-logo svg, .brand-logo img { width: 100%; height: 100%; display: block; }

.brand-name {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.01em;
    color: var(--ink-deep);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-name:hover { color: var(--orange-dark); }

.lang-toggle {
    border: 1px solid var(--grey);
    background: var(--white);
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.lang-toggle .lang-sep { color: var(--grey); margin: 0 5px; }
.lang-toggle .lang-en, .lang-toggle .lang-zh { opacity: .45; }
html[data-lang="en"] .lang-toggle .lang-en { opacity: 1; color: var(--orange-dark); }
html[data-lang="zh"] .lang-toggle .lang-zh { opacity: 1; color: var(--orange-dark); }

/* -------------------------------------------------------------- layout */
#app {
    max-width: var(--max);
    margin: 0 auto;
    padding: 24px 16px 32px;
}
.screen[hidden] { display: none; }

h1 { font-size: clamp(26px, 5vw, 40px); line-height: 1.18; margin: 0 0 12px; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink); }

.muted { color: #7C7C7C; }
.small { font-size: 13px; }

/* --------------------------------------------------------------- hero */
.hero { text-align: center; padding: 8px 0 4px; }
.hero-art { max-width: 420px; margin: 0 auto 6px; }
.hero-art .art { width: 100%; height: auto; display: block; }
.lede { font-size: 17px; color: #6B6B6B; max-width: 620px; margin: 0 auto; }

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 30px 0 26px;
}

.choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    padding: 22px;
    background: var(--white);
    border: 2px solid var(--grey-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.choice:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: var(--shadow); }
.choice-icon { width: 48px; height: 48px; }
.choice-icon svg { width: 100%; height: 100%; }
.choice-label { font-size: 19px; font-weight: 700; color: var(--ink-deep); }
.choice-hint { font-size: 14px; color: #8A8A8A; }

.code-card {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 26px;
}
.code-card h2 { font-size: 18px; }
.code-row { display: flex; gap: 10px; margin-top: 12px; }
.code-input {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .28em;
    text-transform: uppercase;
    text-align: center;
    padding: 12px 10px;
    border: 2px solid var(--grey);
    border-radius: 10px;
    background: var(--white);
    color: var(--ink-deep);
    width: 170px;
    min-width: 0;
}
.code-input:focus { outline: none; border-color: var(--orange); }
.code-input.wide { width: 100%; margin-bottom: 16px; }

.home-foot { text-align: center; border-top: 1px solid var(--grey-soft); padding-top: 18px; }
.admin-link { font-size: 14px; text-decoration: none; color: #9A9A9A; }
.admin-link:hover { color: var(--orange-dark); }
.home-foot .small { margin-top: 8px; }

/* -------------------------------------------------------------- panel */
.panel {
    background: var(--white);
    border: 1px solid var(--grey-soft);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.panel.narrow { max-width: 460px; margin: 0 auto; }
.panel[hidden] { display: none; }

label { display: block; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); margin: 14px 0 6px; }

input[type="text"], input[type="password"], input:not([type]), textarea, select {
    width: 100%;
    font-size: 16px;
    font-family: inherit;
    padding: 11px 13px;
    border: 2px solid var(--grey);
    border-radius: 10px;
    background: var(--white);
    color: var(--ink-deep);
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); }

.btn {
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 22px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .1s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-ghost { background: var(--white); color: var(--ink); border-color: var(--grey); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-block { width: 100%; margin-top: 16px; white-space: normal; }

.form-error { color: #C0392B; font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.ok-note { color: #2E7D32; font-size: 14px; font-weight: 600; margin: 10px 0 0; }

/* ---------------------------------------------------------- lobby / QR */
.lobby-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin: 18px 0; }
@media (min-width: 760px) { .lobby-grid { grid-template-columns: 300px 1fr; } }

.qr-card {
    background: var(--white);
    border: 1px solid var(--grey-soft);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.qr-holder {
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    aspect-ratio: 1;
}
.qr-holder svg { width: 100%; height: 100%; display: block; border-radius: 8px; }
.room-code { margin-top: 12px; font-size: 13px; color: #8A8A8A; letter-spacing: .06em; text-transform: uppercase; }
.room-code strong {
    display: block;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 32px;
    letter-spacing: .3em;
    color: var(--ink-deep);
    margin-top: 4px;
}

.roster-card { background: var(--paper); border-radius: var(--radius); padding: 18px; }
.roster-card h3 { display: flex; align-items: center; gap: 8px; }
.count {
    background: var(--orange);
    color: #fff;
    font-size: 12px;
    border-radius: 999px;
    padding: 2px 9px;
    letter-spacing: 0;
}
.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.roster li {
    background: var(--white);
    border: 1px solid var(--grey);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 14px;
    font-weight: 600;
}
.roster.compact { justify-content: center; margin-top: 14px; }

.ask-box { border-top: 1px solid var(--grey-soft); padding-top: 6px; }
.ask-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* -------------------------------------------------------- round / live */
.round-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill {
    background: var(--ink-deep);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 6px 14px;
}
.timer {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 26px;
    font-weight: 700;
    color: var(--orange);
    min-width: 46px;
    text-align: right;
}
.timer.low { color: #C0392B; animation: pulse .6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.question { font-size: clamp(19px, 3.4vw, 26px); font-weight: 700; margin: 16px 0; line-height: 1.3; }

.answer-count {
    font-size: clamp(30px, 7vw, 56px);
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink-deep);
    font-variant-numeric: tabular-nums;
    margin: 4px 0 14px;
}
.incoming { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.incoming li {
    background: var(--paper);
    border: 1px dashed var(--grey);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--orange-dark);
}

/* -------------------------------------------------------------- voting */
.vote-stage {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 22px;
    margin: 14px 0;
    position: relative;
    overflow: hidden;
}
.vote-label {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 44px;
    font-weight: 800;
    color: rgba(74, 74, 74, .16);
    line-height: 1;
}
.vote-text { font-size: clamp(21px, 4vw, 34px); font-weight: 700; line-height: 1.3; padding-right: 54px; min-height: 40px; }
.vote-progress { height: 6px; background: var(--grey-soft); border-radius: 999px; margin-top: 18px; overflow: hidden; }
.vote-progress i { display: block; height: 100%; width: 100%; background: var(--orange); transform-origin: left; }

.vote-ask { font-size: 15px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink); margin: 8px 0 0; }
.vote-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vote-btn {
    font-family: inherit;
    font-size: 19px;
    font-weight: 800;
    padding: 20px 10px;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform .1s ease, box-shadow .15s ease;
}
.vote-btn:active { transform: scale(.97); }
.vote-btn.human { background: var(--ink); color: #fff; }
.vote-btn.ai { background: var(--orange); color: #fff; }
.vote-btn.chosen { box-shadow: 0 0 0 4px rgba(232, 134, 42, .3); }
.vote-btn:disabled { opacity: .4; cursor: not-allowed; }

/* -------------------------------------------------------------- reveal */
.verdict {
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
}
.verdict.pass { background: var(--orange-soft); border-left: 6px solid var(--orange); }
.verdict.fail { background: #EAF1EA; border-left: 6px solid var(--ink); }
.verdict .sub { display: block; font-size: 14px; font-weight: 500; color: #6B6B6B; margin-top: 6px; }

.reveal-list { display: grid; gap: 10px; }
.reveal-item {
    border: 2px solid var(--grey-soft);
    border-radius: 12px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 14px;
    align-items: start;
}
.reveal-item.is-ai { border-color: var(--orange); background: #FEFAF5; }
.reveal-item.is-human { border-color: var(--grey); background: var(--white); }
.reveal-key {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    grid-row: span 3;
    line-height: 1.2;
}
.reveal-text { font-size: 17px; font-weight: 600; }
.reveal-meta { font-size: 13px; color: #8A8A8A; }
.tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-radius: 5px;
    padding: 3px 7px;
    color: #fff;
    margin-right: 6px;
}
.tag.ai { background: var(--orange); }
.tag.human { background: var(--ink); }
.tag.fooled { background: #fff; color: var(--orange-dark); border: 1px solid var(--orange); }
.tag.mine { background: var(--white); color: var(--ink); border: 1px solid var(--grey); }

.bars { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--grey-soft); margin-top: 4px; }
.bars i { display: block; height: 100%; }
.bars .b-human { background: var(--ink); }
.bars .b-ai { background: var(--orange); }

.reveal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

.final-box {
    text-align: center;
    background: var(--paper);
    border-radius: var(--radius);
    padding: 26px 20px;
}
.final-box .big { font-size: clamp(26px, 5vw, 38px); font-weight: 800; letter-spacing: -.02em; margin: 8px 0; }
.final-box .rate { font-size: 54px; font-weight: 800; color: var(--orange); line-height: 1; }
.final-table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; }
.final-table th, .final-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--grey-soft); }
.final-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- player */
.role-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 6px 15px;
    margin-bottom: 4px;
}
.role-badge.answerer { background: var(--orange); color: #fff; }
.role-badge.voter { background: var(--ink); color: #fff; }

.waiting { text-align: center; padding: 22px 0 6px; color: #8A8A8A; }
.dot-pulse { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--orange); margin: 0 auto 12px; animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .2; transform: scale(.75); } }

/* ------------------------------------------------------------- banner */
.banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 11px 44px 11px 16px;
    background: var(--ink-deep);
    color: #DADADA;
    font-size: 14px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .16);
}
.banner a { color: var(--orange); font-weight: 700; text-decoration: none; }
.banner a:hover { text-decoration: underline; }
.banner-sep { color: #666; }
.banner-close {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.banner[hidden] { display: none; }

/* ------------------------------------------------------------ utility */
[hidden] { display: none !important; }
button { font-family: inherit; }
::selection { background: rgba(232, 134, 42, .3); }

@media (max-width: 520px) {
    #app { padding: 16px 12px 26px; }
    .panel { padding: 16px; }
    .code-input { width: 100%; }
    .code-row { flex-direction: column; }
    .code-row .btn { width: 100%; }
    .reveal-key { grid-row: auto; font-size: 18px; }
    .reveal-item { grid-template-columns: auto 1fr; }
}
