/* ==================== SPACE DASH — style ==================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cyan: #22e5ff;
  --magenta: #ff2ec4;
  --purple: #8b5cf6;
  --deep: #020010;
}

html, body {
  height: 100%;
  background: var(--deep);
  font-family: 'Rubik', system-ui, sans-serif;
  color: #eaf6ff;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;      /* ingen iOS-callout ved langt tryk */
  overscroll-behavior: none;        /* ingen gummibånds-scroll under spil */
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1px 1px at 12% 24%, #fff8, transparent),
    radial-gradient(1px 1px at 68% 12%, #9be8ff88, transparent),
    radial-gradient(1.5px 1.5px at 84% 66%, #ffc9f288, transparent),
    radial-gradient(1px 1px at 34% 78%, #fff6, transparent),
    radial-gradient(1px 1px at 52% 42%, #fff4, transparent),
    radial-gradient(1200px 600px at 50% 120%, #2a1060 0%, var(--deep) 60%);
}

/* Spil-ramme: fast 16:9, letterbox-centreret */
#wrap {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  max-width: 1280px;
  max-height: 720px;
  box-shadow: 0 0 80px rgba(124, 58, 237, 0.35), 0 0 24px rgba(34, 229, 255, 0.15);
  border-radius: 10px;
  overflow: hidden;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--deep);
  -webkit-touch-callout: none;   /* stopper "Gem/Kopiér billede" ved langt tryk */
  -webkit-user-select: none;
  user-select: none;
}

/* ==================== HUD ==================== */

#hud {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 5;
}

#progress {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(60%, 560px);
  height: 10px;
  border: 1px solid rgba(155, 232, 255, 0.5);
  border-radius: 8px;
  background: rgba(10, 8, 40, 0.6);
  overflow: hidden;
}

#pbar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--purple), var(--magenta));
  box-shadow: 0 0 12px var(--cyan);
  border-radius: 8px;
  transition: width 0.1s linear;
}

#pct {
  position: absolute;
  top: 27px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', monospace;
  font-size: clamp(10px, 1.6vw, 13px);
  font-weight: 700;
  color: #9be8ff;
  text-shadow: 0 0 8px rgba(34, 229, 255, 0.8);
}

#attempts {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));   /* notch/punch-hole på mobil */
  bottom: max(12px, env(safe-area-inset-bottom));
  font-family: 'Orbitron', monospace;
  font-size: clamp(10px, 1.8vw, 14px);
  font-weight: 700;
  color: #cfd8ff;
  text-shadow: 0 0 8px rgba(139, 92, 246, 0.8);
}

#diff-tag {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  font-family: 'Orbitron', monospace;
  font-size: clamp(10px, 1.8vw, 14px);
  font-weight: 700;
  padding: 3px 10px;
  border: 1px solid var(--cyan);
  border-radius: 20px;
  background: rgba(10, 8, 40, 0.55);
}

#hud-buttons {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  font-size: clamp(16px, 2.2vw, 18px);
  padding: 9px 13px;               /* ekstra touch-mål på mobil (~44px) */
  touch-action: manipulation;      /* ingen dobbelttryk-zoom på knapper */
  background: rgba(10, 8, 40, 0.6);
  color: #eaf6ff;
  border: 1px solid rgba(155, 232, 255, 0.45);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s;
}
.hud-btn:hover { box-shadow: 0 0 12px rgba(34, 229, 255, 0.6); transform: translateY(-1px); }

/* ==================== Toast ==================== */

#toast {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 8px 22px;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: clamp(13px, 2.4vw, 20px);
  color: #ffd6f5;
  background: rgba(60, 8, 48, 0.75);
  border: 1px solid var(--magenta);
  border-radius: 24px;
  box-shadow: 0 0 24px rgba(255, 46, 196, 0.5);
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  z-index: 6;
}
#toast.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* ==================== Overlays ==================== */

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 0, 16, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10;
  overflow-y: auto;
}

.panel {
  text-align: center;
  padding: clamp(16px, 4vw, 40px);
  max-width: 92%;
}

.logo {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: clamp(28px, 6vw, 58px);
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #7df9ff, var(--cyan) 30%, var(--magenta) 75%, #ffd6f5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(34, 229, 255, 0.45));
  animation: logoPulse 2.6s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(34, 229, 255, 0.35)); }
  50%      { filter: drop-shadow(0 0 26px rgba(255, 46, 196, 0.55)); }
}

h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(24px, 5vw, 44px);
  color: #eaf6ff;
  text-shadow: 0 0 20px rgba(139, 92, 246, 0.7);
}

