:root {
  --bg: #0b1020;
  --panel: rgba(17, 24, 45, 0.88);
  --line: rgba(148, 163, 184, 0.18);
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #a855f7;
  --good: #34d399;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 20% 0%, #172554 0%, #0b1020 55%, #070a14 100%);
  color: var(--fg);
  min-height: 100vh;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 840px;
  margin: 0 auto;
  padding: 20px 18px 36px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 12px var(--good);
}

.brand-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.clock {
  font-family: ui-monospace, monospace;
  font-size: 14px;
  color: var(--muted);
}

.search-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(10px);
  margin-bottom: 18px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.engine-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.eng {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.eng:hover { color: var(--fg); background: rgba(255, 255, 255, 0.05); }
.eng.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(168, 85, 247, 0.25));
  border-color: rgba(56, 189, 248, 0.5);
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row input {
  flex: 1;
  background: rgba(9, 13, 28, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  color: var(--fg);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.search-btn {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, filter 0.15s;
}

.search-btn:hover { filter: brightness(1.1); }
.search-btn:active { transform: scale(0.98); }

.arcade-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.4);
}

.arcade-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.game-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gtab {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.gtab:hover { color: var(--fg); border-color: rgba(56, 189, 248, 0.4); }
.gtab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.3), rgba(168, 85, 247, 0.3));
  border-color: var(--accent);
}

.arcade-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  font-size: 13px;
  color: var(--muted);
  background: rgba(9, 13, 28, 0.75);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
}

.stat strong {
  color: var(--accent);
  font-family: ui-monospace, monospace;
  margin-left: 4px;
}

.icon-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--accent); }
.icon-btn.primary {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.stage-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: #060913;
  aspect-ratio: 760 / 440;
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: rgba(6, 9, 19, 0.76);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay h2 {
  margin: 0 0 8px;
  font-size: 26px;
  background: linear-gradient(135deg, #38bdf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.overlay p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  max-width: 460px;
}

.play-btn {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
}

.play-btn:hover { filter: brightness(1.1); }

.touch-pad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.touch-mid { display: flex; gap: 8px; }
.touch-pad button {
  width: 52px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
  color: var(--fg);
  font-size: 16px;
}

.hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.links-section {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px 8px;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.link-group { margin-bottom: 16px; }
.link-group h3 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}

.link-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  text-decoration: none;
  color: var(--fg);
  background: rgba(9, 13, 28, 0.72);
  border: 1px solid var(--line);
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}

.link-grid a:hover {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-1px);
}

.link-grid a span {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #7dd3fc;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(168, 85, 247, 0.22));
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.link-grid a strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.25;
}

.link-grid a small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
  color: #64748b;
}

@media (max-width: 640px) {
  .touch-pad { display: flex; }
  .search-btn { padding: 0 16px; }
}
