/* ============================================================
   Boulder Dash – Global Styles
   ============================================================ */
:root {
  --bd-black:    #000000;
  --bd-white:    #FFFFFF;
  --bd-yellow:   #BFCE72;
  --bd-cyan:     #67B6BD;
  --bd-blue:     #40318D;
  --bd-green:    #55A049;
  --bd-red:      #883932;
  --bd-orange:   #8B5429;
  --bd-grey:     #787878;
  --bd-dgrey:    #505050;
  --bd-lgrey:    #9F9F9F;
  --bd-surface:  #0a0a1a;
  --bd-surface2: #141428;
  --bd-radius:   6px;
  --bd-transition: 200ms ease;
}

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

html, body {
  height: 100%;
  font-family: 'Courier New', Courier, monospace;
  background: var(--bd-black);
  color: var(--bd-white);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.bd-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.75rem;
  background: var(--bd-surface);
  border-bottom: 2px solid var(--bd-dgrey);
  flex-shrink: 0;
  z-index: 100;
}

.bd-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--bd-yellow);
  text-decoration: none;
}

.bd-nav-brand sup {
  font-size: 0.55em;
  align-self: flex-start;
  margin-left: 0.15em;
  line-height: 1;
}

.bd-nav-links {
  display: flex;
  gap: 0.25rem;
}

.bd-nav-links a {
  color: var(--bd-lgrey);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--bd-radius);
  font-size: 0.8rem;
  transition: all var(--bd-transition);
}

.bd-nav-links a:hover,
.bd-nav-links a.active {
  background: var(--bd-surface2);
  color: var(--bd-yellow);
}

/* ============================================================
   HUD (Heads-Up Display)
   ============================================================ */
.bd-hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 0.35rem 1rem;
  background: var(--bd-surface);
  border-bottom: 2px solid var(--bd-dgrey);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.bd-hud-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bd-hud-label {
  color: var(--bd-lgrey);
  font-size: 0.75rem;
}

.bd-hud-value {
  color: var(--bd-yellow);
  font-weight: 700;
  min-width: 3ch;
}

.bd-hud-value.diamonds {
  color: var(--bd-cyan);
}

.bd-hud-value.time {
  color: var(--bd-white);
}

.bd-hud-value.time.low {
  color: var(--bd-red);
  animation: blink 0.5s infinite;
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.bd-hud-level {
  color: var(--bd-green);
  font-size: 0.8rem;
}

/* ============================================================
   GAME AREA
   ============================================================ */
.bd-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  background: #050510;
}

.bd-game-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#bd-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============================================================
   LEVELS PAGE
   ============================================================ */
.bd-levels {
  max-width: 700px;
  width: 100%;
  padding: 1.5rem;
  overflow-y: auto;
  margin: 0 auto;
}

.bd-levels h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--bd-yellow);
}

.bd-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.bd-level-card {
  background: var(--bd-surface2);
  border: 1px solid var(--bd-dgrey);
  border-radius: var(--bd-radius);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--bd-transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.bd-level-card:hover {
  border-color: var(--bd-yellow);
  background: #1a1a35;
}

.bd-level-card h3 {
  font-size: 0.95rem;
  color: var(--bd-cyan);
  margin-bottom: 0.3rem;
}

.bd-level-card p {
  font-size: 0.8rem;
  color: var(--bd-lgrey);
}

.bd-level-card .bd-level-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--bd-grey);
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.bd-about {
  max-width: 700px;
  width: 100%;
  padding: 1.5rem;
  overflow-y: auto;
  margin: 0 auto;
}

.bd-about h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--bd-yellow);
}

.bd-about h3 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
  color: var(--bd-cyan);
}

.bd-about p, .bd-about li {
  font-size: 0.85rem;
  color: var(--bd-lgrey);
  line-height: 1.6;
}

.bd-about ul { padding-left: 1.5rem; margin-bottom: 0.75rem; }

