:root {
  color-scheme: dark;
  --bg: #04110d;
  --panel: #09241b;
  --panel-2: #0d3024;
  --line: rgb(255 255 255 / 10%);
  --ink: #f6f3e8;
  --muted: #9db1a7;
  --jade: #42d98e;
  --jade-soft: #a9efc5;
  --gold: #f3ce73;
  --danger: #dd6862;
  --shadow: 0 24px 70px rgb(0 0 0 / 38%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: #020c09; }
body { min-height: 100dvh; }
button, input, select { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
#app { min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; color: var(--ink); background: rgb(255 255 255 / 5%); font-weight: 850; line-height: 1.25; text-align: center; cursor: pointer; }
.btn:hover { border-color: rgb(255 255 255 / 22%); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { border-color: rgb(66 217 142 / 35%); color: #042016; background: linear-gradient(145deg, #b0f2c9, #46da91); }
.btn.gold { border-color: rgb(243 206 115 / 42%); color: #2a1d06; background: linear-gradient(145deg, #ffe69a, #c99233); }
.btn.danger { color: #ffd7d4; background: rgb(151 61 57 / 60%); }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 12px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: rgb(255 255 255 / 5%); cursor: pointer; }
#locale-root { position: fixed; z-index: 260; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); }
.locale-switch { display: inline-grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: rgb(3 19 14 / 88%); box-shadow: 0 8px 24px #0005; backdrop-filter: blur(12px); }
.locale-switch button { min-width: 34px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 999px; padding: 0 7px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 900; cursor: pointer; }
.locale-switch button.active { color: #092016; background: var(--gold); }

/* Closed login */
.login-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); background: radial-gradient(circle at 20% 20%, #10573e, transparent 40%), linear-gradient(135deg, #061c15, #020b08); }
.login-art { position: relative; display: grid; align-content: end; min-height: 420px; overflow: hidden; padding: 7vw; }
.login-art::before { content: "瓯"; position: absolute; right: 8%; top: 4%; color: rgb(244 215 135 / 8%); font: 44vw STKaiti, KaiTi, serif; line-height: 1; }
html[lang="zh-Hant"] .login-art::before { content: "甌"; }
html[lang="en"] .login-art::before { content: "O"; font-family: Georgia, serif; }
.login-art h1 { position: relative; max-width: 720px; margin: 10px 0 14px; font: 700 clamp(46px, 6vw, 86px) STKaiti, KaiTi, serif; letter-spacing: .12em; }
.login-art p { position: relative; max-width: 590px; margin: 0; color: #bcd0c6; font-size: 16px; line-height: 1.8; }
.login-panel { display: grid; place-items: center; padding: 32px; background: rgb(2 12 9 / 58%); backdrop-filter: blur(22px); }
.login-card { width: min(100%, 430px); border: 1px solid var(--line); border-radius: 28px; padding: 34px; background: rgb(8 31 23 / 88%); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 28px; }
.login-brand img { width: 56px; height: 56px; border: 1px solid rgb(243 206 115 / 40%); border-radius: 17px; }
.login-brand strong { display: block; font-size: 23px; }
.login-brand span { color: var(--muted); font-size: 12px; }
.field { display: grid; gap: 8px; margin-bottom: 15px; }
.field label { color: #d7e3dd; font-size: 13px; font-weight: 800; }
.field input, .field select, select.field-control { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; outline: none; background: #061b14; }
.field input:focus, .field select:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgb(66 217 142 / 12%); }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

/* Player shell */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 238px minmax(0, 1fr); background: radial-gradient(circle at 80% 0%, rgb(38 148 104 / 15%), transparent 34%), var(--bg); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 24px 16px; background: rgb(4 20 15 / 93%); }
.side-brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 28px; }
.side-brand img { width: 45px; height: 45px; border-radius: 14px; }
.side-brand strong { display: block; font: 700 21px STKaiti, KaiTi, serif; letter-spacing: .1em; }
.side-brand span { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.nav { display: grid; gap: 7px; }
.nav button { min-height: 48px; display: flex; align-items: center; gap: 11px; border: 1px solid transparent; border-radius: 14px; padding: 9px 13px; color: #a9bbb2; background: transparent; font-weight: 800; text-align: left; cursor: pointer; }
.nav button.active { border-color: rgb(66 217 142 / 20%); color: var(--jade-soft); background: rgb(66 217 142 / 9%); }
.nav-icon { width: 24px; color: var(--gold); text-align: center; }
.side-user { margin-top: auto; border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: rgb(255 255 255 / 3%); }
.side-user strong { display: block; font-size: 13px; }
.side-user span { display: block; margin: 3px 0 9px; color: var(--muted); font-size: 10px; }
.content { min-width: 0; padding: 30px clamp(20px, 4vw, 58px) 48px; }
.content-inner { width: min(100%, 1180px); margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 25px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 38px); }
.status-pill { display: flex; align-items: center; gap: 8px; border: 1px solid rgb(66 217 142 / 22%); border-radius: 999px; padding: 8px 12px; color: #bee9d0; background: rgb(66 217 142 / 7%); font-size: 11px; }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 12px var(--jade); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr); gap: 16px; }
.hero-card { min-height: 255px; display: grid; align-content: end; overflow: hidden; border: 1px solid rgb(243 206 115 / 24%); border-radius: 25px; padding: 27px; background: radial-gradient(circle at 85% 16%, rgb(243 206 115 / 25%), transparent 23%), linear-gradient(135deg, #124b38, #09271d); box-shadow: var(--shadow); }
.hero-card h2 { margin: 7px 0 8px; font-size: clamp(27px, 4vw, 42px); }
.hero-card p { max-width: 570px; margin: 0 0 20px; color: #bed1c8; font-size: 13px; line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.rank-card { border: 1px solid var(--line); border-radius: 25px; padding: 23px; background: linear-gradient(145deg, #0c3024, #071d16); }
.rank-badge { width: 68px; height: 68px; display: grid; place-items: center; margin-bottom: 21px; border: 1px solid rgb(243 206 115 / 38%); border-radius: 50%; color: #342308; background: linear-gradient(145deg, #ffe69a, #c68f31); font-size: 27px; font-weight: 900; }
.rank-card h3 { margin: 0 0 5px; font-size: 20px; }
.rank-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 31px 0 14px; }
.section-head h2 { margin: 4px 0 0; font-size: 21px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.mode-card { min-height: 174px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 20px; padding: 19px; background: linear-gradient(145deg, rgb(13 49 37 / 85%), rgb(7 27 20 / 92%)); }
.mode-card:hover { border-color: rgb(66 217 142 / 30%); }
.mode-top { display: flex; justify-content: space-between; gap: 10px; }
.mode-icon { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid rgb(243 206 115 / 25%); border-radius: 14px; color: var(--gold); background: rgb(243 206 115 / 7%); font-size: 19px; }
.live-tag { height: fit-content; border-radius: 999px; padding: 4px 7px; color: #9de8bd; background: rgb(66 217 142 / 10%); font-size: 9px; font-weight: 900; }
.mode-card h3 { margin: 15px 0 5px; font-size: 16px; }
.mode-card p { flex: 1; margin: 0 0 13px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.mode-card .btn { width: 100%; }
.queue-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 17px; border: 1px solid rgb(243 206 115 / 28%); border-radius: 18px; padding: 14px 17px; background: rgb(243 206 115 / 7%); }
.queue-banner strong { display: block; font-size: 14px; }
.queue-banner span { color: var(--muted); font-size: 11px; }

/* Secondary screens */
.panel { border: 1px solid var(--line); border-radius: 22px; padding: 22px; background: rgb(9 35 26 / 78%); }
.panel + .panel { margin-top: 14px; }
.panel h2, .panel h3 { margin-top: 0; }
.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.rule-card { border: 1px solid var(--line); border-radius: 18px; padding: 19px; background: rgb(255 255 255 / 3%); }
.rule-card b { color: var(--gold); }
.rule-card p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.cosmetic-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cosmetic { min-height: 160px; display: grid; align-content: end; border: 1px solid var(--line); border-radius: 18px; padding: 15px; background: radial-gradient(circle at 50% 25%, rgb(66 217 142 / 18%), transparent 35%), #08251b; }
.cosmetic-preview { height: 58px; display: grid; place-items: center; color: var(--gold); font: 38px STKaiti, KaiTi, serif; }
.cosmetic strong { font-size: 13px; }
.cosmetic span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.account-stat { border: 1px solid var(--line); border-radius: 17px; padding: 17px; background: rgb(255 255 255 / 3%); }
.account-stat span { color: var(--muted); font-size: 10px; }
.account-stat b { display: block; margin-top: 4px; font-size: 17px; }

/* Modal */
#modal-root { position: fixed; z-index: 100; inset: 0; pointer-events: none; }
.modal-backdrop { position: absolute; inset: 0; display: grid; place-items: center; padding: 18px; background: rgb(0 8 5 / 72%); backdrop-filter: blur(7px); pointer-events: auto; }
.modal { width: min(100%, 520px); max-height: 88dvh; overflow: auto; border: 1px solid var(--line); border-radius: 24px; padding: 22px; background: #0a291f; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 15px; margin-bottom: 18px; }
.modal-head h2 { margin: 4px 0 0; font-size: 21px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 17px; }
.invite-code { margin: 12px 0; border: 1px dashed rgb(243 206 115 / 35%); border-radius: 14px; padding: 14px; color: var(--gold); background: rgb(0 0 0 / 18%); font: 700 13px ui-monospace, monospace; overflow-wrap: anywhere; }
.room-roster { display: grid; gap: 7px; margin: 13px 0; }
.room-seat { display: flex; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
.room-seat span { color: var(--muted); }
#toast-root { position: fixed; z-index: 200; right: 18px; top: 18px; width: min(calc(100% - 36px), 380px); display: grid; gap: 8px; pointer-events: none; }
.toast { border: 1px solid rgb(255 255 255 / 12%); border-radius: 14px; padding: 12px 14px; background: rgb(8 54 39 / 96%); box-shadow: var(--shadow); font-size: 12px; }
.toast.error { background: rgb(111 43 40 / 97%); }

/* Admin */
.admin-shell { min-height: 100dvh; background: radial-gradient(circle at 92% 0%, rgb(66 217 142 / 13%), transparent 34%), var(--bg); }
.admin-top { height: 76px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 0 clamp(20px, 5vw, 70px); background: rgb(4 20 15 / 88%); }
.admin-actions { display: flex; align-items: center; gap: 9px; }
.admin-locale { box-shadow: none; }
body:has(.admin-shell) > #locale-root { display: none; }
.admin-brand { display: flex; align-items: center; gap: 11px; }
.admin-brand img { width: 42px; height: 42px; border-radius: 12px; }
.admin-brand strong { display: block; }
.admin-brand span { color: var(--muted); font-size: 10px; }
.admin-main { width: min(calc(100% - 40px), 1320px); margin: 0 auto; padding: 30px 0 50px; }
.admin-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 20px; }
.admin-heading h1 { margin: 5px 0 0; font-size: 31px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { min-height: 125px; border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: linear-gradient(145deg, #0c3024, #071d16); }
.kpi span { color: var(--muted); font-size: 11px; }
.kpi b { display: block; margin: 9px 0 2px; color: var(--gold); font-size: 31px; font-variant-numeric: tabular-nums; }
.kpi small { color: #8bb9a1; font-size: 10px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(330px, .8fr); gap: 14px; margin-top: 14px; }
.chart-card { border: 1px solid var(--line); border-radius: 22px; padding: 20px; background: rgb(9 35 26 / 82%); }
.chart-card h2 { margin: 0 0 4px; font-size: 17px; }
.chart-card > p { margin: 0 0 20px; color: var(--muted); font-size: 10px; }
.bar-chart { height: 230px; display: flex; align-items: end; gap: 10px; border-bottom: 1px solid var(--line); padding: 16px 4px 0; }
.bar-column { min-width: 20px; height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.bar-value { color: #bde8cf; font-size: 9px; }
.bar { width: min(100%, 42px); min-height: 2px; border-radius: 8px 8px 2px 2px; background: linear-gradient(#9aefbd, #31b978); box-shadow: 0 0 20px rgb(66 217 142 / 12%); }
.bar-label { color: var(--muted); font-size: 8px; white-space: nowrap; }
.metric-bars { display: grid; gap: 13px; }
.metric-row { display: grid; grid-template-columns: 92px 1fr 38px; align-items: center; gap: 8px; font-size: 11px; }
.metric-track { height: 9px; overflow: hidden; border-radius: 999px; background: rgb(255 255 255 / 6%); }
.metric-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3ed68a, #e6c56f); }
.user-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.user-table th, .user-table td { border-bottom: 1px solid var(--line); padding: 11px 8px; text-align: left; }
.user-table th { color: var(--muted); font-weight: 700; }
.user-table td:last-child, .user-table th:last-child { text-align: right; }
.user-table td:last-child { white-space: nowrap; }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { min-height: 240px; padding: 42px 8vw; }
  .login-art::before { font-size: 280px; }
  .login-panel { padding: 22px; }
  .shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 20px 10px; }
  .side-brand { justify-content: center; margin: 0 0 25px; }
  .side-brand div, .nav-label, .side-user { display: none; }
  .nav button { justify-content: center; padding: 8px; }
  .nav-icon { width: auto; }
  .hero-grid, .admin-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cosmetic-grid, .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .login-art { display: none; }
  .login-shell { display: block; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
  .login-panel { min-height: 100dvh; padding: 0; background: transparent; }
  .login-card { padding: 25px 20px; }
  .shell { display: block; padding-bottom: 78px; }
  .sidebar { position: fixed; z-index: 50; inset: auto 0 0; width: 100%; height: auto; display: block; border: 0; border-top: 1px solid var(--line); padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); backdrop-filter: blur(15px); }
  .side-brand, .side-user { display: none; }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .nav button { min-height: 55px; display: grid; place-items: center; gap: 1px; padding: 4px; font-size: 9px; }
  .nav-label { display: block; }
  .nav-icon { font-size: 17px; }
  .content { padding: max(20px, env(safe-area-inset-top)) 14px 28px; }
  .topbar { align-items: start; margin-bottom: 17px; }
  .status-pill { padding: 7px 9px; font-size: 9px; }
  .hero-card { min-height: 230px; padding: 21px; }
  .hero-grid, .mode-grid, .rules, .account-grid { grid-template-columns: 1fr; }
  .rank-card { display: none; }
  .section-head { margin-top: 23px; }
  .mode-card { min-height: 158px; }
  .cosmetic-grid { grid-template-columns: repeat(2, 1fr); }
  .queue-banner { align-items: start; }
  .queue-banner .btn { min-height: 38px; }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 24px 24px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .admin-top { height: 65px; padding: 0 14px; }
  .admin-actions { gap: 6px; }
  .admin-actions .locale-switch button { min-width: 29px; padding-inline: 5px; }
  .admin-actions .btn { min-width: 58px; padding-inline: 9px; }
  .admin-brand strong { font-size: 13px; }
  .admin-main { width: calc(100% - 28px); padding-top: 21px; }
  .admin-heading h1 { font-size: 24px; }
  .kpi-grid { gap: 8px; }
  .kpi { min-height: 105px; padding: 14px; }
  .kpi b { font-size: 25px; }
  .chart-card { padding: 15px; overflow-x: auto; }
  .bar-chart { min-width: 540px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .shell { display: block; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; z-index: 50; inset: auto 0 0; width: 100%; height: auto; display: block; border: 0; border-top: 1px solid var(--line); padding: 5px max(10px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); backdrop-filter: blur(15px); }
  .side-brand, .side-user { display: none; }
  .nav { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .nav button { min-height: 50px; display: grid; place-items: center; gap: 0; padding: 3px 6px; font-size: 9px; text-align: center; }
  .nav-label { display: block; }
  .nav-icon { width: auto; font-size: 15px; }
  .content { padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 22px max(16px, env(safe-area-inset-left)); }
  .topbar { margin-bottom: 14px; }
  .hero-card { min-height: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
