:root {
  --bg: #041425;
  --bg-alt: #0b2239;
  --panel: #102b44cc;
  --text: #edf6ff;
  --muted: #9eb9d1;
  --accent: #39d0ff;
  --danger: #ff5c7a;
  --line: #2d4d69;
  --ok: #66ffb5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, #1d3f66 0%, transparent 32%),
    radial-gradient(circle at 80% 10%, #1e3656 0%, transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, #030d17 100%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.toast-layer {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 20;
  display: grid;
  gap: 0.4rem;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: 280px;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  border: 1px solid #3f6685;
  background: #102841f0;
  color: #dcefff;
  font-size: 0.75rem;
  animation: toastIn 260ms ease, toastOut 260ms ease 2.2s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(#d7f2ff 0.7px, transparent 0.7px);
  background-size: 36px 36px;
  opacity: 0.25;
  animation: twinkle 7s linear infinite;
}

@keyframes twinkle {
  0% { transform: translateY(0px); opacity: 0.2; }
  50% { opacity: 0.35; }
  100% { transform: translateY(-10px); opacity: 0.2; }
}

.hero {
  text-align: center;
  padding: 1.2rem 1rem 1rem;
}

.hero-art {
  width: min(980px, 94vw);
  height: auto;
  border: 1px solid #2a4e6b;
  border-radius: 14px;
  box-shadow: 0 16px 26px #00000055;
  animation: floatArt 6s ease-in-out infinite;
}

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

.grid {
  width: min(1100px, 92vw);
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  backdrop-filter: blur(2px);
  animation: riseIn 400ms ease;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  margin: 0 0 0.7rem;
  display: flex;
}

.panel-head .icon {
  width: 1.2rem;
  height: 1.2rem;
  color: var(--accent);
}

.hud-panel {
  padding: 0.6rem 0.9rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.gauge {
  border: 1px solid #32526d;
  border-radius: 999px;
  background: #0a1f32;
  height: 12px;
  position: relative;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 0%;
  transition: width 280ms ease;
}

.gauge.explore .gauge-fill { background: linear-gradient(90deg, #38b9ff, #7ad9ff); }
.gauge.energy .gauge-fill { background: linear-gradient(90deg, #4dffbf, #7effd8); }
.gauge.overdrive .gauge-fill { background: linear-gradient(90deg, #ffba4d, #ffe18f); }
.gauge.cooldown .gauge-fill { background: linear-gradient(90deg, #ff6f8f, #ffb2c2); }

.wide {
  grid-column: 1 / -1;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.metric {
  min-height: 56px;
  border: 1px solid #33546f;
  border-radius: 10px;
  background: linear-gradient(180deg, #173958, #102a40);
  display: grid;
  place-items: center;
  padding: 0.2rem;
  gap: 0.2rem;
  cursor: pointer;
}

.metric .icon {
  width: 1rem;
  height: 1rem;
  color: #8de7ff;
}

.metric strong {
  font-size: 0.85rem;
  color: #ecf8ff;
}

.metric.changed {
  animation: pulseValue 480ms ease;
}

.metric:active {
  transform: scale(0.96);
}

@keyframes pulseValue {
  0% { transform: scale(1); box-shadow: 0 0 0 transparent; }
  45% { transform: scale(1.06); box-shadow: 0 0 14px #5acaff88; }
  100% { transform: scale(1); box-shadow: 0 0 0 transparent; }
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.store-btn {
  border: 1px solid #3b607f;
  background: linear-gradient(180deg, #143451, #102e48);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  padding: 0.5rem;
  min-height: 78px;
  display: grid;
  gap: 0.32rem;
  justify-items: center;
}

.store-btn .icon.big {
  width: 1.2rem;
  height: 1.2rem;
  color: #86e4ff;
}

.cost-row {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.cost-token {
  display: inline-flex;
  align-items: center;
  gap: 0.13rem;
  padding: 0.12rem 0.22rem;
  border-radius: 6px;
  background: #0d2235;
  border: 1px solid #2b4b66;
  font-size: 0.68rem;
}

.cost-token .icon {
  width: 0.68rem;
  height: 0.68rem;
}

.store-btn.affordable {
  border-color: #5dc4ff;
  animation: affordGlow 1.8s ease-in-out infinite;
}

@keyframes affordGlow {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50% { box-shadow: 0 0 12px #54ceff66; }
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.op-btn {
  border: 1px solid #3b607f;
  background: linear-gradient(180deg, #143451, #102e48);
  color: var(--text);
  border-radius: 10px;
  min-height: 50px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.op-btn .icon {
  width: 1.1rem;
  height: 1.1rem;
  transition: transform 180ms ease;
}

.op-btn.active {
  border-color: var(--ok);
  box-shadow: 0 0 10px #66ffb55c;
}

.op-btn.cooldown {
  opacity: 0.65;
}

.op-btn:hover .icon {
  transform: scale(1.14) rotate(-6deg);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger {
  border-color: #8a3448;
  background: linear-gradient(180deg, #4a1b28, #35101b);
}

#log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.log-item {
  width: 2rem;
  height: 2rem;
  border: 1px solid #2c4e6b;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #102a40;
}

.log-item .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: #9cdaf7;
}

#log li {
  animation: logIn 300ms ease;
}

@keyframes logIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

.guide h2 {
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.guide p {
  margin: 0.3rem 0;
  color: #d1e6f8;
  line-height: 1.35;
}

@media (max-width: 780px) {
  .icon-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .ops-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
