:root {
  --cream: #fff6e8;
  --ink: #1b2230;
  --night: #0d1524;
  --spark: #7fe3ff;
  --spark-deep: #2aa8d8;
  --loss: #ff6b74;
  --warm: #ffcf6b;
  --card: rgba(255, 248, 236, 0.96);
  --shadow: 0 14px 44px rgba(6, 12, 22, 0.45);
  font-family: "Zen Maru Gothic", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #060b14;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #060b14 0%, #0d1524 55%, #16243a 100%);
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 62%, rgba(127, 227, 255, 0.5), transparent 60%);
  opacity: 0;
  transition: opacity .1s linear;
}
.flash.is-on { opacity: 1; }
.flash.is-loss { background: radial-gradient(ellipse at 50% 62%, rgba(255, 107, 116, 0.5), transparent 60%); }

/* --- HUD --- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
  pointer-events: none;
  text-align: center;
  color: var(--cream);
}
.hud__count {
  margin: 0;
  font-family: "Dela Gothic One", system-ui, sans-serif;
  font-size: 54px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 18px rgba(127, 227, 255, .85), 0 2px 0 rgba(0,0,0,.35);
}
.hud__count.is-up { animation: pump .22s ease-out; }
.hud__count.is-down { animation: shake .22s ease-out; color: #ffd9dc; }
@keyframes pump { 0% { transform: scale(1); } 45% { transform: scale(1.24); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 30% { transform: translateX(-6px); } 65% { transform: translateX(5px); } }

.hud__to {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: .85;
  letter-spacing: .04em;
}
.hud__bar {
  margin: 8px auto 0;
  width: 62%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  overflow: hidden;
}
.hud__bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--spark-deep), var(--spark));
}

.pop {
  position: absolute;
  z-index: 7;
  top: 40%;
  left: 0; right: 0;
  margin: 0;
  text-align: center;
  pointer-events: none;
  font-family: "Dela Gothic One", system-ui, sans-serif;
  font-size: 40px;
  color: var(--spark);
  text-shadow: 0 0 20px rgba(127,227,255,.8);
  animation: popUp .7s ease-out forwards;
}
.pop.is-loss { color: var(--loss); text-shadow: 0 0 20px rgba(255,107,116,.8); }
@keyframes popUp {
  0% { opacity: 0; transform: translateY(14px) scale(.85); }
  20% { opacity: 1; transform: translateY(0) scale(1.08); }
  100% { opacity: 0; transform: translateY(-30px) scale(1); }
}

.hint {
  position: absolute;
  z-index: 6;
  left: 0; right: 0;
  bottom: calc(26px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  color: var(--cream);
  font-size: 14px;
  opacity: .8;
  pointer-events: none;
  animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: .35; } 50% { opacity: .9; } }

/* --- sheets --- */
.sheet {
  position: absolute;
  z-index: 10;
  inset: auto 0 0 0;
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 22px calc(24px + env(safe-area-inset-bottom));
  background: var(--card);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise .26s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.sheet h1, .sheet h2 {
  margin: 6px 0 8px;
  font-family: "Dela Gothic One", system-ui, sans-serif;
  font-size: 30px;
  letter-spacing: .02em;
}
.sheet__lead { margin: 0 0 12px; font-size: 15px; line-height: 1.7; }
.sheet__how {
  margin: 0 auto 16px;
  padding: 12px 14px;
  max-width: 320px;
  list-style: none;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.9;
  background: rgba(13, 21, 36, .06);
  border-radius: 14px;
}
.welcome__art { width: 132px; height: auto; display: block; margin: 0 auto; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 8px auto 0;
  padding: 15px 18px;
  border-radius: 999px;
  font-family: "Dela Gothic One", system-ui, sans-serif;
  font-size: 18px;
  color: #05202c;
  background: linear-gradient(180deg, #9fecff, #4cc6ec);
  box-shadow: 0 6px 0 #2a94b5;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #2a94b5; }
.btn--ghost {
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  padding: 10px;
}
.btn--ghost:active { transform: none; box-shadow: none; opacity: .65; }

.result__num { margin: 4px 0 2px; font-size: 17px; }
.result__num strong {
  font-family: "Dela Gothic One", system-ui, sans-serif;
  font-size: 40px;
  color: var(--spark-deep);
}
.result__sub { margin: 0 0 6px; font-size: 13.5px; line-height: 1.7; opacity: .8; }

/* --- map --- */
.map__lead { margin: 0 0 14px; font-size: 13.5px; opacity: .8; }
.map__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 330px;
  margin: 0 auto;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: #101a2e;
  color: rgba(255, 246, 232, .6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  overflow: hidden;
}
.cell__name { font-size: 12.5px; }
.cell__num { font-size: 11px; opacity: .75; }
.cell__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, rgba(255, 207, 107, .85), rgba(255, 207, 107, 0) 70%);
  opacity: 0;
}
.cell.is-open {
  color: var(--cream);
  background: #1a2a49;
  box-shadow: inset 0 0 0 1.5px rgba(127, 227, 255, .45);
}
.cell.is-locked {
  background: #0c1526;
  color: rgba(255, 246, 232, .32);
}
.cell.is-center { outline: 1px dashed rgba(255, 246, 232, .35); outline-offset: -4px; }
.cell__name, .cell__num { position: relative; z-index: 1; }
.cell__glow { z-index: 0; }
