:root {
  --bg: #0a0f24; --surface: #121a3a; --surface-2: #192350; --border: #2a3564;
  --text: #f2f4ff; --muted: #aab2d5; --violet: #6a47f5; --violet-soft: #9b86ff;
  --lime: #c6f432; --danger: #ff7a90;
  --nav-h: 64px; --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.app {
  max-width: 480px; min-height: 100dvh; margin: 0 auto;
  padding: calc(var(--st) + 8px) 16px calc(var(--nav-h) + var(--sb) + 28px);
}
@media (min-width: 520px) { .app { border-inline: 1px solid var(--border); } }

.topbar { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-bottom: 8px; }
.logo { width: 32px; height: 32px; }
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: .01em; }

h1 { font-size: clamp(1.45rem, 6.5vw, 1.8rem); line-height: 1.2; letter-spacing: -.01em; margin-top: 6px; overflow-wrap: anywhere; }
h3 { font-size: 1.05rem; }
.section-title { font-size: 1.05rem; margin: 26px 0 10px; }
.lead { color: var(--muted); margin-top: 8px; }
.muted { color: var(--muted); font-size: 1rem; }
.block { margin-top: 18px; }
.view:not([hidden]) { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.stack { display: grid; gap: 10px; margin-top: 20px; }
.grid { display: grid; gap: 10px; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; text-align: center;
  transition: background .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--violet); color: #fff; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-danger { background: transparent; border-color: rgba(255,122,144,.5); color: var(--danger); }
.btn:disabled { background: #151d40; border-color: var(--border); color: #8a93b8; cursor: not-allowed; }
@media (hover: hover) {
  .btn-primary:hover { background: #7b5cff; }
  .btn-secondary:hover { background: #222e63; }
  .btn-danger:hover { background: rgba(255,122,144,.1); }
  .game-card:hover { border-color: var(--violet-soft); }
}
.btn-primary:active:not(:disabled) { background: #5636d8; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); background: rgba(255,255,255,.03);
}
.chip-soon, .chip-rec { color: var(--lime); border-color: rgba(198,244,50,.45); background: transparent; }
.chip-status { color: #d4cbff; border-color: rgba(155,134,255,.5); background: rgba(106,71,245,.15); }

.art {
  display: block; background: linear-gradient(145deg, #1e2a68, #141b40);
  border-radius: 14px; overflow: hidden;
}
.art svg { display: block; width: 100%; height: 100%; }
.art-wide { width: 100%; aspect-ratio: 16 / 9; }
#detail-art { margin-top: 10px; border: 1px solid var(--border); }

.featured { overflow: hidden; background: linear-gradient(160deg, #271c6c, var(--surface) 65%); border-color: #43399c; }
.featured .art { border-radius: 0; }
.featured-body { padding: 16px; display: grid; gap: 8px; justify-items: start; }
.featured-body .chips { margin: 0; }
.featured-body h2 { font-size: 1.35rem; }
.featured-body .btn { margin-top: 6px; }

.game-card {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center;
  width: 100%; min-height: 96px; padding: 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.game-card:active { background: var(--surface-2); }
.game-card .art { width: 72px; height: 72px; border-radius: 12px; }
.game-card .name { display: block; font-weight: 700; }
.game-card .desc { display: block; color: var(--muted); font-size: .9375rem; line-height: 1.35; margin: 2px 0 6px; }
.game-card .chips { margin: 0; }

.teaser {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; align-items: center;
  margin-top: 26px; padding: 16px; border-radius: 18px; border: 1px solid #43399c;
  background: linear-gradient(135deg, #2a1d7a, #0f2a4f);
}
.teaser-title { font-size: 1.2rem; margin: 8px 0 4px; }
.teaser-art { width: 84px; height: 84px; }
.teaser-btn { grid-column: 1 / -1; }

.back-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px 0 6px;
  background: none; border: 0; border-radius: 12px; color: var(--violet-soft); font-weight: 600;
}
.rules { list-style: none; counter-reset: r; padding: 6px 16px; }
.rules li { counter-increment: r; display: flex; gap: 12px; padding: 10px 0; }
.rules li + li { border-top: 1px solid var(--border); }
.rules li::before {
  content: counter(r); flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--violet);
}
.record-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.notice {
  margin-top: 16px; padding: 12px 14px; border-radius: 14px; font-size: 1rem;
  border: 1px solid rgba(155,134,255,.4); background: rgba(106,71,245,.12);
}
.notice.warn { border-color: rgba(255,122,144,.5); background: rgba(255,122,144,.08); }

.arena-hero { margin-top: 10px; height: 170px; border-radius: 18px; overflow: hidden; border: 1px solid var(--border); }
.arena-hero svg { display: block; width: 100%; height: 100%; }
.mode { padding: 16px; display: grid; gap: 10px; }
.mode-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.profile-head { display: flex; align-items: center; gap: 14px; padding: 16px; margin-top: 10px; }
.profile-head > div:last-child { min-width: 0; }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  font-size: 1.4rem; font-weight: 800; background: linear-gradient(145deg, var(--violet), #3b2aa8);
}
.list { list-style: none; padding: 0 16px; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; min-height: 48px; }
.list li + li { border-top: 1px solid var(--border); }
.list .empty { color: var(--muted); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
.setting-name { font-weight: 600; }
.switch {
  position: relative; flex: none; width: 52px; height: 30px; padding: 0; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); transition: background .15s;
}
.switch::before { content: ""; position: absolute; inset: -8px; }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #cfd5f2; transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--violet); border-color: var(--violet); }
.switch[aria-checked="true"] .knob { transform: translateX(22px); background: #fff; }

.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 10;
  width: min(100%, 480px); display: grid; grid-template-columns: repeat(3, 1fr);
  padding-bottom: var(--sb); background: rgba(14,20,48,.98); border-top: 1px solid var(--border);
}
.nav-btn {
  position: relative; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; background: none; border: 0; color: var(--muted);
  font-size: .76rem; font-weight: 600;
}
.nav-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.nav-btn.is-active { color: var(--text); }
.nav-btn.is-active svg { color: var(--violet-soft); }
.nav-btn.is-active::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--lime);
}

.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,7,20,.72); }
.modal-card {
  position: relative; width: min(100%, 480px); max-height: 88dvh; overflow-y: auto;
  padding: 22px 18px calc(18px + var(--sb)); background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px 22px 0 0;
}
@media (min-width: 520px) { .modal { align-items: center; } .modal-card { border-radius: 22px; } }
.modal-card h2 { font-size: 1.25rem; padding-right: 48px; }
#modal-body { display: grid; gap: 10px; margin-top: 12px; color: var(--muted); }
.icon-btn {
  position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border);
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sb) + 14px); z-index: 30;
  transform: translate(-50%, 10px); width: max-content; max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 14px; background: #232e66; border: 1px solid var(--violet-soft);
  font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 340px) {
  .app { padding-inline: 12px; }
  .game-card { grid-template-columns: 60px minmax(0, 1fr); }
  .game-card .art { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}