:root {
  color-scheme: dark;
  --bg: #112f37;
  --panel: rgba(8, 20, 24, 0.82);
  --panel-strong: #102d33;
  --text: #f7fbf8;
  --muted: #b7c9c2;
  --accent: #ffbf3f;
  --accent-2: #48d4a0;
  --danger: #ff5f5f;
  --shadow: rgba(0, 0, 0, 0.28);
  --press: rgba(255, 255, 255, 0.22);
  --menu-art: none;
  --icon-atlas: none;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button, select, input, textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #092025;
  background: var(--accent);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, filter 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover, button:focus-visible {
  filter: brightness(1.08);
  outline: 3px solid rgba(255, 255, 255, 0.36);
  outline-offset: 2px;
  animation: control-lift 180ms ease-out both;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.46;
  filter: grayscale(0.3);
}

button.secondary, button[data-action], .game-toolbar button {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

button.primary {
  background: var(--accent);
  color: #132327;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 191, 63, 0.16), transparent 24rem),
    linear-gradient(145deg, #143e46 0%, #0f2f37 48%, #163129 100%);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
}

.screen.active {
  display: grid;
  place-items: center;
}

#mainMenu {
  isolation: isolate;
  background-image:
    linear-gradient(90deg, rgba(3, 13, 16, 0.3), rgba(3, 13, 16, 0.08) 50%, rgba(3, 13, 16, 0.3)),
    linear-gradient(180deg, rgba(3, 13, 16, 0.08), rgba(3, 13, 16, 0.44)),
    var(--menu-art);
  background-size: auto, auto, cover;
  background-position: center;
  background-repeat: no-repeat;
}

#mainMenu::before,
#mainMenu::after {
  content: "";
  position: absolute;
  inset: -8%;
  z-index: -1;
  pointer-events: none;
}

#mainMenu::before {
  background:
    radial-gradient(circle at 8% 22%, transparent 0 22px, rgba(255, 105, 120, 0.28) 23px 25px, transparent 26px),
    radial-gradient(circle at 88% 18%, transparent 0 42px, rgba(255, 191, 63, 0.24) 43px 46px, transparent 47px),
    radial-gradient(circle at 16% 82%, transparent 0 54px, rgba(72, 212, 160, 0.2) 55px 58px, transparent 59px),
    radial-gradient(circle at 92% 76%, transparent 0 30px, rgba(77, 184, 255, 0.2) 31px 34px, transparent 35px),
    radial-gradient(circle at 70% 62%, transparent 0 11px, rgba(255, 255, 255, 0.18) 12px 14px, transparent 15px);
  animation: menu-bubbles-drift 14s ease-in-out infinite alternate;
}

#mainMenu::after {
  inset: 0;
  background:
    linear-gradient(38deg, transparent 0 34%, rgba(255, 255, 255, 0.12) 34.2% 34.5%, transparent 34.7%),
    linear-gradient(142deg, transparent 0 74%, rgba(255, 191, 63, 0.13) 74.2% 74.5%, transparent 74.7%);
  opacity: 0.52;
  animation: trajectory-glide 9s ease-in-out infinite alternate;
}

.brand-lockup, .menu-panel {
  width: min(720px, 100%);
  text-align: center;
  position: relative;
  z-index: 1;
}

.menu-panel {
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.76);
}

.logo-bubbles {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.logo-bubbles span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  box-shadow: inset -9px -12px 18px rgba(0,0,0,.22), inset 8px 10px 16px rgba(255,255,255,.42), 0 8px 20px var(--shadow);
  animation: loading-bubble 1.2s ease-in-out infinite;
}

.logo-bubbles span:nth-child(1) { background: #ff6978; animation-delay: -0.24s; }
.logo-bubbles span:nth-child(2) { background: #ffbf3f; animation-delay: -0.12s; }
.logo-bubbles span:nth-child(3) { background: #48d4a0; }

.loading-track {
  width: min(320px, 78vw);
  height: 8px;
  margin: 1rem auto 0;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.32);
}

.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ffffff);
  transition: width 140ms ease;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 5.8rem);
  letter-spacing: 0;
  line-height: 0.92;
}

