:root {
  --text: #fff7ff;
  --muted: #d7c6f2;
  --gold: #ffd56a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  color: var(--text);
  font-family: "Trebuchet MS", ui-rounded, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  background: #10243a url("../assets/winter.jpg") center top / cover no-repeat fixed;
}
body[data-theme="vault"] {
  background: #140e06 url("../assets/theme-vault.jpg") center top / cover no-repeat fixed;
}
body[data-theme="harbor"] {
  background: #061820 url("../assets/theme-harbor.jpg") center top / cover no-repeat fixed;
}
body[data-theme="olympus"] {
  background: #1a1218 url("../assets/theme-olympus.jpg") center top / cover no-repeat fixed;
}
body[data-theme="nebula"] {
  background: #070814 url("../assets/theme-nebula.jpg") center center / cover no-repeat fixed;
}
body[data-theme="lantern"] {
  background: #140c08 url("../assets/theme-lantern.jpg") center top / cover no-repeat fixed;
}
body[data-theme="glacier"] {
  background: #061428 url("../assets/theme-glacier.jpg") center center / cover no-repeat fixed;
}
body[data-theme="reef"] {
  background: #042028 url("../assets/theme-reef.jpg") center center / cover no-repeat fixed;
}
body[data-theme="dune"] {
  background: #101018 url("../assets/theme-dune.jpg") center center / cover no-repeat fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6, 16, 36, 0.42), rgba(6, 16, 36, 0.04) 24%, rgba(6, 16, 36, 0.08) 68%, rgba(6, 16, 36, 0.32));
}
.wrap {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}
.top, .hint, #game { min-width: 0; max-width: 100%; }
.top {
  position: relative;
  z-index: 50;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: calc(10px + env(safe-area-inset-top)) 12px 6px;
  gap: 6px;
}
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 12px;
  white-space: nowrap;
  text-shadow: 0 2px 0 #5b1d8c, 0 8px 18px rgba(255, 90, 200, 0.45);
}
.brand img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
.stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 4px 5px;
  text-align: center;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(40, 12, 70, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 8px 16px rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
}
.stat b {
  display: block;
  font-size: 18px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 2px 0 #8a4b00;
}
.stat.gold {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px 7px;
  background: linear-gradient(180deg, #ffe9a8, #e0a020);
  border-color: rgba(255, 236, 170, 0.85);
}
.stat.gold b {
  flex: 0 0 auto;
  font-size: 20px;
  color: #4a2800;
  text-shadow: none;
}
.stat.gold span {
  color: #6b3d00;
  font-size: 13px;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.15;
}
a.stat { color: inherit; text-decoration: none; }
a.stat.gold { cursor: pointer; }
a.stat.gold span::after { content: " ›"; }
.stat span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
}
.combo {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  text-shadow: 0 0 12px #ff4fd0, 0 2px 0 #7a1570;
}
button {
  position: relative;
  z-index: 51;
  touch-action: manipulation;
  background: linear-gradient(180deg, #ff8ad8, #e23aa8);
  color: #fff;
  border: 0;
  border-radius: 999px;
  flex: 0 0 auto;
  padding: 8px 12px;
  font-weight: 900;
  box-shadow: 0 4px 0 #9b1d6c, 0 8px 16px rgba(226, 58, 168, 0.35);
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #9b1d6c; }
#restart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 5px 11px 4px;
  line-height: 1.05;
  font-size: 13px;
}
#restart span {
  color: #ffe08a;
  font-size: 11px;
  letter-spacing: 0.02em;
}
#restart.broke { opacity: 0.55; }
.hint {
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.35;
  color: #f3d7ff;
  text-shadow: 0 2px 8px rgba(80, 0, 80, 0.8);
  padding: 0 12px 4px;
}
a.ebit {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px 1px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #f0a202);
  color: #3a2200;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-shadow: none;
  box-shadow: 0 2px 0 #a86a00;
  pointer-events: auto;
  position: relative;
  z-index: 60;
  touch-action: manipulation;
}
a.ebit:active { transform: translateY(1px); }
#game {
  flex: 1 1 0;
  width: 100%;
  height: 0;
  min-height: 0;
  display: block;
  touch-action: none;
  position: relative;
  z-index: 1;
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(12, 4, 28, 0.45);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.overlay.show { display: flex; }
.overlay .card { pointer-events: auto; }
.ver {
  margin-left: 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #ffe9ff;
}
.card {
  background: linear-gradient(180deg, #3a1860, #1a0a32);
  border: 2px solid rgba(255, 180, 255, 0.35);
  border-radius: 28px;
  padding: 28px 22px;
  width: min(340px, 86vw);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  text-shadow: 0 3px 0 #5b1d8c;
}
.card p { color: var(--muted); margin: 0 0 18px; font-size: 16px; }
.card button { width: 100%; padding: 14px; font-size: 18px; margin-top: 8px; }
#continue { background: linear-gradient(180deg, #7dffc6, #1fb861); color: #04140c; box-shadow: 0 4px 0 #0f7a44, 0 8px 16px rgba(31,184,97,0.35); }
.level-pop { z-index: 40; pointer-events: auto; }
.level-pop a.partner {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #f0a202);
  color: #3a2200;
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
  text-shadow: none;
  box-shadow: 0 4px 0 #a86a00, 0 8px 16px rgba(240, 162, 2, 0.35);
}
.level-pop a.partner:active { transform: translateY(2px); }
#level-close {
  background: transparent;
  color: #f3d7ff;
  box-shadow: none;
}
