:root {
  --bg: #0f1730;
  --bg-2: #2d5a5b;
  --panel: rgba(255, 255, 255, 0.17);
  --panel-strong: rgba(255, 255, 255, 0.25);
  --text: #fff5f7;
  --accent: #ff7aa2;
  --accent-2: #ffcf5c;
  --accent-3: #7fe2d3;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  overflow: hidden;
  background: linear-gradient(135deg, #132746, #2c5e62 45%, #7b4f8b 100%);
  position: relative;
}

.sky,
.garden,
.petal-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky {
  background: radial-gradient(circle at top left, rgba(255,255,255,0.35), transparent 35%);
  animation: drift 18s ease-in-out infinite alternate;
}

.garden {
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.12), transparent 20%),
    radial-gradient(circle at 80% 15%, rgba(255,255,255,0.16), transparent 25%),
    radial-gradient(circle at 50% 80%, rgba(255,255,255,0.14), transparent 28%);
  filter: blur(0.5px);
}

.petal-layer {
  background-image: radial-gradient(circle, rgba(255,255,255,0.7) 1px, transparent 2px);
  background-size: 90px 90px;
  opacity: 0.48;
  animation: floatPetals 22s linear infinite;
}

.petal-layer-b {
  opacity: 0.3;
  transform: scale(1.08) translateY(8px);
  animation-duration: 28s;
}

.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px 20px 24px;
}

.topbar,
.hud,
.game-area,
.panel-card,
.stat-card,
.board-wrap,
.overlay-card {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2rem;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 16px rgba(255,255,255,0.32);
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.brand p {
  margin: 2px 0 0;
  color: rgba(255,255,255,0.78);
  font-size: 0.9rem;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.16);
}

.stat-card {
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--panel-strong);
  text-align: center;
}

.stat-card span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.72);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.12rem;
}

.game-area {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  margin-top: 16px;
  flex: 1;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  padding: 16px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: var(--shadow);
}

.panel-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.objective-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.objective-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.objective-list .done {
  background: rgba(127, 226, 211, 0.24);
}

.power-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.power-btn,
.btn {
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.power-btn:hover,
.btn:hover {
  transform: translateY(-2px);
}

.power-btn {
  padding: 10px 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 122, 162, 0.95), rgba(255, 207, 92, 0.9));
  box-shadow: 0 10px 20px rgba(0,0,0,0.16);
}

.board-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: var(--shadow);
}

.board {
  position: relative;
  width: min(92vw, 560px);
  aspect-ratio: 1/1;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255,255,255,0.18), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.2);
  touch-action: none;
  user-select: none;
}

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 20px;
  transition: transform 0.28s ease, opacity 0.22s ease, box-shadow 0.22s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.24), 0 9px 18px rgba(0,0,0,0.16);
  cursor: pointer;
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), transparent);
  pointer-events: none;
}

.tile.selected {
  box-shadow: 0 0 0 4px rgba(255,207,92,0.95), 0 12px 26px rgba(0,0,0,0.24);
}

.tile.removing {
  opacity: 0;
  transform: scale(0.4);
}

.tile.hint {
  outline: 3px solid rgba(255,255,255,0.9);
  outline-offset: -4px;
}

.message-box {
  margin-top: 14px;
  min-height: 24px;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.86);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 17, 34, 0.78);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: min(92vw, 480px);
  padding: 26px 24px;
  border-radius: 30px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.16);
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card.small {
  width: min(90vw, 360px);
}

.overlay-card h2,
.overlay-card h3 {
  margin: 0 0 10px;
}

.overlay-card p {
  color: rgba(255,255,255,0.82);
  margin: 0 0 18px;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  padding: 12px 16px;
  border-radius: 999px;
  min-width: 120px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 20px rgba(0,0,0,0.16);
}

.btn.soft {
  background: rgba(255,255,255,0.18);
}

.hidden {
  display: none !important;
}

.settings-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 12;
  background: rgba(7, 11, 23, 0.55);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 8;
  box-shadow: 0 0 16px currentColor;
}

@keyframes drift {
  from { transform: translate3d(-2%, -2%, 0); }
  to { transform: translate3d(2%, 2%, 0); }
}

@keyframes floatPetals {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3%, 12%, 0) scale(1.06); }
}

@media (max-width: 980px) {
  .game-area {
    grid-template-columns: 1fr;
  }

  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .panel-card {
    flex: 1;
    min-width: 260px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 12px 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .hud {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
  }

  .board-wrap {
    padding: 10px;
  }

  .board {
    width: min(94vw, 460px);
  }
}
