:root {
  --bg: #0a1020;
  --bg2: #0f1830;
  --panel: #131e38;
  --panel2: #18264a;
  --line: #24365f;
  --text: #e8eefc;
  --muted: #8d9cc2;
  --cyan: #3ee0ff;
  --gold: #ffc830;
  --green: #3ddc84;
  --red: #ff5a6e;
  --orange: #ff9f43;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16305e 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #1a1d4a 0%, transparent 55%), var(--bg);
  color: var(--text); min-height: 100vh;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 12px 24px; background: rgba(10, 16, 32, .82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 40px; height: 27px; color: var(--cyan); }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tabs button { background: none; border: 0; padding: 8px 14px; border-radius: 10px; color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button:hover { color: var(--text); background: var(--panel); }
.tabs button.active { color: var(--bg); background: var(--cyan); }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.account #username { color: var(--text); font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 80px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }
.noscript { text-align: center; color: var(--red); }

h1 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; letter-spacing: .5px; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.lead { color: var(--muted); font-size: 16px; margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 16px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); }

.card { background: linear-gradient(180deg, var(--panel) 0%, var(--bg2) 100%); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stack > * + * { margin-top: 16px; }

button.primary, button.ghost, button.danger, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 9px 16px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: transform .05s, background .15s, border-color .15s; white-space: nowrap;
}
button.primary { background: var(--cyan); color: #041422; }
button.primary:hover { background: #7aeaff; }
button.ghost, a.button { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover, a.button:hover { border-color: var(--cyan); text-decoration: none; }
button.danger { background: transparent; color: var(--red); border-color: rgba(255, 90, 110, .35); }
button.danger:hover { background: rgba(255, 90, 110, .1); }
button.small, a.button.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(62, 224, 255, .15); }
.field + .field { margin-top: 14px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }
.error { color: var(--red); font-size: 14px; min-height: 1.4em; margin-top: 10px; }

/* auth */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; padding: 30px 0; }
.hero h1 span { color: var(--cyan); }
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps b { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); color: var(--cyan); border: 1px solid var(--line); font-size: 14px; }
.steps div { padding-top: 3px; }
.steps strong { display: block; }
.steps span { color: var(--muted); font-size: 14px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.seg button { flex: 1; background: none; border: 0; padding: 8px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--panel2); color: var(--text); }
.banner { border: 1px solid rgba(255, 200, 48, .4); background: rgba(255, 200, 48, .08); color: #ffe6a3; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; font-size: 14px; }

/* handheld art */
.handheld { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1.9; margin: 30px 0 0; border-radius: 120px; background: linear-gradient(160deg, #233863, #121c36); border: 2px solid #2d4677; box-shadow: 0 30px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08); }
.handheld .screen { position: absolute; left: 27%; right: 27%; top: 14%; bottom: 14%; border-radius: 8px; background: #060b16; border: 3px solid #0b1222; overflow: hidden; }
.handheld .screen::before { content: "NEW GAME FROM YOUR AI STUDIO"; position: absolute; left: 8%; right: 8%; top: 22%; padding: 10% 4%; text-align: center; font: 700 9px/1.5 var(--mono); color: var(--gold); border: 1px solid var(--cyan); border-radius: 4px; background: rgba(62, 224, 255, .08); }
.handheld .screen::after { content: "A INSTALL     B LATER"; position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font: 600 8px var(--mono); color: var(--cyan); }
.handheld .dpad { position: absolute; left: 9%; top: 34%; width: 12%; aspect-ratio: 1; }
.handheld .dpad::before, .handheld .dpad::after { content: ""; position: absolute; background: #0b1222; border-radius: 3px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
.handheld .dpad::before { left: 33%; right: 33%; top: 0; bottom: 0; }
.handheld .dpad::after { top: 33%; bottom: 33%; left: 0; right: 0; }
.handheld .abxy { position: absolute; right: 8%; top: 30%; width: 14%; aspect-ratio: 1; }
.handheld .abxy i { position: absolute; width: 34%; aspect-ratio: 1; border-radius: 50%; }
.handheld .abxy i:nth-child(1) { left: 33%; top: 0; background: #3ee0ff; }
.handheld .abxy i:nth-child(2) { right: 0; top: 33%; background: #ff5a6e; }
.handheld .abxy i:nth-child(3) { left: 33%; bottom: 0; background: #3ddc84; }
.handheld .abxy i:nth-child(4) { left: 0; top: 33%; background: #ffc830; }

/* lists */
.list { display: grid; gap: 12px; }
.item { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #4b5878; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(61, 220, 132, .15); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--green); border-color: rgba(61, 220, 132, .35); background: rgba(61, 220, 132, .08); }
.badge.wait { color: var(--gold); border-color: rgba(255, 200, 48, .35); background: rgba(255, 200, 48, .08); }
.badge.bad { color: var(--red); border-color: rgba(255, 90, 110, .35); background: rgba(255, 90, 110, .08); }
.badge.info { color: var(--cyan); border-color: rgba(62, 224, 255, .35); background: rgba(62, 224, 255, .08); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* pair */
.pair-card h2 { display: flex; align-items: center; gap: 10px; }
.code-input { font: 700 30px/1 var(--mono) !important; letter-spacing: 12px; text-align: center; padding: 14px !important; }
.howto { counter-reset: n; list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
.howto li { counter-increment: n; position: relative; padding-left: 32px; }
.howto li::before { content: counter(n); position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); color: var(--cyan); font-size: 12px; font-weight: 700; }
.kbd { display: inline-block; line-height: 1.5; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; font: 600 12px var(--mono); color: var(--text); background: var(--bg); }

/* games */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; cursor: pointer; }
.drop.over { border-color: var(--cyan); background: rgba(62, 224, 255, .06); color: var(--text); }
.drop strong { color: var(--text); }
.game { display: block; padding: 0; overflow: hidden; }
.game > .head { display: flex; gap: 16px; align-items: center; padding: 16px 18px; }
.game .icon { flex: none; width: 52px; height: 39px; border-radius: 8px; background: linear-gradient(135deg, #24407a, #142142); display: grid; place-items: center; font: 800 16px var(--mono); color: var(--cyan); border: 1px solid var(--line); }
.game .detail { border-top: 1px solid var(--line); padding: 14px 18px 18px; background: rgba(0, 0, 0, .15); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: 0; }
.report-errors { margin: 10px 0 0; padding-left: 18px; color: var(--red); font-size: 14px; }
.report-warnings { margin: 6px 0 0; padding-left: 18px; color: var(--gold); font-size: 14px; }

/* ai */
.token-new { border: 1px solid rgba(61, 220, 132, .4); background: rgba(61, 220, 132, .07); border-radius: 12px; padding: 14px; margin-top: 14px; }
.copy { position: relative; }
.copy pre { margin: 0; padding-right: 74px !important; background: #070c18; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; color: #cfe6ff; }
.copy button { position: absolute; top: 8px; right: 8px; }
.ai-steps { display: grid; gap: 16px; }
.ai-step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; }
.ai-step > b { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--cyan); color: #041422; font-weight: 800; }
.prompt-list { display: grid; gap: 8px; margin-top: 8px; }
.prompt-list div { background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.tool-grid div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.tool-grid code { color: var(--cyan); display: block; margin-bottom: 2px; }
.switch { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.switch button { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.switch button.active { border-color: var(--cyan); color: var(--cyan); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255, 90, 110, .5); color: #ffc2ca; }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand span { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tabs button { flex: 1; }
  main { padding: 18px 16px 60px; }
  .hero { grid-template-columns: 1fr; gap: 20px; padding: 6px 0; }
  .hero .handheld { display: none; }
  h1 { font-size: 26px; }
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-start; }
  .game > .head { flex-wrap: wrap; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}
