*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body.game-page {
  --top-h: 56px;
  --hud-h: 46px;
  --pad-h: 0px;
  background: radial-gradient(120% 70% at 50% 0%, #121633 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
@media (pointer: coarse), (max-width: 760px) { body.game-page { --pad-h: 150px; } }

.g-top {
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-left));
}
.g-home { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-size: 20px; letter-spacing: .02em; }
.g-home img { width: 40px; height: 40px; object-fit: contain; }
.g-btn-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--panel-line); color: var(--text); cursor: pointer;
}
.g-btn-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.g-btn-icon .spk { fill: currentColor; }
.g-btn-icon[aria-pressed="false"] .on { display: none; }
.g-btn-icon[aria-pressed="true"] .off { display: none; }
.g-btn-icon[aria-pressed="true"] { color: var(--green); border-color: rgba(61,255,110,.4); }

.g-main {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0 8px max(8px, env(safe-area-inset-bottom));
  --stage-w: min(calc(100vw - 16px), calc((100dvh - var(--top-h) - var(--hud-h) - 24px - var(--pad-h) - 22px) * 0.75), 640px);
}

.g-hud {
  width: var(--stage-w); height: var(--hud-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  font-family: var(--font-arcade);
}
.hud-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hud-mid { align-items: center; }
.hud-right { align-items: flex-end; }
.hud-k { font-size: 8px; color: var(--muted); letter-spacing: .12em; }
.hud-v { font-size: clamp(11px, 2.6vw, 15px); color: var(--text); white-space: nowrap; }
.hud-left .hud-v { color: var(--green); text-shadow: 0 0 10px rgba(61,255,110,.45); }
.hud-right .hud-v { color: var(--gold); }
.hud-v.bump { animation: hudbump .35s var(--ease); }
@keyframes hudbump { 40% { transform: scale(1.18); } }

.g-stage {
  position: relative; width: var(--stage-w); aspect-ratio: 9 / 12;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(61,255,110,.25), 0 0 40px rgba(61,255,110,.12), 0 30px 80px rgba(0,0,0,.6);
  background: #070912;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#game { display: block; width: 100%; height: 100%; }

.g-status { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; pointer-events: none; }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px 5px 5px; border-radius: 999px; font-family: var(--font-arcade); font-size: 8px; background: rgba(5,6,11,.75); border: 1px solid var(--panel-line); }
.st img { width: 20px; height: 20px; object-fit: contain; }
.st-shield { color: var(--blue); }
.st-speed { color: var(--gold); }

/* overlays */
.g-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(80% 60% at 50% 45%, rgba(5,6,11,.74), rgba(5,6,11,.93));
  opacity: 0; visibility: hidden; transition: opacity .18s ease, visibility 0s linear .18s;
}
.g-overlay.is-open { opacity: 1; visibility: visible; transition: opacity .18s ease; }
.ov-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 360px; }
.ov-logo { width: min(62%, 260px); height: auto; filter: drop-shadow(0 10px 30px rgba(61,255,110,.25)); }
.ov-tag { margin: 0; font-family: var(--font-display); font-size: clamp(20px, 5vw, 28px); line-height: 1.05; letter-spacing: .02em; }
.ov-hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.kb { font-family: var(--font-arcade); font-size: 9px; padding: 3px 6px; border: 1px solid var(--panel-line); border-radius: 6px; color: var(--text); }