.kicker {
  color: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.menu-copy {
  max-width: 620px;
  margin: 1rem auto 1.5rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  width: min(480px, 100%);
  margin: 0 auto;
}

.button-grid .primary {
  grid-column: 1 / -1;
}

.brand-footer {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

.brand-footer a {
  color: var(--text);
  text-underline-offset: 3px;
}

.brand-footer a:hover,
.brand-footer a:focus-visible {
  color: var(--accent);
  outline: 2px solid rgba(255, 255, 255, 0.42);
  outline-offset: 3px;
}

.button-grid button {
  position: relative;
  padding-right: 2.7rem;
  text-align: left;
}

.button-grid button::after {
  content: "\203A";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-54%);
  color: currentColor;
  font-size: 1.55rem;
  line-height: 1;
}

.button-grid .primary {
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.18),
    0 0 26px color-mix(in srgb, var(--accent) 58%, transparent);
}

.game-screen.active {
  display: block;
  padding: 0;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(0.55rem, var(--safe-top));
  left: 50%;
  width: min(860px, calc(100vw - max(1rem, var(--safe-left)) - max(1rem, var(--safe-right))));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 0.8fr 1.15fr 0.85fr 0.9fr 0.85fr auto auto;
  gap: 0.35rem;
  pointer-events: none;
}

.hud > div, .hud-icon, .game-toolbar, .modal {
  background: linear-gradient(180deg, rgba(12, 37, 43, 0.88), rgba(6, 22, 26, 0.82));
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 22px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.12);
  backdrop-filter: blur(10px);
}

.hud > div, .hud-icon {
  border-radius: 8px;
  min-width: 0;
  padding: 0.42rem 0.5rem;
}

.hud-icon {
  pointer-events: auto;
  min-height: 0;
  min-width: 50px;
  padding: 0.35rem 0.55rem;
  color: var(--text);
  font-size: 0.78rem;
  box-shadow: 0 3px 0 rgba(0,0,0,.22);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hud strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}

.score-badge.is-pulsing strong,
.coin-badge.is-pulsing strong,
.juice-badge.is-pulsing strong {
  color: var(--accent);
}

.hud-badge.is-pulsing {
  animation: hud-scale-pop 420ms cubic-bezier(.2, .8, .2, 1);
}

.juice-badge {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 0.28rem;
}

.juice-icon {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 66% 34% 68% 32%;
  background-color: var(--accent);
  background-image: var(--icon-atlas);
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0 0;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 52%, transparent));
}

.juice-icon::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 7px;
  width: 5px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  transform: rotate(28deg);
}

.art-icons-ready .juice-icon {
  border-radius: 0;
  background-color: transparent;
}

.art-icons-ready .juice-icon::before {
  display: none;
}

.juice-copy {
  min-width: 0;
}

.moves-badge.is-low {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent), 0 10px 22px rgba(0,0,0,.26);
}

.game-toolbar {
  position: absolute;
  right: auto;
  bottom: max(0.65rem, var(--safe-bottom));
  left: 50%;
  width: min(560px, calc(100vw - max(1rem, var(--safe-left)) - max(1rem, var(--safe-right))));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 0.66fr 0.82fr repeat(3, 1fr);
  gap: 0.4rem;
  border-radius: 8px;
  padding: 0.38rem;
}

.game-toolbar button {
  position: relative;
  min-height: 46px;
  padding: 0.34rem 0.3rem;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 0 rgba(0,0,0,.24);
}

.game-toolbar button[data-power] {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem;
}

.game-toolbar button[data-action="swap"] {
  display: grid;
  place-items: center;
}

.swap-art {
  position: relative;
  width: 42px;
  height: 42px;
  background-image: var(--icon-atlas);
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0 100%;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.38));
}

