:root {
  --ink: #2f3f55;
  --muted: #5f738a;
  --sky: #7ec8ff;
  --cream: #fff8ec;
  --lemon: #ffe27a;
  --pink: #ff6b9d;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Jua", system-ui, sans-serif;
  color: var(--ink);
  background: #1a3a58;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 0.557));
  height: min(100dvh, calc(100vw / 0.557));
  max-width: 420px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.55), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(255, 226, 122, 0.35), transparent 24%),
    linear-gradient(180deg, var(--sky), #b8e2ff 52%, #fff1c8);
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.home {
  pointer-events: auto;
  text-decoration: none;
  color: #fff;
  background: rgba(30, 50, 70, 0.45);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.score-pill {
  background: rgba(30, 50, 70, 0.45);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 12px;
  color: #fff;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.score-pill b {
  color: var(--lemon);
  font-size: 16px;
}

.score-pill.soft b {
  color: #c8ecff;
}

.phase-msg {
  position: absolute;
  top: 62px;
  left: 12px;
  right: 12px;
  z-index: 2;
  margin: 0;
  text-align: center;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-size: clamp(22px, 6vw, 28px);
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.board {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(86%, 320px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  z-index: 2;
}

.board.cols-3 {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(92%, 340px);
}

.board.cols-5 {
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(96%, 360px);
}

.board.locked {
  pointer-events: none;
}

.board.locked .tile {
  cursor: default;
}

.tile.dim {
  filter: brightness(0.72) saturate(0.85);
  opacity: 0.75;
}

.tile {
  appearance: none;
  border: none;
  aspect-ratio: 1;
  border-radius: 22px;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    0 6px 0 rgba(47, 63, 85, 0.16),
    inset 0 0 0 2px rgba(255, 255, 255, 0.65);
  overflow: hidden;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.tile:disabled {
  cursor: default;
}

.tile.lit {
  transform: scale(1.06);
  filter: brightness(1.12) saturate(1.15);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.85),
    0 0 28px rgba(255, 107, 157, 0.55),
    0 8px 0 rgba(47, 63, 85, 0.12);
}

.tile.ok {
  box-shadow:
    0 0 0 4px rgba(95, 211, 106, 0.9),
    0 6px 0 rgba(47, 63, 85, 0.12);
}

.tile.bad {
  animation: shake 0.35s ease;
  box-shadow:
    0 0 0 4px rgba(255, 90, 90, 0.9),
    0 6px 0 rgba(47, 63, 85, 0.12);
}

.tile:not(:disabled):active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 3px 0 rgba(47, 63, 85, 0.16);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.hint {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 2;
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 56px 18px 20px;
  overflow-y: auto;
  text-align: center;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(180deg, rgba(126, 200, 255, 0.94), rgba(255, 236, 180, 0.96));
}

.overlay.hidden {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(180deg, #ff8ab5, #ff4f8b);
  box-shadow: 0 4px 0 #d93f74;
}

.badge.soft {
  background: linear-gradient(180deg, #7ad0ff, #4aa8ef);
  box-shadow: 0 4px 0 #2f7fc0;
}

.hero-art {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: 0 10px 24px rgba(40, 70, 100, 0.2);
}

.hero-art.small {
  width: 100px;
  height: 100px;
  border-radius: 22px;
}

.overlay h1 {
  margin: 2px 0 0;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-weight: 400;
  font-size: clamp(34px, 9vw, 42px);
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.45);
}

.overlay p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.45;
}

.btn {
  appearance: none;
  border: none;
  min-width: 168px;
  min-height: 48px;
  margin-top: 6px;
  padding: 0 22px;
  border-radius: 999px;
  font: inherit;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #ff8ab5, #ff4f8b);
  box-shadow: 0 5px 0 #d93f74;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #d93f74;
}

.link {
  margin-top: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
