/* ============ Gravity Garden: Orbital Bloomer — UI stylesheet ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #04060f;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8ecf8;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
#game-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; display: block;
  touch-action: none;
}
.ui-layer { position: fixed; z-index: 40; }
.hidden { display: none !important; }

/* ---------- Top HUD (z 40) ---------- */
#top-hud {
  top: 0; left: 0; right: 0; z-index: 40;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(6,10,24,0.92) 0%, rgba(6,10,24,0) 100%);
  pointer-events: none;
}
#top-hud button, #top-hud .currency { pointer-events: auto; }
#hud-left { display: flex; flex-direction: column; gap: 2px; }
#hud-left .currency-row { display: flex; gap: 14px; }
.currency {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
#hud-left > .currency, #hud-left > div { display: flex; gap: 14px; align-items: center; }
#pollen-value { color: #ffd9f0; }
#fragment-value { color: #9fe8ff; }
#pollen-rate { font-size: 11px; color: #7ee787; font-variant-numeric: tabular-nums; }
#hud-right { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(140,170,255,0.25);
  background: rgba(10,16,38,0.75); color: #cfe0ff;
  font-size: 18px; cursor: pointer;
  transition: transform 0.09s ease-out, box-shadow 0.15s;
}
.icon-btn:hover { box-shadow: 0 0 12px rgba(80,220,255,0.35); }
.icon-btn:active { transform: scale(0.94); }

/* hazard banner */
#hud-center { position: absolute; left: 50%; transform: translateX(-50%); top: 8px; pointer-events: auto; }
#hazard-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px;
  background: rgba(40,8,12,0.9);
  border: 1px solid rgba(255,80,80,0.6);
  border-radius: 10px;
  font-weight: 700; letter-spacing: 0.5px; font-size: 14px;
  color: #ffb0a0;
  animation: bannerPulse 1s infinite;
  transition: transform 0.45s cubic-bezier(0.22,1,0.36,1);
}
#hazard-banner.telegraph { border-color: rgba(255,190,80,0.7); color: #ffd9a0; background: rgba(40,28,8,0.9); }
@keyframes bannerPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255,60,60,0.3); }
  50% { box-shadow: 0 0 22px rgba(255,60,60,0.75); }
}
#hazard-banner-timer { font-variant-numeric: tabular-nums; color: #fff; }
#storm-clear-btn {
  padding: 4px 10px; font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, #6a3fd0, #2d8fd0);
  color: #fff; border: none; border-radius: 6px; cursor: pointer;
}

/* ---------- Bottom action bar (z 50) ---------- */
#action-bar {
  bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; gap: 12px;
}
.action-btn {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 16px;
  border: 1px solid rgba(140,170,255,0.3);
  background: rgba(10,16,38,0.82);
  color: #dfe8ff; font-size: 24px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.09s ease-out, box-shadow 0.2s;
  backdrop-filter: blur(6px);
}
.action-btn .label {
  position: absolute; bottom: 3px; font-size: 9px; letter-spacing: 0.5px; opacity: 0.75;
}
.action-btn .key {
  position: absolute; top: 3px; right: 6px; font-size: 9px; opacity: 0.45;
}
.action-btn:active { transform: scale(0.94); }
.action-btn.active {
  box-shadow: 0 0 24px rgba(80,220,255,0.55);
  border-color: rgba(80,220,255,0.9);
  transform: scale(1.06);
  color: #9ff0ff;
}

