:root {
  --ink: #0c1418;
  --slate: #1a2a32;
  --ridge: #2b4550;
  --mint: #6fd6b6;
  --sand: #efe6d4;
  --rust: #e2552d;
  --steel: #9eb4bd;
  --chip: #f0c43a;
  --danger: #ff5d5d;
  --glow: rgba(111, 214, 182, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 15% 10%, #1d3a44 0%, transparent 45%),
    radial-gradient(ellipse at 90% 90%, #243018 0%, transparent 40%),
    linear-gradient(160deg, #070d10 0%, var(--ink) 50%, #101c22 100%);
  color: var(--sand);
  font-family: "IBM Plex Sans", sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: stretch;
  padding: 0;
  overflow: hidden;
}

.page {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.page[hidden] {
  display: none !important;
}

.page-game {
  display: grid;
  place-items: center;
  padding: 0.6rem;
  box-sizing: border-box;
}

#app {
  width: min(1400px, 100%);
  height: 90vh;
  height: 90dvh;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
  padding: 0 0.1rem;
  flex: 0 0 auto;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

/* —— Wild Idea Zone links —— */
.wiz-home {
  display: flex;
  flex: 0 0 auto;
  border-radius: 7px;
  transition: transform 0.12s ease;
}

.wiz-home img {
  display: block;
  width: 28px;
  height: 28px;
}

.wiz-home:hover,
.wiz-home:focus-visible {
  transform: translateY(-1px) scale(1.06);
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.wiz-footer {
  flex: 0 0 auto;
  margin: 0.45rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--steel);
  opacity: 0.8;
}

.wiz-footer a {
  color: var(--mint);
  text-decoration: none;
}

.wiz-footer a:hover,
.wiz-footer a:focus-visible {
  text-decoration: underline;
  outline: none;
}

.brand {
  margin: 0;
  font-family: Bungee, cursive;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--mint);
  letter-spacing: 0.04em;
  text-shadow: 0 0 16px var(--glow);
}

.chips {
  margin: 0;
  font-weight: 700;
  color: var(--chip);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  filter: drop-shadow(0 16px 36px rgba(0, 0, 0, 0.5));
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(111, 214, 182, 0.28);
  background: #0a1216;
  touch-action: none;
  cursor: pointer;
}

.hud {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: 0.65rem;
  display: grid;
  gap: 0.35rem;
  pointer-events: none;
}

.hud[hidden] {
  display: none !important;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.meter-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--danger), var(--chip) 45%, var(--mint));
  transform-origin: left center;
  transition: transform 0.1s linear;
}

.hud-hint {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.85;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(8, 16, 20, 0.35), rgba(8, 16, 20, 0.82)),
    radial-gradient(circle at 50% 20%, rgba(111, 214, 182, 0.12), transparent 55%);
  text-align: center;
  pointer-events: auto;
}

.panel[hidden] {
  display: none !important;
}

.panel-brand {
  margin: 0;
  font-family: Bungee, cursive;
  font-size: clamp(2rem, 7vw, 3.4rem);
  color: var(--mint);
  text-shadow:
    0 4px 0 #0b2a30,
    0 0 24px var(--glow);
  animation: bob 1.8s ease-in-out infinite;
}

.shop-title {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

.panel-copy {
  margin: 0 auto;
  max-width: 34rem;
  line-height: 1.45;
  color: var(--sand);
  opacity: 0.92;
}

.panel-help {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.btn {
  appearance: none;
  border: 2px solid rgba(158, 180, 189, 0.45);
  background: rgba(26, 42, 50, 0.92);
  color: var(--sand);
  font: 700 0.95rem "IBM Plex Sans", sans-serif;
  padding: 0.7rem 1.15rem;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  border-color: var(--mint);
  outline: none;
}

.btn.primary {
  background: linear-gradient(180deg, #2f8f78, #1f6a5a);
  border-color: #7fd6c2;
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.shop-list {
  display: grid;
  gap: 0.55rem;
  width: min(28rem, 100%);
  margin: 0 auto;
  text-align: left;
}

.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  background: rgba(14, 24, 30, 0.85);
  border: 1px solid rgba(158, 180, 189, 0.28);
}

.shop-item h3 {
  margin: 0;
  font-size: 1rem;
}

.shop-item p {
  margin: 0;
  grid-column: 1 / -1;
  font-size: 0.82rem;
  opacity: 0.8;
}

.shop-item .lvl {
  color: var(--mint);
  font-weight: 700;
  font-size: 0.85rem;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@media (max-width: 640px) {
  .page-game {
    padding: 0.35rem;
  }

  #app {
    height: 90vh;
    height: 90dvh;
  }

  .panel {
    padding: 1rem;
  }

  .panel-actions {
    flex-direction: column;
  }

  .page-game .btn {
    width: 100%;
  }
}
