/* ═══════════════════════════════════════════════════════
   WortGefecht – style.css
   Angepasst an das Original-Design (V3) inkl. Header-Fix
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #f0ede6;
  --text-muted: #888;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --key-bg: #818384;
  --key-text: #fff;
  --accent: #e8c84a;
  --flip-duration: 0.5s;

  /* Dynamische Größen */
  --tile-size: 56px;
  --tile-font: 1.4rem;
  --tile-gap: 5px;
  --key-h: 52px;
  --key-font: 0.85rem;
  --header-h: 56px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header Positionierung ── */
header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center; /* Zentriert das Logo in der Mitte */
  padding: 0 1rem;
  position: relative;
  flex-shrink: 0;
}

.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--accent);
  font-style: italic;
  margin-left: 1px;
}

/* Container für den Button rechts */
.header-right {
  position: absolute;
  right: 1rem; /* Hier kannst du den Abstand vom rechten Rand ändern */
  display: flex;
  align-items: center;
}

/* Der Einstellungs-Button selbst */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem; /* Größe des Zahnrads */
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  touch-action: manipulation; /* iOS Fix gegen Zoom */
}

.icon-btn:active {
  opacity: 0.6;
}

/* ── Screens ── */
.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

/* ── Setup / Hauptmenü ── */
#setup-screen {
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.setup-box {
  width: 100%;
  background: var(--surface);
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.setup-box h2 {
  font-family: 'DM Serif Display', serif;
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.8rem;
}

.opt-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.opt-group {
  display: flex;
  gap: 8px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.opt-btn {
  flex: 1;
  min-width: 40px;
  height: 40px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.opt-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.primary-btn {
  width: 100%;
  padding: 1rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Serif Display', serif;
  margin-top: 1rem;
}

/* ── Game Screen ── */
.subheader {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.pill {
  background: var(--surface2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

#board {
  display: grid;
  gap: var(--tile-gap);
  margin-bottom: 1.5rem;
}

/* ── Tiles ── */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  perspective: 1000px;
}

.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform var(--flip-duration);
  transform-style: preserve-3d;
}

.tile.reveal .tile-inner {
  transform: rotateX(180deg);
}

.tile-front, .tile-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: var(--tile-font);
  font-weight: 500;
  border-radius: 2px;
}

.tile-front {
  background: var(--bg);
  border: 2px solid var(--border);
}

.tile.pop .tile-front {
  border-color: var(--text-muted);
  animation: pop 0.1s linear;
}

.tile-back {
  transform: rotateX(180deg);
  color: #fff;
}

.tile[data-state="correct"] .tile-back { background: var(--correct); }
.tile[data-state="present"] .tile-back { background: var(--present); }
.tile[data-state="absent"] .tile-back  { background: var(--absent); }

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ── Keyboard ── */
#keyboard {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 10px;
}
.kb-row {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.key {
  flex: 1;
  height: var(--key-h);
  font-size: var(--key-font);
  background: var(--key-bg);
  color: var(--key-text);
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.key.wide {
  flex: 1.5;
  font-size: 0.7rem;
}

.key[data-state="correct"] { background: var(--correct); }
.key[data-state="present"] { background: var(--present); }
.key[data-state="absent"]  { background: var(--absent); opacity: 0.5; }

/* ── Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.overlay.show {
  display: flex;
}

.overlay-content {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: 20px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

/* ── Toast ── */
#toast {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background: #eee;
  color: #111;
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
}