/* ---------- Side panels (z 60) ---------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw);
  z-index: 60;
  background: rgba(7,11,26,0.96);
  border-left: 1px solid rgba(120,150,255,0.25);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.65,0,0.35,1);
  backdrop-filter: blur(10px);
}
.side-panel.open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; font-weight: 800; font-size: 15px; letter-spacing: 1px;
  border-bottom: 1px solid rgba(120,150,255,0.18);
  color: #bcd0ff;
}
.panel-header .panel-wallet { margin-left: auto; font-variant-numeric: tabular-nums; color: #ffd9f0; }
.panel-close {
  background: none; border: none; color: #8fa3d9; font-size: 16px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
}
.panel-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.panel-tabs { display: flex; border-bottom: 1px solid rgba(120,150,255,0.15); }
.panel-tabs .tab {
  flex: 1; padding: 10px; background: none; border: none;
  color: #7386b8; font-weight: 700; font-size: 12px; letter-spacing: 1px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.panel-tabs .tab.active { color: #9fe8ff; border-bottom-color: #4dd8ff; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; scrollbar-width: thin; }

.shop-section { font-size: 11px; letter-spacing: 2px; color: #6a7db0; margin: 14px 4px 8px; font-weight: 800; }
.shop-section:first-child { margin-top: 2px; }
.shop-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: rgba(20,28,58,0.7);
  border: 1px solid rgba(120,150,255,0.15);
  border-radius: 10px;
}
.shop-card.unaffordable { opacity: 0.45; }
.shop-card .card-icon { font-size: 26px; width: 38px; text-align: center; }
.shop-card .card-info { flex: 1; min-width: 0; }
.shop-card .card-title { font-weight: 700; font-size: 13px; color: #e8ecf8; }
.shop-card .card-sub { font-size: 11px; color: #8fa3d9; margin-top: 2px; }
.shop-card .card-cost { font-size: 13px; font-weight: 700; color: #ffd9f0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop-card .card-cost.fragments { color: #9fe8ff; }
.buy-btn {
  padding: 7px 14px; border-radius: 8px; border: none;
  background: linear-gradient(135deg, #2d8fd0, #3fd08a);
  color: #04121e; font-weight: 800; font-size: 12px; cursor: pointer;
  transition: transform 0.09s ease-out;
}
.buy-btn:active { transform: scale(0.94); }
.buy-btn:disabled { background: #2a3352; color: #5a6a94; cursor: not-allowed; }
.buy-btn.shake { animation: btnShake 0.3s; }
@keyframes btnShake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); }
}
.level-pips { display: flex; gap: 3px; margin-top: 3px; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: #2a3352; }
.pip.on { background: #4dd8ff; box-shadow: 0 0 6px rgba(77,216,255,0.7); }

/* codex */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3,5,14,0.72);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.22s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(760px, 94vw); max-height: 86vh;
  background: rgba(9,14,32,0.98);
  border: 1px solid rgba(120,150,255,0.3);
  border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: cardIn 0.34s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cardIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.codex-entry {
  padding: 14px 10px; text-align: center;
  background: rgba(20,28,58,0.7); border: 1px solid rgba(120,150,255,0.15);
  border-radius: 12px; cursor: pointer; transition: transform 0.12s, box-shadow 0.2s;
}
.codex-entry:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(60,120,255,0.25); }
.codex-entry.locked { opacity: 0.4; filter: grayscale(0.8); }
.codex-entry .c-icon { font-size: 30px; }
.codex-entry .c-name { font-size: 12px; font-weight: 700; margin-top: 6px; }
.codex-entry .c-dots { font-size: 10px; margin-top: 4px; color: #7ee787; letter-spacing: 2px; }
.codex-detail { padding: 4px 8px; }
.codex-detail h3 { font-size: 16px; margin-bottom: 4px; }
.codex-detail .desc { font-size: 12px; color: #9fb0dd; font-style: italic; margin-bottom: 10px; }
.stat-row { display: flex; align-items: center; gap: 8px; font-size: 11px; margin: 4px 0; color: #bcd0ff; }
.stat-bar { flex: 1; height: 7px; background: #1a2444; border-radius: 4px; overflow: hidden; }
.stat-bar > div { height: 100%; border-radius: 4px; }
.back-btn { background: none; border: 1px solid rgba(120,150,255,0.3); color: #9fe8ff; border-radius: 8px; padding: 6px 14px; cursor: pointer; font-weight: 700; font-size: 12px; margin-bottom: 10px; }

/* settings */
.settings-card { width: min(420px, 92vw); }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 6px; border-bottom: 1px solid rgba(120,150,255,0.1); font-size: 13px; }
.setting-row input[type=range] { width: 140px; accent-color: #4dd8ff; }
.setting-row select { background: #141c3a; color: #dfe8ff; border: 1px solid rgba(120,150,255,0.3); border-radius: 6px; padding: 4px 8px; }
.toggle { width: 42px; height: 22px; border-radius: 11px; background: #2a3352; position: relative; cursor: pointer; border: none; transition: background 0.2s; }
.toggle.on { background: #2d8fd0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.toggle.on::after { left: 22px; }

/* victory */
.victory-card { width: min(560px, 92vw); text-align: center; padding: 36px 28px; }
.victory-card h1 { font-size: 24px; background: linear-gradient(90deg, #ffd76a, #ff8ad0, #8afff0); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 14px; }
.victory-card p { font-size: 13px; color: #9fb0dd; margin-bottom: 12px; line-height: 1.6; }
.big-btn {
  display: block; width: 100%; padding: 14px; margin-top: 10px;
  border: none; border-radius: 10px; cursor: pointer;
  font-weight: 800; font-size: 14px; letter-spacing: 0.5px;
  background: linear-gradient(135deg, #6a3fd0, #d03fa8); color: #fff;
  transition: transform 0.1s;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.secondary { background: rgba(30,40,80,0.9); color: #9fb0dd; }

/* ---------- Toasts (z 80) ---------- */
#toast-container {
  position: fixed; top: 72px; right: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: min(340px, 80vw);
}
.toast {
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; line-height: 1.4;
  background: rgba(10,16,38,0.95);
  border: 1px solid rgba(120,150,255,0.3);
  transform: translateX(120%);
  animation: toastIn 0.38s cubic-bezier(0.16,1,0.3,1) forwards;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}
.toast.out { animation: toastOut 0.24s ease-in forwards; }
.toast.rare { background: rgba(24,20,64,0.95); border-left: 3px solid #4dd8ff; }
.toast.legendary {
  background: rgba(40,16,72,0.97); font-size: 14px;
  border: 1px solid transparent;
  background-image: linear-gradient(rgba(40,16,72,0.97), rgba(40,16,72,0.97)), linear-gradient(90deg, #ffd76a, #ff8ad0, #8afff0, #ffd76a);
  background-origin: border-box; background-clip: padding-box, border-box;
  animation: toastIn 0.38s cubic-bezier(0.16,1,0.3,1) forwards, shimmer 2s linear infinite;
}
@keyframes shimmer { to { filter: hue-rotate(360deg); } }
.toast.error { background: rgba(60,12,16,0.95); border-left: 3px solid #ff5a5a; animation: toastIn 0.38s cubic-bezier(0.16,1,0.3,1) forwards, errShake 0.3s 0.38s; }
@keyframes toastIn { to { transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes errShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- tooltip + seed picker (z 70) ---------- */
#tooltip {
  position: fixed; z-index: 70; pointer-events: none;
  padding: 5px 10px; border-radius: 7px;
  background: rgba(8,12,28,0.94); border: 1px solid rgba(120,150,255,0.35);
  font-size: 11px; font-weight: 600; white-space: nowrap;
  transform: translate(-50%, -130%);
}
#seed-picker {
  position: fixed; z-index: 70;
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; border-radius: 12px;
  background: rgba(8,12,28,0.96); border: 1px solid rgba(120,150,255,0.35);
  transform: translate(-50%, -110%);
  max-height: 50vh; overflow-y: auto;
  min-width: 190px;
}
.seed-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  background: rgba(24,32,64,0.8); border: 1px solid transparent;
  font-size: 12px; font-weight: 600;
}
.seed-option:hover { border-color: rgba(80,220,255,0.6); }
.seed-option .s-count { margin-left: auto; color: #8fa3d9; font-variant-numeric: tabular-nums; }
.seed-option .s-dot { width: 12px; height: 12px; border-radius: 50%; }

/* ---------- Loading (z 100) ---------- */
#loading-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at 50% 40%, #0b1230 0%, #04060f 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; transition: opacity 0.6s;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }
#loading-vine { font-size: 46px; animation: sprout 1.6s ease-in-out infinite; }
@keyframes sprout { 0%,100% { transform: scale(1) rotate(-4deg); } 50% { transform: scale(1.15) rotate(4deg); } }
#loading-screen h1 {
  font-size: 30px; letter-spacing: 8px; font-weight: 900;
  background: linear-gradient(90deg, #7ee787, #4dd8ff, #ff8ad0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#loading-screen h2 { font-size: 12px; letter-spacing: 6px; color: #6a7db0; font-weight: 600; }
#loading-bar-outer { width: min(320px, 70vw); height: 6px; background: #141c3a; border-radius: 3px; margin-top: 22px; overflow: hidden; }
#loading-bar-inner { width: 0%; height: 100%; background: linear-gradient(90deg, #3fd08a, #4dd8ff); border-radius: 3px; transition: width 0.3s; }
#loading-status { font-size: 11px; color: #56688f; margin-top: 8px; }

/* debug overlay */
#debug-overlay {
  position: fixed; left: 8px; bottom: 8px; z-index: 75;
  font-size: 10px; font-family: monospace; color: #7ee787;
  background: rgba(0,0,0,0.55); padding: 6px 9px; border-radius: 6px;
  pointer-events: none; white-space: pre; line-height: 1.5;
}

/* mobile */
@media (max-width: 700px), (pointer: coarse) {
  #top-hud { height: 48px; padding: 0 10px; }
  .currency { font-size: 14px; }
  .action-btn { width: 62px; height: 62px; }
  .action-btn .key { display: none; }
  #toast-container { top: 58px; right: 8px; }
  #hazard-banner { font-size: 11px; padding: 6px 10px; gap: 8px; }
}

/* ---------- additions ---------- */
.toast-sub { font-size: 11px; font-weight: 500; opacity: 0.75; margin-top: 3px; line-height: 1.35; }
#tooltip { white-space: normal; max-width: 220px; text-align: left; line-height: 1.5; }
#tooltip b { color: #9fe8ff; }
#tooltip .tt-row { display: flex; align-items: center; gap: 6px; font-size: 10px; margin: 2px 0; }
#tooltip .tt-row > span:first-child { width: 12px; opacity: 0.7; }
#tooltip .tt-bar { flex: 1; height: 6px; background: #1a2444; border-radius: 3px; overflow: hidden; }
#tooltip .tt-bar > i { display: block; height: 100%; background: #4dd8ff; border-radius: 3px; }
#ad-overlay {
  position: fixed; inset: 0; z-index: 95; display: none;
  align-items: center; justify-content: center;
  background: rgba(3,5,14,0.9); color: #6a7db0;
  font-size: 14px; letter-spacing: 2px; font-weight: 700;
}
