/* =============================================================
   CoSy-Tec / AV-Einsatz — Training Simulation
   Aussenverpackung: Montserrat / Roboto (CoSy-Tec Brand)
   Game-Canvas-UI: Press Start 2P (8-Bit Pixel-Art)
   ============================================================= */

:root {
  /* CoSy-Tec Brand Palette */
  --cosy-green:    #88C378;
  --cosy-green-d:  #4F7A42;
  --cosy-black:    #000000;
  --cosy-white:    #FFFFFF;
  --cosy-slate:    #9DA5AE;
  --cosy-fog:      #E5E7EB;

  /* Game-interne Dark-UI Palette */
  --pixel-dark:    #0d0d0d;
  --pixel-bg:      #1a1a2e;
  --pixel-surface: #16213e;
  --pixel-panel:   #232347;
  --pixel-text:    #e8e8e8;
  --pixel-amber:   #e6a817;
  --pixel-red:     #cc3333;
  --pixel-blue:    #1a5fa8;

  /* Font-Stack */
  --font-title: 'Montserrat', system-ui, sans-serif;
  --font-body:  'Roboto', system-ui, sans-serif;
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--pixel-dark);
  color: var(--pixel-text);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
  image-rendering: pixelated;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

.hidden { display: none !important; }

/* -------------------------------------------------------------
   Game Shell
   ------------------------------------------------------------- */
#game-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 8px;
  background: radial-gradient(circle at 50% 30%, #1f1f3a 0%, #0d0d0d 70%);
}

/* -------------------------------------------------------------
   HUD — behält Pixel-Font (Teil der Game-UI)
   ------------------------------------------------------------- */
#hud {
  width: 100%;
  max-width: 800px;
  background: var(--pixel-bg);
  border: 4px solid var(--cosy-green);
  border-bottom: none;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
}

.hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-label {
  color: var(--cosy-green);
  font-size: 8px;
  letter-spacing: 1px;
}

.hud-value {
  color: var(--pixel-text);
  font-size: 12px;
}

.hud-claim {
  color: var(--pixel-amber);
}

/* -------------------------------------------------------------
   Canvas
   ------------------------------------------------------------- */
#canvas-area {
  position: relative;
  width: 100%;
  max-width: 800px;
  background: var(--cosy-black);
  border: 4px solid var(--cosy-green);
  box-shadow: 0 0 20px rgba(136, 195, 120, 0.4);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: #2a2a3e;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#ui-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.overlay-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 220px;
  background: rgba(13, 13, 13, 0.92);
  border: 3px solid var(--cosy-green);
  padding: 10px;
  font-family: var(--font-pixel);
  font-size: 9px;
  pointer-events: auto;
  color: var(--pixel-text);
}

.panel-title {
  font-size: 10px;
  color: var(--cosy-green);
  margin-bottom: 8px;
  border-bottom: 2px solid var(--cosy-green-d);
  padding-bottom: 4px;
}

#ruestliste-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

#ruestliste-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  padding: 3px 4px;
  border: 1px solid #333;
  background: #111;
}

#ruestliste-items li.checked {
  background: #1d3320;
  border-color: var(--cosy-green);
  color: var(--cosy-green);
  text-decoration: line-through;
}

#ruestliste-items li .check {
  color: var(--cosy-green);
  font-size: 11px;
}

.panel-hint {
  margin-top: 8px;
  font-size: 7px;
  color: #888;
  text-align: center;
}

#dialog-panel {
  top: auto;
  bottom: 12px;
  left: 12px;
  right: 12px;
  width: auto;
  background: rgba(13, 13, 13, 0.95);
  font-size: 10px;
  line-height: 1.6;
}

#dialog-text {
  color: var(--pixel-text);
}

/* Fade layer */
#fade-layer {
  position: absolute;
  inset: 0;
  background: black;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s linear;
}

#fade-layer.fade-out {
  opacity: 1;
}

/* -------------------------------------------------------------
   Controls Bar — behält Pixel-Font
   ------------------------------------------------------------- */
