:root {
  color-scheme: dark;
  --bg: #101827;
  --ink: #f8fbff;
  --muted: #bed0e5;
  --aqua: #5eead4;
  --berry: #ff6f91;
  --gold: #ffd166;
  --lime: #8effa7;
  --violet: #a78bfa;
  --plum: #31224d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101827;
  color: var(--ink);
  touch-action: none;
}

body {
  min-height: 100svh;
}

button {
  font: inherit;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

#gameRoot {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 209, 102, 0.22), transparent 32%),
    radial-gradient(circle at 78% 34%, rgba(94, 234, 212, 0.24), transparent 30%),
    linear-gradient(180deg, #382556 0%, #17223a 48%, #101827 100%);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(462px, 44vw);
  min-height: 66px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 209, 102, 0.36);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(15, 22, 38, 0.86), rgba(47, 30, 74, 0.76));
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.34), 0 0 34px rgba(255, 111, 145, 0.14);
  backdrop-filter: blur(12px);
}

.mark,
.potion-emblem {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 28%, #ffffff 0 8%, transparent 9%),
    radial-gradient(circle at 50% 62%, var(--berry) 0 26%, transparent 27%),
    conic-gradient(from 0deg, var(--aqua), var(--lime), var(--gold), var(--berry), var(--violet), var(--aqua));
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.48);
}

.brand-lockup h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(18px, 2.1vw, 28px);
  line-height: 1;
}

.brand-lockup p {
  margin: 5px 0 0;
  color: #e2eefb;
  font-size: clamp(11px, 1vw, 14px);
  line-height: 1.25;
}

.meter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 8px;
  width: min(402px, 42vw);
}

.meter {
  position: relative;
  min-height: 56px;
  overflow: hidden;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(7, 13, 28, 0.76);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
}

.meter span {
  display: block;
  color: #cfe1f7;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.meter b {
  display: block;
  margin-top: 5px;
  color: #ffffff;
  font-size: 21px;
  line-height: 1;
}

.meter i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 4px;
  background: var(--aqua);
  box-shadow: 0 0 18px currentColor;
}

.score i { background: var(--berry); }
.drops i { background: var(--gold); }
.orders i { background: var(--aqua); }

#touchControls {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 116px 128px 138px 104px;
  gap: 10px;
  transform: translateX(-50%);
}

.brew-button,
.upgrade-button,
.rush-button {
  min-width: 88px;
  min-height: 64px;
  border: 0;
  border-radius: 999px;
  color: #101827;
  cursor: pointer;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow:
    inset 0 -7px 18px rgba(3, 7, 18, 0.2),
    0 16px 34px rgba(0, 0, 0, 0.3);
}

.brew-button {
  background: linear-gradient(135deg, #ffd166, #ff9f43);
}

.upgrade-button {
  background: linear-gradient(135deg, #5eead4, #8effa7);
}

.rush-button {
  background: linear-gradient(135deg, #ff6f91, #a78bfa);
}

.brew-button:active,
.upgrade-button:active,
.rush-button:active {
  transform: translateY(2px) scale(0.98);
}

#modal {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 209, 102, 0.18), transparent 42%),
    rgba(6, 10, 22, 0.22);
  transition: opacity 180ms ease, visibility 180ms ease;
}

#modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-frame {
  width: min(540px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 209, 102, 0.42);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(14, 21, 38, 0.95), rgba(55, 31, 75, 0.92));
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.48),
    0 0 80px rgba(255, 111, 145, 0.22);
  text-align: center;
}

.titleplate {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.titleplate p {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.titleplate h2 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(32px, 6.6vw, 58px);
  line-height: 0.96;
}

.brief {
  margin: 16px auto 0;
  max-width: 440px;
  color: #e3f0ff;
  font-size: 16px;
  line-height: 1.45;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 20px;
}

.brief-grid span {
  display: grid;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef6ff;
  font-size: 12px;
  font-weight: 850;
}

#modalPrimary {
  width: min(260px, 100%);
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--aqua));
  color: #101827;
  cursor: pointer;
  font-size: 15px;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 0 18px 48px rgba(255, 209, 102, 0.34);
}

@media (max-width: 780px) {
  #hud {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .brand-lockup {
    width: min(100%, 360px);
    min-height: 58px;
  }

  .brand-lockup h1 {
    font-size: 19px;
  }

  .brand-lockup p {
    max-width: 270px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .meter-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 360px);
  }

  .meter {
    min-height: 48px;
    padding: 7px 9px;
  }

  .meter b {
    font-size: 18px;
  }

  #touchControls {
    width: calc(100vw - 18px);
    grid-template-columns: 1fr 1.08fr 1.16fr 0.92fr;
    gap: 7px;
  }

  .brew-button,
  .upgrade-button,
  .rush-button {
    min-width: 0;
    min-height: 62px;
    padding: 0 5px;
    font-size: 12px;
  }

  .modal-frame {
    padding: 18px;
  }

  .brief-grid {
    grid-template-columns: 1fr;
  }
}
