/* OVALTINE QUEST admin. Self-hosted campaign fonts; no inline styles (the CSP forbids them), so anything that
   varies per element is a custom property set from script. */
@font-face { font-family: 'BoonTook Mon'; src: url('/fonts/boontookmon.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'FC Friday'; src: url('/fonts/fcfriday-medium.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/montserrat-var.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #12264a; --blue: #1f4e9c; --blue-d: #163b78; --blue-l: #eaf1ff; --amber: #f2a63b; --amber-l: #fff3dc;
  --mist: #f3f6fb; --card: #fff; --line: #e3e9f3; --text: #1d2b45; --muted: #62708a; --ok: #168a5f; --bad: #c8372d; --bad-l: #fdeceb;
  --f-body: 'FC Friday', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-num: 'Montserrat', 'FC Friday', system-ui, sans-serif;
  --f-display: 'BoonTook Mon', 'FC Friday', system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(18, 38, 74, .06), 0 8px 24px rgba(18, 38, 74, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--mist); color: var(--text); font: 17px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico.big { width: 40px; height: 40px; color: var(--bad); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------- controls ---------- */
button { font: inherit; cursor: pointer; }
button.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px;
  border: 0; border-radius: 12px; color: #fff; font-weight: 700;
  background: linear-gradient(180deg, #2a62bb, var(--blue)); box-shadow: 0 6px 16px rgba(31, 78, 156, .28);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
button.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(31, 78, 156, .34); }
button.primary:active { transform: translateY(0) scale(.98); }
button.primary:disabled { filter: grayscale(.4) opacity(.7); transform: none; cursor: default; }
button.primary.busy::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite; }
button.wide { width: 100%; }
button.link { background: none; border: 0; padding: 6px 2px; color: var(--blue); font-weight: 600; }
button.link:hover { text-decoration: underline; }
button.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }
input, select {
  font: inherit; color: var(--text); background: #fff; min-height: 46px; padding: 0 14px; width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px; transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #9aa6bd; }
input:hover, select:hover { border-color: #c9d4e6; }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(31, 78, 156, .14); }
select { appearance: none; padding-right: 40px; background:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 21px) 52% / 6px 6px no-repeat,
  linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 15px) 52% / 6px 6px no-repeat, #fff; }
.ctl { display: grid; gap: 6px; min-width: 0; }
.ctl label, .step > label { font-size: .88rem; font-weight: 600; color: var(--muted); }
.msg { min-height: 1.5em; font-size: .92rem; color: var(--bad); }
.msg.ok { color: var(--ok); } .msg.info { color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.brand { position: relative; overflow: hidden; color: #fff; display: grid; place-items: center; padding: 48px 40px; background: linear-gradient(155deg, #0f2447 0%, #1b438a 60%, #2a62bb 100%); }
.blobs i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: drift 22s ease-in-out infinite alternate; }
.blobs i:nth-child(1) { width: 340px; height: 340px; background: #2f7bff; top: -90px; left: -80px; }
.blobs i:nth-child(2) { width: 260px; height: 260px; background: var(--amber); opacity: .28; bottom: -60px; right: 6%; animation-duration: 28s; animation-delay: -6s; }
.blobs i:nth-child(3) { width: 220px; height: 220px; background: #5ec3ff; opacity: .3; top: 45%; left: 55%; animation-duration: 25s; animation-delay: -12s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }
.brand-in { position: relative; display: grid; gap: 22px; max-width: 520px; width: 100%; }
.wordmark { font-family: var(--f-num); font-weight: 800; letter-spacing: .06em; font-size: 1rem; }
.brand h1 { font-family: var(--f-display); font-size: clamp(1.7rem, 2.6vw, 2.4rem); font-weight: 700; line-height: 1.3; }
.brand h1 span { display: block; }
.brand-sub { color: #b9cdf0; }
.motif { width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(5, 15, 40, .4)); }
.m-frame { fill: #f4f8ff; } .m-sun { fill: var(--amber); } .m-sun-core { fill: #fff2c9; }
.m-hill { fill: #8db3ee; } .m-house { fill: #fff; stroke: #c9d8f3; stroke-width: 2; } .m-roof { fill: #1f4e9c; }
.m-door { fill: #a8591f; } .m-door.b { fill: #1f4e9c; } .m-win { fill: #7fc2ff; } .m-cloud { fill: #dbe7fb; }
.m-ring { fill: none; stroke: #fff; stroke-width: 3.5; stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; animation: draw 9s ease-in-out infinite backwards; }
.m-pulse { fill: none; stroke: var(--amber); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; animation: pulse 9s ease-out infinite backwards; }
.m-ring.r1, .m-pulse.r1 { animation-delay: .9s; } .m-ring.r2, .m-pulse.r2 { animation-delay: 2.9s; } .m-ring.r3, .m-pulse.r3 { animation-delay: 4.5s; }
@keyframes draw { 0% { stroke-dashoffset: 100; opacity: 1; } 7% { stroke-dashoffset: 0; } 82% { stroke-dashoffset: 0; opacity: 1; } 92%, 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes pulse { 0%, 6% { opacity: 0; transform: scale(1); } 8% { opacity: .85; transform: scale(1); } 22%, 100% { opacity: 0; transform: scale(1.8); } }
.m-lens circle { fill: rgba(255, 255, 255, .1); stroke: var(--amber); stroke-width: 4; }
.m-lens path { stroke: var(--amber); stroke-width: 6; stroke-linecap: round; }
.m-lens { animation: lens 9s ease-in-out infinite; transform: translate(330px, 235px); }
@keyframes lens {
  0% { transform: translate(330px, 235px); } 8%, 20% { transform: translate(390px, 92px); } 30%, 40% { transform: translate(334px, 174px); }
  48%, 62% { transform: translate(297px, 102px); } 82% { transform: translate(350px, 250px); } 100% { transform: translate(330px, 235px); }
}

.panel { display: grid; place-items: center; padding: 32px 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.signin { width: min(100%, 420px); padding: 34px 30px 26px; display: grid; gap: 14px; animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.signin.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--amber-l); color: #b56d00; }
.mark .ico { width: 26px; height: 26px; }
.signin h2 { font-size: 1.45rem; }
.sub, .hint { color: var(--muted); font-size: .95rem; }
.step { display: grid; gap: 10px; margin-top: 6px; }
.step.enter { animation: slidein .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes slidein { from { opacity: 0; transform: translateX(18px); } }
.input-ico { position: relative; }
.input-ico .ico { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: #8a98b3; pointer-events: none; }
.input-ico input { padding-left: 44px; }
.otp-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp { text-align: center; padding: 0; min-height: 58px; font-family: var(--f-num); font-weight: 700; font-size: 1.5rem; border-radius: 12px; caret-color: var(--blue); }
.otp.filled { border-color: var(--blue); background: #f4f8ff; animation: pop .22s ease-out; }
@keyframes pop { 50% { transform: scale(1.08); } }
.row-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fine { font-size: .82rem; color: #8a98b3; text-align: center; }

/* ---------- shell ---------- */
.loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 24px 16px; background: #fff; border-right: 1px solid var(--line); }
.wordmark.small { color: var(--ink); padding: 0 10px; font-size: .95rem; }
.tabs { display: grid; gap: 4px; }
.tabs button, .logout { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-weight: 600; text-align: left; transition: background .15s ease, color .15s ease; }
.tabs button:hover, .logout:hover { background: var(--mist); color: var(--text); }
.tabs button.on { background: var(--blue-l); color: var(--blue); }
.tabs button.on::before { content: ''; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--amber); }
.logout { margin-top: auto; }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 48px; }
.page-head { max-width: 1040px; margin: 0 auto 20px; }
.page-head h1 { font-size: 1.7rem; font-weight: 700; }
.body { max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); display: grid; gap: 2px; position: relative; overflow: hidden; --c: var(--blue); }
.stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.stat.amber { --c: var(--amber); } .stat.grey { --c: #aab6cc; }
.stat .num { font-family: var(--f-num); font-weight: 800; font-size: 2.3rem; line-height: 1.15; color: var(--ink); }
.stat span { color: var(--muted); }
.card h2 + .small { margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: clamp(4px, 1.2vw, 12px); height: 210px; margin-top: 18px; }
.col { flex: 1; min-width: 0; height: 100%; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 4px; }
.col .v { font-family: var(--f-num); font-weight: 700; font-size: .78rem; color: var(--ink); }
.col .d { font-family: var(--f-num); font-size: .7rem; color: var(--muted); }
.bar { width: 100%; max-width: 38px; height: var(--h); align-self: end; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #4f86dc, var(--blue)); transform-origin: bottom; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d); transition: background .15s ease; }
.col:hover .bar { background: linear-gradient(180deg, #ffc566, var(--amber)); }
@keyframes grow { from { transform: scaleY(0); } }
.mstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.mstat { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--mist); display: grid; gap: 10px; }
.mstat dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mstat dt { font-size: .8rem; color: var(--muted); } .mstat dd { margin: 0; font-family: var(--f-num); font-weight: 700; color: var(--ink); }

.tablewrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.result > .tablewrap { margin-top: 0; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
th { position: sticky; top: 0; background: #f7f9fd; color: var(--muted); font-weight: 600; font-size: .85rem; text-align: left; padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom: 1px solid #eef2f8; white-space: nowrap; }
tbody tr { animation: rowin .35s ease both; animation-delay: calc(var(--i, 0) * 28ms); transition: background .12s ease; }
tbody tr:hover { background: #f5f8ff; }
tbody tr:last-child td { border-bottom: 0; }
tr.warn { background: #fffaf0; } tr.warn:hover { background: #fff4de; }
@keyframes rowin { from { opacity: 0; transform: translateY(4px); } }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.rank { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 9px; font-family: var(--f-num); font-weight: 700; font-size: .85rem; color: var(--muted); background: var(--mist); }
.rank.r1 { background: var(--amber); color: #4a2d00; } .rank.r2 { background: #dfe6f2; color: #2c3a55; } .rank.r3 { background: #f2c9a4; color: #5a2f10; }
.code { font-family: var(--f-num); font-weight: 600; font-size: .88rem; }
.time { font-family: var(--f-num); color: var(--ink); }
.flag { display: inline-block; margin-right: 4px; padding: 1px 9px; border-radius: 999px; font-family: var(--f-num); font-size: .7rem; font-weight: 700; background: var(--blue-l); color: var(--blue-d); }
.f-FAST, .f-MANY_WRONGS, .f-WALL_SHORT { background: var(--bad-l); color: #9a2119; }
.f-SAME_PHONE { background: var(--amber-l); color: #7a4b00; } .f-TESTER { background: #e8ebf1; color: #3a4660; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.toolbar .ctl:first-child { flex: 1 1 240px; } .toolbar .ctl:nth-child(2) { flex: 0 0 170px; }
.toolbar + .msg { margin-top: 10px; }
.warn-box { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--amber-l); border: 1px solid #f0cf94; color: #5a3b00; }
.warn-box .ico { margin-top: 3px; color: #b56d00; }
.legend summary { cursor: pointer; font-weight: 600; }
.legend dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 14px 0 0; align-items: center; }
.legend dd { margin: 0; color: var(--muted); }

/* ---------- player lookup ---------- */
.searchbar .grow { flex: 1 1 320px; }
.searchbar .input-ico input { padding-left: 44px; }
button.codelink { padding: 2px 8px; border: 0; border-radius: 8px; background: var(--blue-l); color: var(--blue-d); transition: background .12s ease, transform .12s ease; }
button.codelink:hover { background: #d6e5ff; text-decoration: underline; }
.players { display: grid; gap: 18px; }
.player { display: grid; gap: 20px; animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
.p-head { display: flex; align-items: center; gap: 16px; }
.avatar { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; color: #fff; background: linear-gradient(145deg, #2a62bb, #12264a); box-shadow: 0 6px 16px rgba(31, 78, 156, .3); }
.p-id { min-width: 0; display: grid; gap: 4px; }
.p-id h2 { font-size: 1.3rem; overflow-wrap: anywhere; }
.p-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.group { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--mist); }
.group h3, .psec h3 { margin: 0 0 8px; font-size: .95rem; color: var(--ink); }
.group dl { margin: 0; display: grid; gap: 7px; }
.group dl > div { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 8px; align-items: baseline; }
.group dt { color: var(--muted); font-size: .88rem; }
.group dd { margin: 0; overflow-wrap: anywhere; }
.uid { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.uid .code { word-break: break-all; }
.psec { display: grid; gap: 8px; }
.psec .tablewrap { margin-top: 0; }
.copy, button.link.tiny { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--blue); font-size: .8rem; font-weight: 600; transition: background .12s ease, border-color .12s ease; }
button.link.tiny { border-color: transparent; background: none; }
.copy .ico { width: 14px; height: 14px; }
.copy:hover { background: var(--blue-l); }
.copy.done { color: var(--ok); border-color: #b9e3d1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); transition: background .12s ease, border-color .12s ease, transform .12s ease; }
.chip:hover { background: var(--blue-l); border-color: #b9cdf0; transform: translateY(-1px); }
.st { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.st-done { background: #e3f6ee; color: #11694a; } .st-active { background: var(--amber-l); color: #7a4b00; }
.yes { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-weight: 600; }
.yes .ico { width: 16px; height: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .brand { padding: 28px 20px 56px; } .brand-in { gap: 12px; } .brand h1 { font-size: 1.35rem; } .brand h1 span { display: inline; } .brand h1 span + span::before { content: ' '; } .motif { max-width: 300px; margin: 0 auto; } .brand-sub { display: none; }
  .panel { align-items: start; margin-top: -26px; padding-top: 0; position: relative; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .stat .num { font-size: 1.8rem; } .stat { padding: 14px 16px; } .card { padding: 18px; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .wordmark.small { padding: 0; }
  .tabs { display: flex; order: 3; width: 100%; overflow-x: auto; }
  .tabs button { width: auto; flex: none; min-height: 42px; }
  .tabs button.on::before { left: 12px; right: 12px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .logout { margin: 0 0 0 auto; width: auto; min-height: 40px; }
  .main { padding-top: 18px; } .page-head h1 { font-size: 1.4rem; }
  .toolbar .ctl:nth-child(2) { flex: 1 1 120px; } .toolbar .primary { width: 100%; }
  .group dl > div { grid-template-columns: 7.2em minmax(0, 1fr); }
  .p-head { gap: 12px; } .avatar { width: 46px; height: 46px; font-size: 1.2rem; }
}
@media (max-width: 380px) { .otp-row { gap: 5px; } .otp { min-height: 52px; font-size: 1.3rem; } .signin { padding: 26px 18px 20px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .m-ring { stroke-dashoffset: 0; } .m-pulse, .m-lens { display: none; }
}