.bd-card {
  background: var(--bd-surface2);
  border: 1px solid var(--bd-dgrey);
  border-radius: var(--bd-radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.bd-keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 1rem;
  font-size: 0.85rem;
}

.bd-keys dt { color: var(--bd-yellow); }
.bd-keys dd { color: var(--bd-lgrey); }

/* ============================================================
   RETRO PAGES (Highscore / Anleitung / Einstellungen)
   Pixel font, plain black, large readable text, no borders.
   ============================================================ */
.bd-retro-scroll {
  overflow-y: auto;
  align-items: flex-start !important;
  justify-content: center !important;
  background: var(--bd-black);
}

.bd-retro-page {
  max-width: 820px;
  width: 100%;
  padding: 1.5rem 1rem 3rem;
  margin: 0 auto;
  text-align: center;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 2rem;
  line-height: 1.3;
  color: var(--bd-lgrey);
}

.bd-retro-page,
.bd-retro-page * {
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: none;
  font-smooth: never;
}

.bd-retro-title {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--bd-yellow);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0.5rem 0 2rem;
  line-height: 1.4;
}

.bd-retro-h3 {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--bd-cyan);
  font-size: 1.05rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.6rem 0 0.9rem;
  line-height: 1.4;
}

.bd-retro-section { margin-bottom: 1.75rem; }

.bd-retro-page p,
.bd-retro-page dd,
.bd-retro-page li {
  font-family: inherit;
  font-size: 2rem;
  color: var(--bd-lgrey);
  line-height: 1.3;
}

.bd-retro-page b,
.bd-retro-page strong {
  color: var(--bd-yellow);
  font-weight: 400;
}

.bd-retro-list {
  list-style: none;
  padding: 0;
  text-align: left;
  max-width: 520px;
  margin: 0 auto;
}

.bd-retro-list li {
  padding: 0.15rem 0 0.15rem 1.5rem;
  position: relative;
}

.bd-retro-list li::before {
  content: '\25B8';
  position: absolute;
  left: 0;
  color: var(--bd-green);
}

.bd-retro-keys {
  display: inline-grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 2rem;
  text-align: left;
  font-size: 2rem;
  margin: 0 auto;
}

.bd-retro-keys dt { color: var(--bd-yellow); font-weight: 400; }
.bd-retro-keys dd { color: var(--bd-lgrey); }

.bd-retro-note {
  color: var(--bd-grey) !important;
  font-size: 1.6rem !important;
  margin-top: 0.75rem;
}

.bd-retro-levels {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 620px;
  text-align: left;
}

.bd-retro-levels li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0 1rem;
  align-items: baseline;
  padding: 0.25rem 0.25rem;
  font-size: 2rem;
  color: var(--bd-lgrey);
  border-bottom: 1px dashed var(--bd-dgrey);
}

.bd-retro-levels li:last-child { border-bottom: none; }

.bd-lvl-num {
  color: var(--bd-cyan);
  font-weight: 400;
  min-width: 2.5ch;
}

.bd-lvl-name { color: var(--bd-yellow); }

.bd-lvl-meta {
  color: var(--bd-green);
  font-size: 1.6rem;
  white-space: nowrap;
}

.bd-lvl-lbl {
  color: var(--bd-grey);
  font-size: 1.2rem;
  margin: 0 0.4rem 0 0.25rem;
}

/* Back hint (WordInvaders style) */
.bd-retro-backhint {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--bd-grey);
  font-size: 0.9rem;
  margin-top: 2.5rem;
  letter-spacing: 0.05em;
  line-height: 1.4;
  cursor: pointer;
}

.bd-retro-backhint:hover { color: var(--bd-yellow); }

/* Total / Version */
.bd-retro-total,
.bd-retro-version {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--bd-yellow);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 1.75rem;
}

/* Highscore table */
.bd-retro-page .bd-score-table {
  width: auto;
  margin: 0 auto;
  font-size: 1.9rem;
  color: var(--bd-lgrey);
  border-collapse: collapse;
}