#controls-bar {
  width: 100%;
  max-width: 800px;
  background: var(--pixel-bg);
  border: 4px solid var(--cosy-green);
  border-top: none;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-pixel);
  font-size: 8px;
  justify-content: center;
}

.ctrl b {
  color: var(--cosy-green);
  margin-right: 4px;
}

/* -------------------------------------------------------------
   Full-Screen Overlays (Start / End)
   ------------------------------------------------------------- */
.full-screen {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 13, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  background-image:
    repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(136,195,120,0.03) 2px,
      rgba(136,195,120,0.03) 4px);
  overflow-y: auto;
}

.start-content {
  max-width: 580px;
  width: 100%;
  text-align: center;
  background: var(--pixel-bg);
  border: 3px solid var(--cosy-green);
  padding: 28px 24px;
  box-shadow: 0 0 40px rgba(136,195,120,0.25);
}

/* -------------------------------------------------------------
   CoSy-Tec Logo Treatment (Start Screen)
   ------------------------------------------------------------- */
.ct-logo {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 6px;
}

.ct-logo-name    { color: var(--pixel-text); }
.ct-logo-sep     { color: var(--cosy-green); font-size: 18px; font-weight: 700; margin: 0 2px; line-height: 1; }
.ct-logo-product { color: var(--cosy-green); text-transform: uppercase; letter-spacing: 3px; font-size: 11px; }

/* -------------------------------------------------------------
   Game Description
   ------------------------------------------------------------- */
.game-description {
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.75;
  color: #a8aab8;
  text-align: left;
  margin: 16px 0;
  padding-left: 14px;
  border-left: 2px solid var(--cosy-green-d);
}

.ct-divider {
  height: 1px;
  background: var(--cosy-green-d);
  margin: 0 0 20px;
}

/* -------------------------------------------------------------
   Event Selection
   ------------------------------------------------------------- */
.event-choice h3 {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 600;
  color: var(--cosy-green);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.event-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.btn-event {
  background: var(--pixel-surface);
  color: var(--pixel-text);
  border: 2px solid var(--cosy-green-d);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: auto auto;
  text-align: left;
  gap: 3px 12px;
  align-items: center;
  font-family: var(--font-body);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.06s ease;
}

.btn-event:hover,
.btn-event:focus {
  background: var(--pixel-panel);
  border-color: var(--cosy-green);
  transform: translateX(-2px);
  outline: none;
}

.btn-emoji {
  grid-row: span 2;
  font-size: 26px;
  text-align: center;
}

.btn-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--cosy-green);
}

.btn-desc {
  font-size: 10px;
  color: var(--cosy-slate);
}

.start-hint {
  font-family: var(--font-body);
  font-size: 9px;
  color: #555;
  margin-top: 8px;
  letter-spacing: 0.5px;
}

/* -------------------------------------------------------------
   End Screen
   ------------------------------------------------------------- */
.end-wide {
  max-width: 660px;
}

.end-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--cosy-green);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.end-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--pixel-surface);
  padding: 9px 14px;
  border: 1px solid #2a2a3a;
  font-family: var(--font-body);
  font-size: 11px;
}

.stat-row span:first-child { color: var(--cosy-slate); }
.stat-row span:last-child  { color: var(--cosy-green); font-weight: 700; }

/* Primary Button */
.btn-primary {
  background: var(--cosy-green);
  color: var(--cosy-black);
  border: 2px solid var(--cosy-green-d);
  padding: 13px 24px;
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background 0.1s ease, transform 0.06s ease;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--cosy-white);
  transform: translateX(-2px);
  outline: none;
}

.btn-full { width: 100%; }

/* -------------------------------------------------------------
   Registration Form
   ------------------------------------------------------------- */
.reg-intro {
  font-family: var(--font-body);
  font-size: 10px;
  color: #888;
  margin: 16px 0 10px;
  text-align: left;
}

.reg-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.reg-form input[type="text"],
.reg-form input[type="email"] {
  font-family: var(--font-body);
  font-size: 11px;
  background: var(--pixel-surface);
  border: 2px solid var(--cosy-green-d);
  color: var(--pixel-text);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.1s ease;
}

