:root {
  --bg: #05070a;
  --panel: rgba(10, 16, 30, 0.88);
  --panel-border: rgba(100, 160, 255, 0.25);
  --accent: #4aa8ff;
  --accent-2: #ffb84a;
  --text: #e8f0ff;
  --text-dim: #8a9ab0;
  --danger: #ff6b6b;
  --success: #6bff8e;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  touch-action: none;
}

#app, canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

.splash {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(20, 40, 80, 0.45), rgba(5, 7, 10, 0.95));
  transition: opacity 0.4s, visibility 0.4s;
  pointer-events: auto;
}

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

.card {
  max-width: 560px;
  width: 92%;
  padding: 2rem;
  border-radius: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.card h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.card p { color: var(--text-dim); line-height: 1.5; margin: 0 0 1.5rem; }

.tips {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.hud {
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
  pointer-events: none;
}

.hud-top, .hud-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
}

.hud-top { justify-content: space-between; }

.hud-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 0.35rem 0.75rem;
  backdrop-filter: blur(4px);
}

.hud-group .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.time-controls { display: flex; align-items: center; gap: 0.4rem; }
.time-controls input { width: 80px; }
.time-controls button, .toggle, .secondary, .primary, .icon {
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: transform 0.1s, background 0.15s;
}

.time-controls button:hover, .toggle:hover, .secondary:hover, .primary:hover, .icon:hover {
  background: rgba(255, 255, 255, 0.18);
}

.primary { background: var(--accent); color: #021025; font-weight: 600; }
.primary:hover { background: #6fc3ff; }

.icon { padding: 0.45rem 0.6rem; font-weight: 700; }

.buttons { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.help {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 0.5rem 0.85rem;
}

.help kbd, kbd {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border-radius: 0.25rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.75rem;
}

.help.hidden, .hud.hidden, .panel.hidden, .touch-ui.hidden, #info-mission.hidden { display: none !important; }

.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  width: 90%;
  max-width: 420px;
  max-height: 82vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}

.panel.right { top: 5rem; right: 1rem; }
.panel.left { top: 5rem; left: 1rem; }
.panel.center { top: 50%; left: 50%; transform: translate(-50%, -50%); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h2 { margin: 0; font-size: 1.25rem; }

.panel-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
  line-height: 1.5;
  font-size: 0.95rem;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--panel-border);
}

.fact-row { margin: 0.4rem 0; }
.fact-name { color: var(--accent); font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list.compact { gap: 0.3rem; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.8rem;
  border-radius: 0.6rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.list-item.done { border-color: var(--success); color: var(--success); }
.list-item .reward { font-size: 0.8rem; color: var(--accent-2); }

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.badge {
  text-align: center;
  padding: 0.6rem 0.4rem;
  border-radius: 0.6rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  opacity: 0.45;
  font-size: 0.75rem;
}
.badge.earned { opacity: 1; border-color: var(--accent-2); color: #fff; }
.badge .icon { font-size: 1.4rem; display: block; margin-bottom: 0.25rem; background: transparent; }

.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.quiz-option {
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.quiz-option:hover { background: rgba(255,255,255,0.12); }
.quiz-option.correct { border-color: var(--success); background: rgba(107, 255, 142, 0.12); }
.quiz-option.wrong { border-color: var(--danger); background: rgba(255, 107, 107, 0.12); }

.feedback {
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--panel-border);
  font-size: 0.95rem;
}
.feedback.correct { color: var(--success); }
.feedback.wrong { color: var(--danger); }

.toasts {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
  pointer-events: none;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: toast-in 0.35s ease, toast-out 0.35s ease 3.6s;
  animation-fill-mode: forwards;
  text-align: center;
  font-size: 0.95rem;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

.touch-ui { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.touch-zone {
  position: absolute;
  width: 45%;
  height: 60%;
  bottom: 0;
  pointer-events: auto;
}
.touch-zone.move-zone { left: 0; }
.touch-zone.look-zone { right: 0; }
.touch-buttons {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}
.touch-btn {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.3rem;
}

@media (max-width: 700px) {
  .hud-top { justify-content: flex-start; gap: 0.4rem; padding: 0.5rem; }
  .hud-group { padding: 0.25rem 0.5rem; font-size: 0.85rem; }
  .hud-group .label { display: none; }
  .hud-group.buttons { margin-left: auto; }
  .hud-group.buttons button { padding: 0.35rem 0.5rem; }
  .time-controls input { width: 60px; }
  .help { font-size: 0.7rem; gap: 0.35rem 0.7rem; }
  .panel { width: 92%; max-height: 76vh; }
  .panel.right, .panel.left { left: 4%; right: auto; top: 4.5rem; }
}

@media (max-width: 420px) {
  .hud-top { flex-direction: column; align-items: flex-start; }
  .hud-group { width: 100%; justify-content: space-between; }
  .hud-group.buttons { margin-left: 0; }
}
