:root {
  --ink: #fff7ff;
  --ink-2: #e6d8f5;
  --ink-3: #b9a6d6;
  --panel: rgba(27, 16, 51, 0.82);
  --panel-2: rgba(45, 27, 82, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #ffd23f;
  --violet: #8e5cf2;
  --pink: #ff5da2;
  --cell: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: #1b1033 url('./assets/background.webp') center / cover fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(27, 16, 51, 0.55), rgba(27, 16, 51, 0.85));
  pointer-events: none;
}

.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hidden {
  display: none !important;
}

a {
  color: var(--gold);
}

/* Start */
.hero-hunter {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45));
  animation: bob 2.6s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-8px);
  }
}

h1 {
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 12px 0 4px;
}

.tagline {
  color: var(--ink-2);
  margin: 0 0 22px;
  font-size: 1.05rem;
}

.card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 12px 0 6px;
}

.stepper output {
  min-width: 110px;
  font-size: 2rem;
  font-weight: 800;
}

.step {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
}

.step:disabled {
  opacity: 0.35;
  cursor: default;
}

.hint {
  color: var(--ink-3);
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.primary,
.secondary {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.primary {
  color: #2a1450;
  background: linear-gradient(135deg, var(--gold), #ffb03f);
  box-shadow: 0 10px 24px rgba(255, 190, 60, 0.35);
}

.secondary {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.primary:active,
.secondary:active,
.step:active,
.icon-btn:active {
  transform: scale(0.97);
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.best {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.92rem;
  margin: 14px 0 0;
  min-height: 1em;
}

.how {
  width: 100%;
  margin-top: 16px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 18px;
}

.how summary {
  cursor: pointer;
  font-weight: 700;
}

.how ul {
  margin: 12px 0 4px;
  padding-left: 20px;
  color: var(--ink-2);
  line-height: 1.6;
}

.credit {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-3);
}

/* Game */
.hud {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat span:last-child {
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.energy {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.heart {
  width: 26px;
  height: 26px;
  fill: var(--pink);
  flex: none;
  filter: drop-shadow(0 2px 6px rgba(255, 93, 162, 0.5));
}

.bar {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  transition: width 0.25s ease, background 0.25s ease;
}

.fill.low {
  background: linear-gradient(90deg, #ff3b3b, #ff7a59);
}

.moves {
  flex: none;
  min-width: 84px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.board {
  --n: 6;
  width: min(100%, 72vh, 560px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  gap: clamp(3px, 0.8vmin, 6px);
  padding: clamp(6px, 1.4vmin, 10px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  touch-action: none;
  user-select: none;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  padding: 0;
  border-radius: 10px;
  background: var(--cell);
  cursor: default;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cell.reach {
  cursor: pointer;
  background: rgba(255, 210, 63, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 210, 63, 0.55);
}

.cell.reach:hover {
  background: rgba(255, 210, 63, 0.28);
}

.cell.trail {
  background: rgba(142, 92, 242, 0.22);
}

.orb {
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b8 0 12%, var(--gold) 28%, #b77cff 62%, #6d3fd6 100%);
  box-shadow: 0 0 14px rgba(255, 210, 63, 0.65);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(0.88);
    box-shadow: 0 0 22px rgba(255, 210, 63, 0.9);
  }
}

.hunter {
  width: 86%;
  height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.hunter.chomp {
  animation: chomp 0.28s ease;
}

@keyframes chomp {
  40% {
    transform: scale(1.18);
  }
}

.tip {
  color: var(--ink-3);
  font-size: 0.9rem;
  margin: 14px 0 0;
}

/* Result */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 7, 30, 0.6);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.result-card {
  max-width: 420px;
  text-align: center;
}

.result-hunter {
  width: 80px;
  height: auto;
  margin: -64px auto 4px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45));
}

.result-card h2 {
  font-size: 2rem;
  margin: 4px 0 6px;
}

.result-card p {
  color: var(--ink-2);
  margin: 0 0 16px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.result-stats div {
  background: var(--panel-2);
  border-radius: 14px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
}

.result-stats strong {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

.result-stats span {
  font-size: 0.78rem;
  color: var(--ink-3);
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