.win-title {
  background: linear-gradient(90deg, #2ee6a8, #7df9ff, var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(46, 230, 168, 0.5));
}

.subtitle {
  margin-top: 12px;
  font-size: clamp(13px, 2vw, 17px);
  color: #b9c6ff;
  line-height: 1.5;
}

/* Sværhedsgrad-kort */
#diff-cards {
  display: flex;
  gap: clamp(10px, 2vw, 20px);
  justify-content: center;
  margin: clamp(16px, 3.5vw, 30px) 0;
  flex-wrap: wrap;
}

.card {
  --accent: var(--cyan);
  flex: 1 1 150px;
  max-width: 210px;
  min-width: 140px;
  padding: clamp(12px, 2.4vw, 22px);
  background: linear-gradient(160deg, rgba(20, 16, 60, 0.9), rgba(8, 5, 28, 0.9));
  border: 1px solid var(--accent);
  border-radius: 16px;
  color: #eaf6ff;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 0 28px var(--accent), inset 0 0 18px rgba(255, 255, 255, 0.05);
  outline: none;
}

.card-name {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: clamp(17px, 2.6vw, 24px);
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent);
}

.card-stars {
  margin-top: 4px;
  color: var(--accent);
  font-size: clamp(12px, 1.8vw, 15px);
  letter-spacing: 0.2em;
}

.card-desc {
  margin-top: 10px;
  font-size: clamp(11px, 1.6vw, 13px);
  color: #b9c6ff;
  line-height: 1.45;
  min-height: 3.6em;
}

.card-best {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(155, 232, 255, 0.2);
  font-size: clamp(10px, 1.5vw, 12px);
  color: #8fa3d9;
}

/* Hint + knapper */
.hint {
  margin-top: 8px;
  color: #8fa3d9;
  font-size: clamp(11px, 1.7vw, 14px);
}

kbd {
  background: rgba(155, 232, 255, 0.12);
  border: 1px solid rgba(155, 232, 255, 0.4);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: 'Orbitron', monospace;
  font-size: 0.85em;
  color: #cffaff;
}

.stats {
  display: flex;
  gap: clamp(14px, 3vw, 36px);
  justify-content: center;
  margin: clamp(14px, 3vw, 26px) 0;
}

.stat {
  background: rgba(20, 16, 60, 0.7);
  border: 1px solid rgba(155, 232, 255, 0.3);
  border-radius: 14px;
  padding: clamp(10px, 2vw, 18px) clamp(16px, 3vw, 30px);
}

.stat-label { display: block; font-size: clamp(11px, 1.6vw, 13px); color: #8fa3d9; }
.stat-value {
  display: block;
  margin-top: 6px;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: clamp(15px, 2.6vw, 22px);
  color: #7df9ff;
  text-shadow: 0 0 10px rgba(34, 229, 255, 0.6);
}

.btn-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: clamp(13px, 2vw, 16px);
  padding: clamp(10px, 1.8vw, 14px) clamp(18px, 3vw, 28px);
  border-radius: 14px;
  border: 1px solid rgba(155, 232, 255, 0.5);
  background: rgba(20, 16, 60, 0.8);
  color: #eaf6ff;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.18s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 0 18px rgba(34, 229, 255, 0.45); }

.btn.primary {
  background: linear-gradient(90deg, rgba(34, 229, 255, 0.25), rgba(255, 46, 196, 0.25));
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(34, 229, 255, 0.35);
}
.btn.primary:hover { box-shadow: 0 0 26px rgba(255, 46, 196, 0.55); }

/* Små skærme */
@media (max-width: 560px) {
  .card { flex: 1 1 100%; max-width: 320px; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; text-align: left; align-items: center; }
  .card-name { grid-row: span 2; }
  .card-desc { min-height: 0; margin-top: 0; }
  .card-best { display: none; }
  .card-stars { display: none; }
}

/* ==================== MOBIL & TABLET ==================== */

/* Tip om at vende enheden (kun små portræt-skærme — spillet er på langs) */
#rotate-tip {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 18px;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 12px;
  color: #eaf6ff;
  background: rgba(10, 8, 40, 0.85);
  border: 1px solid var(--cyan);
  border-radius: 22px;
  box-shadow: 0 0 18px rgba(34, 229, 255, 0.35);
  pointer-events: none;
  white-space: nowrap;
  animation: logoPulse 2.6s ease-in-out infinite;
}
@media (orientation: portrait) and (max-width: 640px) {
  #rotate-tip { display: block; }
}

/* Kompakt menu på lave skærme (fx telefon på langs ~390px høj) */
@media (max-height: 480px) {
  .panel { padding: 10px 16px; }
  .logo { font-size: clamp(22px, 4.5vw, 34px); }
  .subtitle { margin-top: 4px; font-size: 12px; line-height: 1.35; }
  #diff-cards { margin: 8px 0; gap: 8px; }
  .card { padding: 8px 10px; min-width: 118px; }
  .card-desc { font-size: 11px; }
  .hint { font-size: 11px; line-height: 1.45; }
}
