/* Candy Blast — modern dark glass theme, pure CSS candies. */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg1: #1a1033;
  --bg2: #2d1457;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f3eefc;
  --muted: #b9a8e0;
  --accent: #ff5fa2;
  --accent2: #ffc24b;
  --tile: 12.5%;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, #4a1d7a55, transparent),
    radial-gradient(900px 600px at -10% 110%, #ff5fa222, transparent),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  display: flex;
  justify-content: center;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(92vw, 540px);
  padding: 18px 0 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button:hover {
  background: rgba(255, 255, 255, 0.14);
}

button:active {
  transform: scale(0.96);
}

button.primary {
  background: linear-gradient(90deg, var(--accent), #ff8f5f);
  border: none;
  font-weight: 700;
  padding: 12px 28px;
  font-size: 1.05rem;
}

.controls {
  display: flex;
  gap: 8px;
}

/* HUD */
.hud {
  display: flex;
  gap: 10px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 74px;
  text-align: center;
}

.stat.grow {
  flex: 1;
  text-align: left;
}

.stat label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.stat .value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress {
  margin-top: 6px;
  height: 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

/* Board */
#board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  background:
    conic-gradient(
        rgba(255, 255, 255, 0.045) 90deg,
        transparent 90deg 180deg,
        rgba(255, 255, 255, 0.045) 180deg 270deg,
        transparent 270deg
      )
      0 0 / 25% 25%,
    rgba(0, 0, 0, 0.28);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.tile {
  position: absolute;
  width: var(--tile);
  height: var(--tile);
  left: 0;
  top: 0;
  transition: transform 0.26s cubic-bezier(0.25, 0.9, 0.4, 1.1);
  will-change: transform;
}

.candy {
  position: absolute;
  inset: 9%;
  border-radius: 46%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 50% 55%, var(--c1), var(--c2) 85%);
  box-shadow:
    inset 0 -5px 10px rgba(0, 0, 0, 0.3),
    0 3px 7px rgba(0, 0, 0, 0.38);
  transition: transform 0.15s, filter 0.15s;
}

.t0 .candy { --c1: #ff6b7a; --c2: #d5203c; }
.t1 .candy { --c1: #ffb154; --c2: #e07000; }
.t2 .candy { --c1: #ffe873; --c2: #d9a900; }
.t3 .candy { --c1: #7fe08a; --c2: #1f9e46; }
.t4 .candy { --c1: #6fb9ff; --c2: #1868c9; }
.t5 .candy { --c1: #c98cff; --c2: #7c2fbd; }

/* Specials */
.tile.striped_h .candy::after,
.tile.striped_v .candy::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.85) 0 12%,
    transparent 12% 30%
  );
  opacity: 0.75;
}

.tile.striped_v .candy::after {
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.85) 0 12%,
    transparent 12% 30%
  );
}

.tile.wrapped .candy {
  animation: wrapped-pulse 1.1s ease-in-out infinite;
  box-shadow:
    inset 0 -5px 10px rgba(0, 0, 0, 0.3),
    0 0 14px 3px rgba(255, 255, 255, 0.55);
}

@keyframes wrapped-pulse {
  50% {
    transform: scale(0.88);
  }
}

.tile.color_bomb .candy {
  --c1: #4a4a5e;
  --c2: #12121c;
}

.tile.color_bomb .candy::after {
  content: '✦';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: #ffd76a;
  text-shadow: 0 0 8px #ff5fa2, 0 0 14px #6fb9ff;
  animation: bomb-spin 2.4s linear infinite;
}

@keyframes bomb-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Interaction states */
.tile.selected .candy {
  transform: scale(1.12);
  filter: brightness(1.25);
  outline: 3px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.tile.hint .candy {
  animation: hint-pulse 0.55s ease-in-out 4;
}

@keyframes hint-pulse {
  50% {
    transform: scale(1.18);
    filter: brightness(1.4);
  }
}

.tile.shake {
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  25% { translate: -6% 0; }
  75% { translate: 6% 0; }
}

.tile.pop .candy {
  animation: pop 0.26s ease-in forwards;
}

@keyframes pop {
  35% {
    transform: scale(1.25);
    filter: brightness(1.6);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* Floating score */
.float-score {
  position: absolute;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--accent2);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: float-up 0.9s ease-out forwards;
  z-index: 5;
}

@keyframes float-up {
  from {
    opacity: 1;
    translate: 0 0;
  }
  to {
    opacity: 0;
    translate: 0 -60px;
  }
}

/* Level dots */
.levels {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.levels button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  font-weight: 700;
}

.levels button.current {
  background: linear-gradient(135deg, var(--accent), #ff8f5f);
  border: none;
}

.levels button.locked {
  opacity: 0.35;
  cursor: not-allowed;
}

.levels button .star {
  font-size: 0.6rem;
  display: block;
  line-height: 0.6;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 5, 25, 0.66);
  backdrop-filter: blur(6px);
  z-index: 10;
  transition: opacity 0.25s;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.card {
  background: linear-gradient(160deg, #2d1a52, #1c1038);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 34px 42px;
  text-align: center;
  max-width: 84vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.card h2 {
  font-size: 1.9rem;
  margin-bottom: 8px;
}

.card p {
  color: var(--muted);
  margin-bottom: 22px;
  white-space: pre-line;
}

@media (max-width: 420px) {
  h1 {
    font-size: 1.35rem;
  }
  .stat {
    padding: 8px 10px;
    min-width: 62px;
  }
  .stat .value {
    font-size: 1.1rem;
  }
}
