/* ============================================================
   AIMC · 界面样式
   ============================================================ */
:root {
  --bg: #080b0f;
  --panel: rgba(15, 20, 26, 0.88);
  --panel-solid: #121820;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9eff5;
  --muted: #8a99a8;
  --accent: #86e07a;
  --accent-deep: #4f9c46;
  --accent-2: #6cc6ff;
  --danger: #ff7b72;
  --radius: 18px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --font: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #8fb6d6;
}

.hidden { display: none !important; }

/* 暗角，让画面更聚焦 */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(125% 95% at 50% 42%, rgba(0, 0, 0, 0) 48%, rgba(3, 7, 11, 0.34) 100%);
}

/* 水下滤镜 */
#water-tint {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(46, 118, 190, 0.28), rgba(14, 60, 110, 0.62));
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 0.18s linear;
  z-index: 4;
}

/* ============================================================
   HUD
   ============================================================ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.debug {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(8, 12, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #cfe0ee;
  font-size: 12px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
}
.debug span { color: var(--accent); font-weight: 600; }

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}
.crosshair i {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
  mix-blend-mode: difference;
}
.crosshair i:nth-child(1) { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.crosshair i:nth-child(2) { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

.hotbar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 7px;
  border-radius: 14px;
  background: rgba(9, 13, 18, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.slot canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.slot .num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
}
.slot.active {
  border-color: var(--accent);
  background: rgba(134, 224, 122, 0.14);
  transform: translateY(-5px);
  box-shadow: 0 0 0 1px rgba(134, 224, 122, 0.25), 0 10px 24px rgba(0, 0, 0, 0.4);
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(233, 239, 245, 0.55);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: opacity 0.6s ease;
}
.hint.fade { opacity: 0; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%) translateY(6px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 14, 19, 0.85);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.lock-tip {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(8, 12, 16, 0.7);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(10px);
  font-size: 13px;
  color: #cfe0ee;
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

/* ============================================================
   屏幕 / 面板
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen.soft {
  background: rgba(4, 7, 10, 0.62);
  backdrop-filter: blur(10px);
  z-index: 40;
}

#screen-home {
  background:
    radial-gradient(1200px 700px at 18% 8%, rgba(72, 148, 96, 0.24), transparent 62%),
    radial-gradient(900px 620px at 82% 78%, rgba(48, 104, 158, 0.28), transparent 62%),
    linear-gradient(180deg, #0a0f14 0%, #070a0e 55%, #05080b 100%);
  z-index: 50;
}

.home-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-grid {
  position: absolute;
  inset: -40%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: perspective(700px) rotateX(58deg) scale(1.4);
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 68%);
  pointer-events: none;
}
.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
}
.bg-blob.b1 { width: 520px; height: 520px; left: -140px; top: -180px; background: rgba(93, 200, 110, 0.35); }
.bg-blob.b2 { width: 620px; height: 620px; right: -200px; bottom: -260px; background: rgba(58, 128, 200, 0.32); }

.home {
  position: relative;
  width: 100%;
  max-width: 560px;
  z-index: 2;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.brand-cube {
  width: 62px;
  height: 62px;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.55));
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.brand-txt h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 0.06em;
  font-weight: 800;
  background: linear-gradient(100deg, #eaf7e6 8%, #8fe07f 48%, #66c9ff 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-txt p {
  margin: 7px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}

.lead {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.85;
  color: #b6c5d3;
}
.lead b { color: #e9f3ff; font-weight: 600; }

.seed-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.field span {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}
.field input {
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus { border-color: rgba(134, 224, 122, 0.55); background: rgba(134, 224, 122, 0.06); }

.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  height: 50px;
  border-radius: 13px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, border-color 0.14s ease, opacity 0.14s;
  color: var(--text);
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn.primary {
  background: linear-gradient(180deg, #97ef86, #5fae52);
  color: #0a230d;
  box-shadow: 0 14px 34px rgba(92, 180, 80, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover { box-shadow: 0 18px 40px rgba(92, 180, 80, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-strong);
  color: #d7e3ee;
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn.ghost:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.ghost.danger { color: #ffb3ad; border-color: rgba(255, 123, 114, 0.3); }
.btn.small { flex: 0 0 auto; height: 46px; padding: 0 18px; font-size: 13.5px; }

.save-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  font-variant-numeric: tabular-nums;
}

.settings {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.028);
}
.range { display: flex; flex-direction: column; gap: 10px; }
.range span { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.range b { color: var(--accent); font-variant-numeric: tabular-nums; }
.range input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}
.range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #10240f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.range input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #10240f; cursor: pointer;
}

.keys {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-size: 12px;
  color: var(--muted);
}
.keys li { display: flex; align-items: center; gap: 5px; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-bottom-width: 2px;
  font-family: inherit;
  font-size: 10.5px;
  color: #cfdbe6;
}

.home-foot {
  margin-top: 24px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(138, 153, 168, 0.6);
}

/* 加载层 */
.loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 12, 0.86);
  backdrop-filter: blur(6px);
}
.loading-box { width: min(340px, 82vw); text-align: center; }
.loading-cube {
  width: 54px; height: 54px; margin: 0 auto 22px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  animation: spin 3.2s linear infinite;
}
.loading-cube i { background: linear-gradient(160deg, #9ae87f, #4a8f42); border-radius: 3px; }
.loading-cube i:nth-child(2) { background: linear-gradient(160deg, #6cc6ff, #2e6fa8); animation-delay: 0.2s; }
.loading-cube i:nth-child(3) { background: linear-gradient(160deg, #ffd479, #b98a2f); }
.loading-cube i:nth-child(4) { background: linear-gradient(160deg, #f4a26b, #a85a2c); animation-delay: 0.4s; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { margin: 0 0 14px; font-size: 14px; color: #dceaf5; }
.bar { height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
#loading-bar {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6fce63, #86e07a, #6cc6ff);
  transition: width 0.18s ease;
}
.loading-box small { display: block; margin-top: 12px; font-size: 11.5px; color: var(--muted); }

/* 面板 */
.panel {
  width: min(400px, 92vw);
  padding: 26px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: rise 0.28s ease both;
  text-align: center;
}
.panel.wide { width: min(620px, 92vw); }
.panel h2 {
  margin: 0 0 18px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.panel .btn { width: 100%; margin-top: 10px; flex: none; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }
.small { font-size: 11.5px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  text-align: left;
}
.stats div {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats span { font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); }
.stats b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  margin: 16px 0 8px;
  max-height: 46vh;
  overflow: auto;
  padding-right: 4px;
}
.pal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.pal-item:hover { border-color: rgba(134, 224, 122, 0.5); background: rgba(134, 224, 122, 0.08); transform: translateY(-2px); }
.pal-item canvas { width: 34px; height: 34px; image-rendering: pixelated; }
.pal-item span { font-size: 10.5px; color: #b9c8d6; }

.fatal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(4, 7, 10, 0.9); }

/* ============================================================
   触屏
   ============================================================ */
.touch { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.stick {
  position: absolute;
  left: 22px;
  bottom: 26px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 15, 20, 0.35);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  touch-action: none;
}
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(233, 243, 250, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.touch-right {
  position: absolute;
  right: 16px;
  bottom: 24px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 10px;
  align-items: end;
  pointer-events: auto;
}
.tbtn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(12, 18, 24, 0.45);
  color: #dfeaf3;
  font-size: 13px;
  font-family: inherit;
  backdrop-filter: blur(6px);
  touch-action: none;
}
.tbtn.big { width: 68px; height: 68px; font-size: 15px; }
.tbtn:active { background: rgba(134, 224, 122, 0.3); }

@media (max-width: 620px) {
  .screen { padding: 18px; align-items: flex-start; padding-top: 6vh; }
  .brand-txt h1 { font-size: 33px; }
  .lead { font-size: 13px; }
  .settings { grid-template-columns: 1fr; gap: 14px; }
  .keys { grid-template-columns: 1fr; }
  .btn-row { flex-direction: column; }
  .hint { display: none; }

  .hotbar { gap: 4px; padding: 5px; bottom: 12px; border-radius: 12px; }
  .slot { width: 34px; height: 34px; border-radius: 8px; }
  .slot canvas { width: 24px; height: 24px; }
  .slot .num { font-size: 8px; top: 0; left: 3px; }

  .stick { left: 14px; bottom: 96px; width: 104px; height: 104px; }
  .stick-knob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
  .touch-right { right: 12px; bottom: 92px; gap: 8px; }
  .tbtn { width: 52px; height: 52px; font-size: 12px; }
  .tbtn.big { width: 60px; height: 60px; font-size: 14px; }

  .debug { font-size: 10.5px; padding: 6px 9px; top: 10px; left: 10px; }
}

@media (max-height: 720px) and (min-width: 621px) {
  .keys { display: none; }
  .home-foot { margin-top: 14px; }
  .lead { margin-bottom: 16px; }
}
