:root {
  --bg: #0c1020;
  --fg: #f3ead8;
  --muted: #9aa3b8;
  --accent: #ffb347;
  --card: #161c30;
  --line: #2c3654;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---- HUD ---- */
#hud { position: fixed; left: 0; right: 0; top: 0; padding-top: env(safe-area-inset-top); pointer-events: none; }
.xpbar { height: 8px; background: #0008; border-bottom: 1px solid #fff2; }
#xpfill { height: 100%; width: 0; background: linear-gradient(90deg, #6ec6ff, #a98bff); transition: width .1s; }
.hudrow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 60px 0 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px #000;
}
#time { font-size: 20px; }
.slots { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; max-width: 70vw; }
.slot { font-size: 13px; background: #0009; border: 1px solid #fff2; border-radius: 6px; padding: 1px 5px; }
.slot.dim { border-style: dashed; }
.iconbtn {
  pointer-events: auto; position: absolute; right: 10px; top: calc(14px + env(safe-area-inset-top));
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid #fff3; background: #000a; color: var(--fg); font-size: 15px;
}

/* ---- 画面（タイトル・レベルアップ・一時停止・結果）---- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  text-align: center; overflow-y: auto;
}
.screen.dim { background: rgba(5, 7, 16, .74); }
h1 { font-size: clamp(34px, 11vw, 72px); margin: 0; letter-spacing: .06em; color: var(--accent); text-shadow: 0 0 28px #ffb34777; }
h2 { font-size: 28px; margin: 0; }
.eyebrow { margin: 0; letter-spacing: .4em; font-size: 12px; color: var(--muted); }
.sub { margin: 0; color: var(--muted); }
.screen > button {
  min-width: 220px; padding: 13px 24px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); font-size: 17px; font-weight: 700;
}
.screen > button.primary { background: var(--accent); color: #2a1600; border-color: transparent; }
.screen > button:focus-visible, .choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.ver { margin: 0; color: #5b6480; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; width: min(440px, 100%); }
.stats:empty { display: none; }
.stat { background: #0009; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .new { color: var(--accent); font-size: 11px; font-weight: 700; }

.choices { display: flex; flex-direction: column; gap: 10px; width: min(440px, 100%); }
.choice {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
.choice:hover { border-color: var(--accent); }
.choice .ic { font-size: 28px; width: 40px; text-align: center; flex: none; }
.choice .body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.choice .nm { font-weight: 700; font-size: 17px; }
.choice .lv { color: var(--accent); font-size: 13px; margin-left: 8px; }
.choice .ds { color: var(--muted); font-size: 14px; }
.choice .key { color: #5b6480; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; flex: none; }
@media (pointer: coarse) { .choice .key { display: none; } }
