:root {
  --ink: #141833;
  --ink-soft: #4a5070;
  --paper: #ffffff;
  --paper-2: #f3f5fb;
  --line: #e3e7f2;
  --glass: rgba(12, 16, 42, 0.52);
  --glass-line: rgba(255, 255, 255, 0.16);
  --hot-1: #ff8a3d;
  --hot-2: #ff3d6e;
  --gold: #f5b301;
  --good: #17b26a;
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #79c6f0;
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body.game { user-select: none; -webkit-user-select: none; }

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

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 46px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 0 rgba(10, 14, 40, 0.18), 0 8px 24px rgba(10, 14, 40, 0.12);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10, 14, 40, 0.18); }
.btn.primary {
  background: linear-gradient(135deg, var(--hot-1), var(--hot-2));
  color: #fff;
  box-shadow: 0 5px 0 #b8264d, 0 12px 28px rgba(255, 61, 110, 0.35);
}
.btn.primary:active { box-shadow: 0 2px 0 #b8264d; }
.btn.big { font-size: 20px; padding: 16px 26px; min-height: 60px; }
.btn.ghost { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: none; border: 1px solid var(--glass-line); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #000; }
.btn.gold { background: linear-gradient(135deg, #ffd452, #f5a300); color: #3b2600; box-shadow: 0 4px 0 #a86f00; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn.wide { width: 100%; }

.icon-btn {
  position: fixed;
  top: calc(12px + var(--safe-t));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 19px;
  display: grid;
  place-items: center;
  z-index: 6;
}
#mute { right: 12px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > .square { flex: 0 0 54px; padding: 0; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: #10142b; color: #fff; padding: 24px; text-align: center; }

/* ---------------------------------------------------------------- HUD */

#hud {
  position: fixed;
  top: calc(18px + var(--safe-t));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 3;
}
#score {
  font-size: clamp(64px, 16vw, 110px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(10, 14, 40, 0.28), 0 0 18px rgba(10, 14, 40, 0.35), 0 10px 30px rgba(10, 14, 40, 0.3);
  font-variant-numeric: tabular-nums;
}
#score.bump { animation: bump 0.18s ease-out; }
@keyframes bump { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
#hud-zone {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 800;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 10px rgba(0, 0, 0, 0.35);
}
#combo {
  margin-top: 10px;
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--hot-2);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s;
}
#combo.on { opacity: 1; transform: none; }

#banner {
  position: fixed;
  left: 50%;
  top: calc(160px + var(--safe-t));
  transform: translate(-50%, -20px);
  opacity: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 4;
  white-space: nowrap;
  transition: opacity 0.25s, transform 0.25s;
}
#banner.on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- menu */

.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(20px + var(--safe-t)) 16px calc(16px + var(--safe-b));
}

#menu { justify-content: space-between; }

.logo { text-align: center; margin-top: 4vh; pointer-events: none; }
.logo h1 {
  margin: 0;
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-shadow: 0 5px 0 rgba(10, 14, 40, 0.16), 0 14px 40px rgba(10, 14, 40, 0.25);
}
.logo h1 span { display: block; }
.logo .l1 { font-size: clamp(54px, 15vw, 92px); }
.logo .l2 {
  font-size: clamp(34px, 9.5vw, 58px);
  color: #fff4e6;
  text-shadow: 0 4px 0 rgba(10, 14, 40, 0.16), 0 12px 32px rgba(255, 120, 80, 0.35);
}
.tagline { margin: 12px 0 0; font-weight: 800; font-size: 16px; opacity: 0.92; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25); }

.menu-bottom { width: 100%; max-width: 420px; display: grid; gap: 12px; }

.card {
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  text-align: left;
  padding: 14px 16px;
}
button.card { width: 100%; }
.daily { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; }
.daily .ico { grid-row: span 2; font-size: 30px; }
.daily b { font-size: 17px; font-weight: 900; }
.daily small { font-size: 13px; opacity: 0.85; font-weight: 700; }
.daily .go { grid-row: span 2; font-weight: 900; font-size: 22px; opacity: 0.8; }
.daily.done { opacity: 0.7; }

.meta-row { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; opacity: 0.95; padding: 0 6px; }
.meta-row .dot { opacity: 0.5; }

.challenge-banner {
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.95), rgba(255, 61, 110, 0.95));
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 30px rgba(255, 61, 110, 0.3);
}

html[data-portal] .links, html[data-portal] #over-sponsor { display: none !important; }
.links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; font-weight: 700; opacity: 0.8; }
.links a { text-decoration: none; }
.links a:hover { text-decoration: underline; }
.biz { margin: 0; font-size: 10px; line-height: 1.5; text-align: center; opacity: 0.7; word-break: keep-all; }

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }

/* ---------------------------------------------------------- game over */