.btn-arcade {
  font-family: var(--font-arcade); font-size: 14px; letter-spacing: .06em;
  color: #031006; background: linear-gradient(180deg, #7dff9c, var(--green) 45%, var(--green-deep));
  border: 0; border-radius: 14px; padding: 16px 26px; min-height: 52px; cursor: pointer;
  box-shadow: 0 6px 0 #0a6e27, 0 0 28px rgba(61,255,110,.45);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn-arcade:active { transform: translateY(4px); box-shadow: 0 2px 0 #0a6e27, 0 0 18px rgba(61,255,110,.35); }
.btn-arcade:focus-visible, .btn-ghost:focus-visible, .pad-btn:focus-visible, .g-btn-icon:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn-ghost { color: var(--muted); font-family: var(--font-arcade); font-size: 10px; text-decoration: none; padding: 12px 16px; }
.btn-ghost:hover { color: var(--text); }

.ov-rekt-frog { width: 110px; height: auto; animation: spin-in .5s var(--ease) both; }
@keyframes spin-in { from { transform: rotate(-30deg) scale(.4); opacity: 0; } }
.rekt-title {
  margin: 0; font-family: var(--font-display); font-size: clamp(64px, 18vw, 104px); line-height: .9;
  color: var(--red); text-shadow: 0 0 24px rgba(255,59,59,.55), 0 5px 0 #6b0b0b;
  animation: slam .45s var(--ease) both;
}
@keyframes slam { from { transform: scale(2.2); opacity: 0; } }
.rekt-by { margin: 0; font-family: var(--font-arcade); font-size: 10px; color: var(--muted); line-height: 1.6; }
.rekt-new { margin: 0; font-family: var(--font-arcade); font-size: 11px; color: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.rekt-stats { display: flex; gap: 24px; margin: 4px 0 6px; font-family: var(--font-arcade); }
.rekt-stats div { display: flex; flex-direction: column; gap: 6px; }
.rekt-stats dt { font-size: 8px; color: var(--muted); }
.rekt-stats dd { margin: 0; font-size: 16px; }

/* touch pad */
.g-pad {
  display: none; width: var(--stage-w); height: calc(var(--pad-h) - 8px); margin-top: 8px;
  grid-template-columns: 1fr 1.1fr 1fr .9fr; grid-template-rows: 1fr 1fr; gap: 8px;
  grid-template-areas: "l u r p" "l d r p";
}
@media (pointer: coarse), (max-width: 760px) { .g-pad { display: grid; } }
.pad-btn {
  border: 1px solid rgba(61,255,110,.28); border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, rgba(30,36,64,.85), rgba(12,14,28,.92));
  color: var(--green); display: grid; place-items: center;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.pad-btn svg { width: 34px; height: 34px; fill: currentColor; filter: drop-shadow(0 0 8px rgba(61,255,110,.5)); }
.pad-btn.is-down { background: rgba(61,255,110,.22); transform: scale(.97); }
.pad-p { grid-area: p; position: relative; border-color: rgba(255,201,60,.35); }
.pad-p img { width: 40px; height: 40px; object-fit: contain; }
.pad-p:disabled { opacity: .35; }
.pad-u { grid-area: u; } .pad-d { grid-area: d; } .pad-l { grid-area: l; } .pad-r { grid-area: r; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===================== progression UI ===================== */
.g-top-actions { display: flex; gap: 8px; align-items: center; }
.g-btn-pill {
  height: 44px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  font-family: var(--font-arcade); font-size: 10px; letter-spacing: .06em; color: var(--green);
  background: var(--panel); border: 1px solid rgba(61,255,110,.35);
}
.g-btn-pill:hover { background: rgba(61,255,110,.12); }

.g-xp { width: var(--stage-w); height: 22px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-bottom: 4px; font-family: var(--font-arcade); }
.xp-lv { font-size: 10px; color: var(--gold); }
.xp-num { font-size: 8px; color: var(--muted); white-space: nowrap; }
.xp-bar { position: relative; display: block; height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; border: 1px solid rgba(255,201,60,.25); }
.xp-bar-lg { height: 12px; }
.xp-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--green), var(--gold)); box-shadow: 0 0 12px rgba(255,201,60,.6); transition: width .35s var(--ease); }