.bd-retro-page .bd-score-table th,
.bd-retro-page .bd-score-table td {
  padding: 0.35rem 1rem;
}

.bd-retro-page .bd-score-table thead tr {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--bd-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bd-retro-page .bd-score-table thead th { padding-bottom: 0.7rem; }
.bd-retro-page .bd-score-table tbody tr { border-bottom: none; }
.bd-retro-page .bd-score-val { color: var(--bd-yellow); }

.bd-retro-page .bd-score-empty {
  color: var(--bd-grey);
  font-size: 1.9rem;
  padding: 1.5rem !important;
}

/* Hint line under title */
.bd-retro-hint {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--bd-grey);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  margin: -1rem 0 1.5rem;
}

/* Settings controls */
.bd-retro-page .bd-setting-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  font-size: 2rem;
  color: var(--bd-lgrey);
  padding: 0.3rem 0;
  position: relative;
}

.bd-retro-page .bd-setting-row:has(.bd-toggle:focus),
.bd-retro-page .bd-setting-row:has(.bd-toggle:focus-visible) {
  color: var(--bd-yellow);
}

.bd-retro-page .bd-setting-row:has(.bd-toggle:focus)::before,
.bd-retro-page .bd-setting-row:has(.bd-toggle:focus-visible)::before {
  content: '\25B8';
  position: absolute;
  left: 0;
  color: var(--bd-yellow);
  font-family: inherit;
}

.bd-retro-page .bd-toggle:focus,
.bd-retro-page .bd-toggle:focus-visible {
  outline: 2px solid var(--bd-yellow);
  outline-offset: 3px;
}

.bd-retro-page .bd-btn:focus,
.bd-retro-page .bd-btn:focus-visible {
  color: var(--bd-yellow);
  outline: none;
}

.bd-retro-page .bd-btn:focus::before,
.bd-retro-page .bd-btn:focus-visible::before {
  content: '\25B8 ';
  color: var(--bd-yellow);
}

.bd-retro-page .bd-setting-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
}

.bd-retro-page .bd-btn {
  min-width: 320px;
  background: transparent;
  border: none;
  color: var(--bd-lgrey);
  font-family: inherit;
  font-size: 2rem;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.bd-retro-page .bd-btn:hover,
.bd-retro-page .bd-btn:focus-visible {
  color: var(--bd-yellow);
  outline: none;
}

.bd-retro-page .bd-btn-danger { color: var(--bd-red); }
.bd-retro-page .bd-btn-danger:hover { color: var(--bd-yellow); background: transparent; }

/* Range slider – retro look */
.bd-setting-slider {
  display: grid !important;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
}

.bd-setting-slider > span:first-child { text-align: left; }

.bd-range {
  appearance: none;
  -webkit-appearance: none;
  width: 220px;
  height: 14px;
  background: var(--bd-surface2);
  border: 2px solid var(--bd-dgrey);
  border-radius: 0;
  outline: none;
  cursor: pointer;
}

.bd-range::-webkit-slider-runnable-track {
  height: 10px;
  background: var(--bd-surface2);
  border: none;
}

.bd-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 20px;
  margin-top: -7px;
  background: var(--bd-yellow);
  border: 2px solid var(--bd-dgrey);
  border-radius: 0;
  cursor: pointer;
}

.bd-range::-moz-range-track {
  height: 10px;
  background: var(--bd-surface2);
  border: none;
}

.bd-range::-moz-range-thumb {
  width: 12px;
  height: 18px;
  background: var(--bd-yellow);
  border: 2px solid var(--bd-dgrey);
  border-radius: 0;
  cursor: pointer;
}

.bd-range:focus,
.bd-range:focus-visible {
  border-color: var(--bd-yellow);
}

.bd-range:focus::-webkit-slider-thumb { background: var(--bd-white); }
.bd-range:focus::-moz-range-thumb { background: var(--bd-white); }