.swap-art::before {
  content: "";
  position: absolute;
  inset: 6px 2px;
  background:
    radial-gradient(circle at 28% 50%, #ff6978 0 23%, transparent 25%),
    radial-gradient(circle at 72% 50%, #48d4a0 0 23%, transparent 25%);
}

.swap-art::after {
  content: "\2194";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 900;
  text-shadow: 0 1px 4px #06171b;
}

.art-icons-ready .swap-art::before,
.art-icons-ready .swap-art::after {
  display: none;
}

.game-toolbar button[data-power] span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-toolbar button[data-power] strong {
  min-width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #081c21;
  background: var(--accent);
  font-size: 0.78rem;
}

.game-toolbar button[data-power]::after {
  content: attr(aria-label) " (key " attr(data-key) ")";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  background: rgba(0,0,0,.82);
  opacity: 0;
  pointer-events: none;
  font-size: 0.75rem;
}

.game-toolbar button[data-action="swap"]::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  background: rgba(0,0,0,.82);
  opacity: 0;
  pointer-events: none;
  font-size: 0.75rem;
}

.game-toolbar button[data-power]:hover::after,
.game-toolbar button[data-power]:focus-visible::after,
.game-toolbar button[data-action="swap"]:hover::after,
.game-toolbar button[data-action="swap"]:focus-visible::after {
  opacity: 1;
}

.game-toolbar button.is-selected {
  background: color-mix(in srgb, var(--accent) 38%, rgba(255,255,255,.14));
  border-color: var(--accent);
}

.game-toolbar button.is-empty strong {
  background: rgba(255,255,255,.18);
  color: var(--muted);
}

.toast-host {
  position: absolute;
  top: 5.5rem;
  left: 50%;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(0,0,0,.72);
  border: 1px solid rgba(255,255,255,.18);
  text-align: center;
  font-weight: 800;
  animation: toast-reveal 220ms ease-out both;
}

.toast.good { border-color: rgba(72, 212, 160, .5); }
.toast.warn { border-color: rgba(255, 191, 63, .55); }

.toast.hype {
  border-color: var(--accent);
  color: #ffffff;
  background: linear-gradient(180deg, rgba(20, 55, 60, 0.96), rgba(6, 24, 29, 0.96));
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 34%, transparent), 0 12px 28px rgba(0, 0, 0, 0.38);
}

.hype-stack {
  margin: 0.7rem 0;
  padding: 0.65rem 0.8rem;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, rgba(0, 0, 0, 0.2));
}

.hype-stack p {
  margin: 0.25rem 0;
  color: #ffffff;
  font-weight: 800;
}

.share-copy-field {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.modal-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0,0,0,.5);
  z-index: 20;
}

.modal-layer.hidden { display: none; }

.modal {
  position: relative;
  width: min(760px, 96vw);
  max-height: min(86vh, 860px);
  overflow: auto;
  border-radius: 8px;
  padding: 1.25rem;
  isolation: isolate;
  animation: modal-reveal 240ms cubic-bezier(.2, .8, .2, 1) both;
}

.modal h2 {
  margin-top: 0.1rem;
  font-size: clamp(1.7rem, 5vw, 2.5rem);
}

.modal .result-hero {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  margin: 0.5rem 0 1rem;
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.stat-grid,
.reward-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.stat-chip,
.star-row,
.objective-label {
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
}

.star-row {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0;
  animation: star-reveal 420ms cubic-bezier(.2, .8, .2, 1) both;
}

.close {
  position: sticky;
  top: 0;
  z-index: 3;
  float: right;
  min-width: 44px;
  padding: 0.35rem 0.65rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}

.option-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 8px;
  padding: 0.85rem;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.07));
  border: 1px solid rgba(255,255,255,.14);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.option-card:hover,
.option-card:focus-within {
  animation: card-lift 180ms ease-out both;
}

.option-card.is-current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.option-card h3 { margin: 0 0 0.4rem; }
.option-card p { color: var(--muted); margin: 0.3rem 0 0.75rem; }

.fx-layer::before,
.fx-layer::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 180ms ease, transform 240ms ease;
}

.fx-layer {
  position: relative;
}

.fx-layer::before {
  top: -45%;
  right: -25%;
  width: 68%;
  height: 110%;
  transform: rotate(24deg) translateY(-18%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 32%, transparent), transparent);
}

.fx-layer::after {
  inset: 0;
  background: radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 42%);
}

.fx-layer:hover::before,
.fx-layer:focus-within::before,
.fx-layer.is-current::before,
.modal.fx-layer::before {
  opacity: 1;
  transform: rotate(24deg) translateY(8%);
}

.fx-layer:hover::after,
.fx-layer:focus-within::after,
.fx-layer.is-current::after,
.modal.fx-layer::after {
  opacity: 1;
}

.fx-layer > * {
  position: relative;
  z-index: 1;
}

.panel-grid > .fx-layer:nth-child(3n+2)::after {
  background: radial-gradient(circle at 80% 90%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 46%);
}

.panel-grid > .fx-layer:nth-child(3n)::before {
  right: auto;
  left: -25%;
  transform: rotate(-24deg) translateY(-18%);
}