#over { justify-content: flex-end; pointer-events: none; }
.over-card {
  pointer-events: auto;
  width: 100%;
  max-width: 440px;
  border-radius: 26px;
  padding: 18px 16px 16px;
  background: rgba(10, 13, 36, 0.72);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 32px - var(--safe-t) - var(--safe-b));
  overflow-y: auto;
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.over-line:empty { display: none; }
@media (min-width: 860px) {
  #over { justify-content: center; align-items: flex-end; padding-right: max(24px, 7vw); }
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.over-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.over-mode { font-size: 13px; font-weight: 800; opacity: 0.8; }
.over-score { font-size: 64px; font-weight: 900; line-height: 0.95; font-variant-numeric: tabular-nums; }
.over-score small { font-size: 18px; font-weight: 800; opacity: 0.7; margin-left: 4px; }
.over-side { text-align: right; font-weight: 800; font-size: 14px; display: grid; gap: 4px; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd452, #f5a300);
  color: #3b2600;
}
.over-line { font-weight: 800; font-size: 15px; }
.over-line.muted { opacity: 0.7; font-size: 13px; }

.sponsor-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  text-decoration: none;
  color: #fff;
}
.sponsor-card .sw { width: 34px; height: 22px; border-radius: 11px; flex: none; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2); }
.sponsor-card .tx { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
.sponsor-card .tx b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sponsor-card .tag { font-size: 10px; font-weight: 900; opacity: 0.6; letter-spacing: 0.08em; text-transform: uppercase; }

.upsell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 212, 82, 0.2), rgba(255, 61, 110, 0.2));
  border: 1px solid rgba(255, 212, 82, 0.4);
  text-align: left;
  width: 100%;
  font-weight: 800;
  font-size: 14px;
}
.upsell canvas { width: 44px; height: 52px; flex: none; }

/* -------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 10, 30, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  -webkit-overflow-scrolling: touch;
  user-select: text;
  -webkit-user-select: text;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
  .sheet { border-radius: 24px; }
}
#modal-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#modal-body > h3 { margin-bottom: -2px; }
a.btn { text-decoration: none; }
.center { display: flex; justify-content: center; }
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 900; }
.sheet h3 { margin: 18px 0 8px; font-size: 15px; font-weight: 900; }
.sheet p { color: var(--ink-soft); line-height: 1.5; margin: 6px 0; }
.sheet .close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}
.sheet .btn { box-shadow: 0 3px 0 rgba(10, 14, 40, 0.15); background: var(--paper-2); }
.sheet .btn.primary { background: linear-gradient(135deg, var(--hot-1), var(--hot-2)); box-shadow: 0 4px 0 #b8264d; }
.sheet .btn.gold { background: linear-gradient(135deg, #ffd452, #f5a300); box-shadow: 0 4px 0 #a86f00; }
.sheet .btn.dark { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #000; }

.tabs { display: flex; gap: 6px; background: var(--paper-2); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px; font-weight: 800; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(10, 14, 40, 0.1); }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; font-weight: 800; }
.board li:nth-child(odd) { background: var(--paper-2); }
.board li.me { background: #fff1e6; outline: 2px solid var(--hot-1); }
.board .rk { color: var(--ink-soft); text-align: center; }
.board li:nth-child(1) .rk { color: #d49b00; }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .nm.sup { color: #c88400; }
.board .sc { font-variant-numeric: tabular-nums; }
.board .empty { text-align: center; color: var(--ink-soft); padding: 24px; display: block; }

.supporter-card {
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(135deg, #2b1f63, #6b2a8f 60%, #d9486e);
  color: #fff;
  display: grid;
  gap: 8px;
}
.supporter-card p { color: rgba(255, 255, 255, 0.85); margin: 0; }
.supporter-card b { font-size: 18px; }

.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.skin {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 8px 6px 10px;
  background: #fff;
  display: grid;
  justify-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink);
}
.skin canvas { width: 72px; height: 84px; }
.skin.on { border-color: var(--hot-1); box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.2); }
.skin .price { font-size: 12px; color: var(--ink-soft); }
.skin .price.own { color: var(--good); }

.providers { display: grid; gap: 10px; }
.provider {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 800;
  color: var(--ink);
  text-align: left;
}
.provider:hover { border-color: var(--hot-1); }
.provider .amt { font-variant-numeric: tabular-nums; }
.fine { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 10px; }

.field { display: grid; gap: 6px; margin: 10px 0; }
.field label { font-weight: 800; font-size: 13px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fff;
}
.field input:focus { border-color: var(--hot-1); outline: none; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--paper-2);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  font-size: 18px;
}

.share-preview { width: 100%; border-radius: 16px; display: block; box-shadow: 0 10px 30px rgba(10, 14, 40, 0.15); background: var(--paper-2); aspect-ratio: 4 / 5; object-fit: cover; }
.intents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.intents a { text-decoration: none; }
.grid-text { white-space: pre; font-size: 13px; line-height: 1.25; background: var(--paper-2); padding: 10px; border-radius: 12px; overflow-x: auto; }

.howto { padding-left: 20px; line-height: 1.7; color: var(--ink-soft); }
.progress { height: 10px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #ff9ec4, #ff5c8a); border-radius: 99px; }

/* -------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(14, 18, 44, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  z-index: 30;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100% - 32px);
  text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--hot-2); animation: spin 0.8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-height: 640px) {
  .logo { margin-top: 1vh; }
  .logo .l1 { font-size: 48px; }
  .logo .l2 { font-size: 30px; }
  .over-score { font-size: 52px; }
}