.bd-range-val {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--bd-yellow);
  min-width: 3ch;
  text-align: right;
}

/* ============================================================
   HIGHSCORE TABLE
   ============================================================ */
.bd-score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  color: var(--bd-lgrey);
}

.bd-score-table thead tr {
  color: var(--bd-cyan);
  border-bottom: 2px solid var(--bd-dgrey);
}

.bd-score-table th,
.bd-score-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
}

.bd-score-table th:nth-child(3),
.bd-score-table th:nth-child(4),
.bd-score-table td:nth-child(3),
.bd-score-table td:nth-child(4) {
  text-align: right;
}

.bd-score-table tbody tr {
  border-bottom: 1px solid rgba(80,80,80,0.4);
}

.bd-score-table tbody tr.bd-score-dim { color: var(--bd-grey); }
.bd-score-val { color: var(--bd-yellow); font-weight: 700; }
.bd-score-empty {
  text-align: center !important;
  padding: 1rem !important;
  color: var(--bd-grey);
}

/* ============================================================
   SETTINGS
   ============================================================ */
.bd-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--bd-lgrey);
  cursor: pointer;
}

.bd-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--bd-dgrey);
  position: relative;
  cursor: pointer;
  transition: background var(--bd-transition);
  flex-shrink: 0;
}

.bd-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bd-white);
  transition: transform var(--bd-transition);
}

.bd-toggle:checked { background: var(--bd-green); }
.bd-toggle:checked::after { transform: translateX(18px); }

.bd-setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.bd-btn {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--bd-radius);
  border: 1px solid var(--bd-dgrey);
  background: var(--bd-surface2);
  color: var(--bd-white);
  cursor: pointer;
  transition: all var(--bd-transition);
}

.bd-btn:hover {
  border-color: var(--bd-yellow);
  color: var(--bd-yellow);
}

.bd-btn-danger {
  border-color: var(--bd-red);
  color: var(--bd-red);
}

.bd-btn-danger:hover {
  background: var(--bd-red);
  color: var(--bd-white);
  border-color: var(--bd-red);
}

/* ============================================================
   LEGAL FOOTER LINKS (About)
   ============================================================ */
.bd-legal-links {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

.bd-legal-links a {
  color: var(--bd-lgrey);
  text-decoration: underline;
}

.bd-legal-links a:hover { color: var(--bd-yellow); }

body.bd-dpad-always .bd-touch-controls { display: block !important; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 340px;
}

.bd-toast {
  background: var(--bd-surface2);
  border: 1px solid var(--bd-dgrey);
  border-radius: var(--bd-radius);
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--bd-yellow);
  font-size: 0.8rem;
  animation: slideIn 0.3s ease;
}

.bd-toast.toast-success { border-left-color: var(--bd-green); }
.bd-toast.toast-danger  { border-left-color: var(--bd-red); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   MOBILE CONTROLS
   ============================================================ */
.bd-touch-controls {
  display: none;
  padding: 0.5rem;
  background: var(--bd-surface);
  border-top: 2px solid var(--bd-dgrey);
  flex-shrink: 0;
}

.bd-dpad {
  display: grid;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 50px 50px 50px;
  gap: 3px;
  justify-content: center;
}

.bd-dpad-btn {
  background: var(--bd-dgrey);
  border: 1px solid var(--bd-grey);
  border-radius: 6px;
  color: var(--bd-white);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.bd-dpad-btn:active { background: var(--bd-yellow); color: var(--bd-black); }
.bd-dpad-center { background: transparent; border: none; }

@media (max-width: 768px) {
  .bd-touch-controls { display: block; }
  .bd-hud { gap: 0.75rem; font-size: 0.8rem; }
  .bd-nav-links { display: none; }
}

@media (max-width: 480px) {
  .bd-hud { gap: 0.5rem; font-size: 0.7rem; flex-wrap: wrap; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bd-surface); }
::-webkit-scrollbar-thumb { background: var(--bd-dgrey); border-radius: 3px; }