.reg-form input[type="text"]:focus,
.reg-form input[type="email"]:focus {
  border-color: var(--cosy-green);
}

.reg-newsletter {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 10px;
  color: #999;
  cursor: pointer;
  padding: 6px 0;
  text-align: left;
}

.reg-newsletter input[type="checkbox"] {
  accent-color: var(--cosy-green);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Leaderboard
   ------------------------------------------------------------- */
.lb-title {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 700;
  color: var(--cosy-green);
  margin: 16px 0 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 16px;
  max-height: 260px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr 64px minmax(0, 120px);
  gap: 6px;
  align-items: center;
  padding: 7px 10px;
  background: var(--pixel-surface);
  border: 1px solid #252535;
  font-family: var(--font-body);
  font-size: 10px;
}

.lb-row.lb-me {
  background: #12221a;
  border-color: var(--cosy-green);
}

.lb-rank  { color: var(--pixel-amber); font-weight: 700; }
.lb-name  { color: var(--pixel-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: var(--cosy-green); font-weight: 700; text-align: right; }
.lb-info  { color: #444; font-size: 9px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lb-empty {
  font-family: var(--font-body);
  font-size: 10px;
  color: #555;
  text-align: center;
  padding: 20px;
}

.lb-global-rank {
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--cosy-green);
  font-weight: 700;
  text-align: center;
  padding: 8px 10px;
  background: #12221a;
  border: 1px solid var(--cosy-green);
  margin-bottom: 6px;
}

/* -------------------------------------------------------------
   Responsive
   ------------------------------------------------------------- */
@media (max-width: 840px) {
  #hud, #canvas-area, #controls-bar { max-width: 100%; }
  .ct-logo { font-size: 11px; }
  .game-description { font-size: 10px; }
  .overlay-panel { width: 170px; font-size: 8px; }
  .end-wide { max-width: 100%; }
}

/* -------------------------------------------------------------
   Touch Controls — sichtbar auf Touch-Geräten / kleinen Screens
   ------------------------------------------------------------- */
#touch-controls {
  display: none;
  width: 100%;
  max-width: 800px;
  background: var(--pixel-bg);
  border: 4px solid var(--cosy-green);
  border-top: none;
  padding: 12px 16px;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#tc-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tc-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tc-center-gap {
  width: 52px;
  height: 52px;
}

#tc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  max-width: 180px;
}

.tc-btn {
  width: 52px;
  height: 52px;
  background: var(--pixel-surface);
  color: var(--pixel-text);
  border: 2px solid var(--cosy-green-d);
  font-family: var(--font-pixel);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.06s ease, border-color 0.06s ease;
  -webkit-tap-highlight-color: transparent;
}

.tc-btn:active,
.tc-btn.tc-pressed {
  background: var(--cosy-green-d);
  border-color: var(--cosy-green);
  color: var(--cosy-black);
}

.tc-act {
  font-size: 9px;
  letter-spacing: 0.5px;
}

.tc-main {
  width: 64px;
  height: 52px;
  background: #1a2a1a;
  border-color: var(--cosy-green);
  color: var(--cosy-green);
  font-size: 10px;
}

.tc-main:active,
.tc-main.tc-pressed {
  background: var(--cosy-green);
  color: var(--cosy-black);
}

/* Tastaturhinweise ausblenden wenn Touch aktiv */
@media (pointer: coarse) {
  #controls-bar { display: none; }
  #touch-controls { display: flex; }
}

/* Auf sehr kleinen Screens immer Touch anzeigen */
@media (max-width: 600px) {
  #controls-bar { display: none; }
  #touch-controls { display: flex; }
}

/* Landscape-Kompaktmodus auf Mobilgeräten */
@media (pointer: coarse) and (max-height: 500px) {
  #touch-controls { padding: 6px 12px; }
  .tc-btn { width: 42px; height: 42px; font-size: 12px; }
  .tc-main { width: 54px; height: 42px; font-size: 9px; }
  .tc-center-gap { width: 42px; height: 42px; }
  #tc-actions { max-width: 160px; }
}