.st-slow { color: #c9a8ff; padding-left: 9px; }
.st-magnet { color: var(--gold); padding-left: 9px; }

.g-power {
  position: absolute; right: 10px; bottom: 10px; width: 62px; height: 62px; border-radius: 50%;
  border: 2px solid rgba(255,201,60,.55); background: rgba(5,6,11,.75); cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.g-power img { width: 38px; height: 38px; object-fit: contain; }
.g-power.is-cool img, .pad-p.is-cool img { filter: grayscale(1) brightness(.6); }
.g-power.is-ready, .pad-p.is-ready { box-shadow: 0 0 18px rgba(255,201,60,.55); }
.pw-ring { position: absolute; inset: -2px; border-radius: inherit; pointer-events: none; background: conic-gradient(rgba(255,201,60,.0) var(--p, 100%), rgba(5,6,11,.65) 0); }
.pw-key { position: absolute; right: -4px; top: -4px; font-family: var(--font-arcade); font-size: 8px; background: var(--gold); color: #1a1100; border-radius: 6px; padding: 3px 5px; }
@media (pointer: coarse), (max-width: 760px) { .g-power { display: none; } }

.toast {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 4;
  padding: 10px 14px; border-radius: 12px; background: rgba(5,6,11,.88); border: 1px solid rgba(255,201,60,.5);
  font-family: var(--font-arcade); font-size: 9px; line-height: 1.6; color: var(--gold); text-align: center; pointer-events: none;
  max-width: 88%; animation: toast-in .3s var(--ease);
}
.toast b { display: block; color: var(--text); font-weight: 400; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

.welcome { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; border-radius: 14px; background: rgba(255,201,60,.08); border: 1px solid rgba(255,201,60,.35); }
.wb-k { font-family: var(--font-arcade); font-size: 9px; color: var(--gold); }
.wb-v { font-family: var(--font-arcade); font-size: 8.5px; color: var(--text); line-height: 1.7; }

.g-celebrate {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: radial-gradient(60% 45% at 50% 45%, rgba(61,255,110,.22), rgba(5,6,11,.75));
  text-align: center; padding: 16px; animation: cel-in .35s var(--ease);
}
.g-celebrate.is-district { background: radial-gradient(60% 45% at 50% 45%, rgba(46,200,255,.2), rgba(5,6,11,.72)); }
@keyframes cel-in { from { opacity: 0; transform: scale(1.08); } }
.g-celebrate p { margin: 0; }
.cel-k { font-family: var(--font-arcade); font-size: clamp(10px, 2.8vw, 13px); color: var(--gold); letter-spacing: .1em; }
.cel-v { font-family: var(--font-display); font-size: clamp(42px, 12vw, 78px); line-height: .95; color: var(--green); text-shadow: 0 0 30px rgba(61,255,110,.6), 0 5px 0 #0a5e22; }
.g-celebrate.is-district .cel-v { color: var(--text); text-shadow: 0 0 30px var(--d-accent, #2ec8ff), 0 5px 0 rgba(0,0,0,.5); }
.cel-u { font-family: var(--font-arcade); font-size: 10px; color: var(--text); line-height: 1.8; }
.chip-share, .btn-share {
  font-family: var(--font-arcade); font-size: 10px; letter-spacing: .06em; cursor: pointer;
  color: var(--text); background: rgba(46,200,255,.12); border: 1px solid rgba(46,200,255,.6); border-radius: 12px; padding: 12px 16px; min-height: 44px;
}
.chip-share:hover, .btn-share:hover { background: rgba(46,200,255,.25); }
.btn-sm { padding: 10px 14px; min-height: 40px; font-size: 9px; }

.ov-rekt { gap: 8px; }
.rekt-stats { gap: 18px; }
.rekt-district { margin: 0; font-family: var(--font-arcade); font-size: 9px; color: var(--muted); }
.rekt-hl { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; width: 100%; max-height: 120px; overflow: auto; }
.rekt-hl li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: rgba(255,201,60,.08); border: 1px solid rgba(255,201,60,.25); font-family: var(--font-arcade); font-size: 8.5px; color: var(--gold); text-align: left; line-height: 1.5; }
.rekt-hl li button { flex: none; min-height: 32px; padding: 6px 10px; font-size: 8px; }
.rekt-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rekt-links { display: flex; gap: 4px; }
.ov-card .btn-ghost { background: none; border: 0; cursor: pointer; }

/* ===================== modals ===================== */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 12px; background: rgba(3,4,8,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, #121530, #0a0c18); border: 1px solid rgba(61,255,110,.3); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 40px rgba(61,255,110,.1); padding: 20px;
}
.modal-x { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--panel-line); background: var(--panel); color: var(--text); font-size: 24px; cursor: pointer; z-index: 2; }
.modal h2 { font-family: var(--font-display); font-weight: 400; margin: 0; font-size: 34px; }

.mp-head { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; align-items: center; margin-bottom: 14px; }
.mp-info { min-width: 0; }
.mp-preview { width: 200px; height: 200px; border-radius: 18px; background: radial-gradient(70% 70% at 50% 45%, rgba(61,255,110,.14), rgba(5,6,11,.4)); border: 1px solid var(--panel-line); }
.mp-evo { margin: 2px 0 10px; font-family: var(--font-arcade); font-size: 10px; color: var(--green); }
.mp-level { display: flex; justify-content: space-between; font-family: var(--font-arcade); font-size: 9px; margin-bottom: 6px; }
.mp-level span:first-child { color: var(--gold); }
.mp-level span:last-child { color: var(--muted); }
.mp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.mp-stats div { min-width: 0; overflow-wrap: anywhere; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--panel-line); }
.mp-stats dt { font-family: var(--font-arcade); font-size: 7px; color: var(--muted); margin-bottom: 5px; }
.mp-stats dd { margin: 0; font-family: var(--font-display); font-size: 17px; }
.mp-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.mp-tabs button { flex: none; font-family: var(--font-arcade); font-size: 9px; padding: 11px 12px; min-height: 40px; border-radius: 10px; cursor: pointer; color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--panel-line); }
.mp-tabs button[aria-selected="true"] { color: #031006; background: var(--green); border-color: var(--green); }
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 10px; border-radius: 14px; text-align: center; background: rgba(255,255,255,.035); border: 1px solid var(--panel-line); }
.item.is-equipped { border-color: var(--green); box-shadow: 0 0 18px rgba(61,255,110,.2); }
.item.is-locked { opacity: .6; }
.item canvas, .item img { width: 84px; height: 84px; object-fit: contain; }
.item .orb { width: 64px; height: 64px; margin: 10px; border-radius: 50%; }
.item-name { font-family: var(--font-arcade); font-size: 8.5px; line-height: 1.5; }
.item-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; min-height: 2.7em; }
.item button, .item .tag { font-family: var(--font-arcade); font-size: 8px; min-height: 36px; padding: 8px 10px; border-radius: 10px; width: 100%; }
.item button { cursor: pointer; color: #031006; background: var(--green); border: 0; }
.item button.is-on { background: transparent; color: var(--green); border: 1px solid var(--green); }
.item .tag { display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--panel-line); }
.item .tag.soon { color: var(--gold); border-color: rgba(255,201,60,.4); }
.ach { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.035); border: 1px solid var(--panel-line); margin-bottom: 8px; }
.ach.is-done { border-color: rgba(255,201,60,.5); }
.ach b { font-family: var(--font-arcade); font-size: 9px; font-weight: 400; color: var(--gold); }
.ach.is-locked b { color: var(--muted); }
.ach span { font-size: 14px; color: var(--muted); }
.ach em { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-family: var(--font-arcade); font-size: 8px; color: var(--muted); text-align: right; }
.ach.is-done em { color: var(--green); }
.prof-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.035); border: 1px solid var(--panel-line); margin-bottom: 8px; font-weight: 600; }
.prof-row small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.soon-tag { font-family: var(--font-arcade); font-size: 8px; color: var(--gold); border: 1px solid rgba(255,201,60,.4); border-radius: 8px; padding: 7px 9px; white-space: nowrap; }
.mp-h { font-family: var(--font-arcade); font-size: 9px; color: var(--muted); margin: 16px 0 8px; font-weight: 400; }
.mp-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.sh { width: min(680px, 100%); text-align: center; }
.sh-card { width: 100%; height: auto; aspect-ratio: 1200 / 630; border-radius: 14px; margin: 14px 0; border: 1px solid var(--panel-line); }
.sh-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sh-btn { display: grid; place-items: center; min-height: 50px; border-radius: 12px; font-family: var(--font-arcade); font-size: 9.5px; text-decoration: none; cursor: pointer; color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--panel-line); }
.sh-x { background: #000; border-color: #444; }
.sh-tg { background: #1d8fd6; border-color: #1d8fd6; }
.sh-btn:hover { filter: brightness(1.15); }
.sh-note { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

@media (max-width: 560px) {
  .mp-head { grid-template-columns: 1fr; gap: 10px; justify-items: center; text-align: center; }
  .mp-info { width: 100%; }
  .mp-preview { width: 150px; height: 150px; }
  .mp-stats dd { font-size: 15px; }
  .mp-level { gap: 8px; }
  .modal h2 { font-size: 26px; }
  .mp-stats { grid-template-columns: repeat(2, 1fr); }
  .mp-grid { grid-template-columns: repeat(2, 1fr); }
  .sh-btns { grid-template-columns: 1fr 1fr; }
  .g-home span { display: none; }
  .modal-card { padding: 16px 14px; }
}

.pad-p[data-locked]:not([data-locked=""])::after { content: attr(data-locked); font-family: var(--font-arcade); font-size: 7px; line-height: 1.6; color: var(--muted); text-align: center; padding: 0 4px; }
@media (max-height: 700px) and (pointer: coarse), (max-height: 700px) and (max-width: 760px) {
  body.game-page { --pad-h: 118px; --top-h: 50px; }
  .ov-logo { width: min(44%, 150px); }
  .ov-hint { display: none; }
  .ov-tag { font-size: 18px; }
  .ov-card { gap: 8px; }
  .btn-arcade { padding: 12px 20px; min-height: 46px; }
}
