/* Orbmerge — merge-idle toy. Theme: teal/gold orb glow over dark board. */

:root {
  --bg: #0a0f14;
  --fg: #e8ecf1;
  --muted: #8b95a5;
  --accent: #46d9c9;
  --accent2: #f2c14e;
  --scrim: rgba(6, 9, 14, 0.78);
  --panel: rgba(16, 22, 30, 0.96);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg);
}

/* ---------- corner chrome ---------- */
.chrome {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 20;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font: 600 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* ---------- overlays: visibility driven purely by body state class ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 30;
}

body.state-menu   .overlay-menu,
body.state-paused .overlay-paused { display: grid; }

.panel {
  width: min(440px, 100%);
  padding: 28px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: var(--panel);
  text-align: center;
  animation: pop 180ms ease-out;
}

@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.panel h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: 0.5px; color: var(--accent); }
.panel h2 { margin: 0 0 14px; font-size: 24px; }
.tagline  { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.hi       { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.hint     { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #06231f;
  font: 700 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.btn-ghost.confirming {
  background: #d9534f;
  color: #fff;
  border-color: #d9534f;
}

/* ---------- upgrade shop panel ---------- */
.shop {
  position: fixed;
  z-index: 25;
  right: calc(8px + env(safe-area-inset-right));
  top: calc(60px + env(safe-area-inset-top));
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: none;
}
body:not(.state-menu) .shop.open { display: block; }

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.shop-head h2 { margin: 0; font-size: 16px; color: var(--accent2); }
.shop-head .icon-btn { width: 32px; height: 32px; font-size: 18px; }

.shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.shop-row:first-of-type { border-top: none; }

.shop-info { flex: 1; min-width: 0; }
.shop-name { font-weight: 700; font-size: 14px; }
.shop-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.shop-lvl { color: var(--accent); font-size: 12px; margin-top: 4px; font-weight: 600; }

.shop-buy {
  flex: 0 0 auto;
  width: 84px;
  min-height: 44px;
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--accent2);
  color: #2a1e02;
}
.shop-cost { font-weight: 800; }

/* ---------- offline / earn toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  transform: translate(-50%, -140%);
  z-index: 40;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(70, 217, 201, 0.4);
  color: var(--fg);
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
  pointer-events: none;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}