.coin-fly {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 40;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  background:
    radial-gradient(circle at 36% 32%, #fff4a6 0 8%, transparent 9%),
    radial-gradient(circle, #ffd950 0 43%, #d88911 46% 58%, #ffe77a 61% 68%, #a95c08 71%);
  border: 1px solid rgba(255,255,255,.82);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 58%, transparent);
  animation: coin-fly-to-hud 760ms cubic-bezier(.2, .75, .2, 1) var(--coin-delay, 0ms) forwards;
  pointer-events: none;
}

.coin-spark {
  position: fixed;
  z-index: 41;
  left: var(--spark-x);
  top: var(--spark-y);
  width: 26px;
  height: 26px;
  pointer-events: none;
  animation: coin-spark 420ms ease-out var(--spark-delay, 620ms) both;
}

.coin-spark::before,
.coin-spark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4px;
  height: 100%;
  border-radius: 4px;
  background: #fff6ae;
  box-shadow: 0 0 12px var(--accent);
}

.coin-spark::after {
  transform: rotate(90deg);
}

@keyframes loading-bubble {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.05); }
}

@keyframes hud-scale-pop {
  0%, 100% { transform: scale(1); }
  42% { transform: scale(1.09); }
}

@keyframes control-lift {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

@keyframes card-lift {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

@keyframes modal-reveal {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes star-reveal {
  from { opacity: 0; transform: translateY(6px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes coin-fly-to-hud {
  0% { opacity: 0; transform: translate(var(--coin-start-x), var(--coin-start-y)) scale(.55) rotate(0); }
  18% { opacity: 1; }
  48% { opacity: 1; transform: translate(var(--coin-mid-x), var(--coin-mid-y)) scale(1.08) rotate(150deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--coin-dx)), calc(-50% + var(--coin-dy))) scale(.62) rotate(320deg); }
}

@keyframes coin-spark {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(0); }
  38% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(45deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6) rotate(90deg); }
}

@keyframes menu-bubbles-drift {
  from { transform: translate3d(-1%, 1%, 0) scale(1); }
  to { transform: translate3d(1.5%, -1.5%, 0) scale(1.025); }
}

@keyframes trajectory-glide {
  from { transform: translateX(-1.5%); opacity: .34; }
  to { transform: translateX(1.5%); opacity: .62; }
}

@keyframes toast-reveal {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.75rem 0;
}

textarea {
  width: 100%;
  min-height: 150px;
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text);
  background: #071a1f;
  border: 1px solid rgba(255,255,255,.2);
}

.editor-grid {
  display: grid;
  gap: 2px;
  overflow: auto;
  padding: 0.25rem;
  background: rgba(0,0,0,.22);
  border-radius: 8px;
}

.editor-cell {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.12);
}

@media (max-width: 540px) {
  .button-grid { grid-template-columns: 1fr; }
  .hud {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.25rem;
  }
  .hud-icon {
    min-width: 0;
    font-size: 0.64rem;
    padding: 0.3rem 0.25rem;
  }
  .hud > div {
    padding: 0.38rem 0.4rem;
  }
  .juice-badge {
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 0.15rem;
  }
  .juice-icon {
    width: 18px;
    height: 18px;
  }
  .label { font-size: 0.58rem; }
  .hud strong { font-size: 0.86rem; }
  .toast-host { top: 4.7rem; }
  .game-toolbar {
    width: calc(100vw - 1rem);
    gap: 0.35rem;
  }
  .game-toolbar button {
    font-size: 0.9rem;
  }
  .game-toolbar button[data-action="swap"] {
    padding: 0.15rem;
  }
  .swap-art { width: 38px; height: 38px; }
  .game-toolbar button[data-power] {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .game-toolbar button[data-power] strong {
    justify-self: center;
    min-width: 1.35rem;
    height: 1.35rem;
  }
}

@media (max-height: 580px) {
  .hud {
    top: max(0.35rem, var(--safe-top));
  }
  .hud > div {
    padding: 0.28rem 0.38rem;
  }
  .game-toolbar {
    bottom: max(0.35rem, var(--safe-bottom));
  }
  .game-toolbar button {
    min-height: 44px;
    padding: 0.2rem;
  }
  .hud {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto auto;
  }
}

@media (hover: none) {
  .game-toolbar button[data-power]::after,
  .game-toolbar button[data-action="swap"]::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
