:root {
  --bg-primary: #0b0d17;
  --bg-card: #12141f;
  --bg-surface: #1a1d2e;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #f43f5e;
  --accent-yellow: #f59e0b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --radius: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  background: #07080e;
  background-image: radial-gradient(circle at 50% 0%, #151828 0%, #07080e 70%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #07080e; }
::-webkit-scrollbar-thumb { background: #1a1d2e; border-radius: 5px; border: 2px solid #07080e; }
::-webkit-scrollbar-thumb:hover { background: #00d2ff; }

a { color: var(--accent-blue); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--text-primary); }

/* Header */
header {
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(7, 8, 14, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  text-shadow: 0 0 15px rgba(255,255,255,0.2);
}
.logo span { 
  color: transparent;
  background: linear-gradient(90deg, #00d2ff, #f72585);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Main Container */
main { flex: 1; padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* Navigation / Categories */
.category-nav {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }

.nav-pill {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  padding: 12px 24px;
  border-radius: 30px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}
.nav-pill:hover { 
  background: rgba(255,255,255,0.08); 
  color: #fff; 
  transform: translateY(-2px); 
  box-shadow: 0 4px 15px rgba(0,0,0,0.3); 
  border-color: rgba(255,255,255,0.2); 
}
.nav-pill.active { 
  background: linear-gradient(135deg, #00d2ff, #3a0ca3); 
  border-color: transparent; 
  color: #fff; 
  box-shadow: 0 8px 25px rgba(0, 210, 255, 0.4); 
}

/* Game Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 15px;
}

@media (max-width: 1200px) {
  .games-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
@media (max-width: 900px) {
  .games-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 600px) {
  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 400px) {
  .games-grid { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  transition: transform 0.2s, border-color 0.2s;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-blue);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.game-icon {
  font-size: 2rem;
  background: var(--bg-surface);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.game-info-card { flex: 1; }
.game-card h3 { margin: 0 0 5px 0; font-size: 1.1rem; color: var(--text-primary); }
.game-card p { margin: 0; color: var(--text-secondary); font-size: 0.85rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card-meta { display: flex; gap: 8px; margin-top: 10px; }
.badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Game Page & Wrapper */
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.game-header {
  width: 100%;
  max-width: 800px;
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.game-header-top {
  display: flex;
  align-items: center;
  gap: 20px;
}

.game-icon-large { font-size: 4rem; }
.game-title h1 { margin: 0 0 5px 0; font-size: 2rem; color: var(--text-primary); }

.game-meta-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; align-items: center; }

/* Canvas */
canvas {
  background-color: #000;
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  max-width: 100%;
  height: auto;
  display: block;
}

/* Difficulty Selector */
.diff-select {
  display: flex;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--bg-surface);
  border-radius: 8px;
  padding: 4px;
  gap: 4px;
}
.diff-select button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.diff-select button:hover { background: rgba(255,255,255,0.05); }
.diff-select button.active[data-val="easy"] { background: var(--accent-green); color: #fff; }
.diff-select button.active[data-val="medium"] { background: var(--accent-blue); color: #fff; }
.diff-select button.active[data-val="hard"] { background: var(--accent-red); color: #fff; }

/* Score Display */
.score-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--bg-surface);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.score-display span {
  font-weight: bold;
  color: var(--accent-yellow);
  font-size: 1.1rem;
}

/* Touch Controls */
#touch-controls { width: 100%; max-width: 800px; display: none; gap: 15px; justify-content: center; user-select: none; margin-top: 20px; }
@media(max-width: 800px) { #touch-controls { display: flex; flex-wrap: wrap; } }

.t-btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  width: 64px; height: 64px;
  border-radius: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: bold;
  border: 1px solid rgba(255,255,255,0.05);
  transition: background 0.1s, transform 0.1s;
  cursor: pointer;
  user-select: none;
}
.t-btn:active { background: var(--accent-blue); color: #fff; transform: scale(0.95); }
.t-btn.wide { width: 120px; font-size: 1rem; letter-spacing: 1px; }

/* Forms & UI Elements */
.search-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
  width: 100%;
}
.search-input {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  padding: 18px 30px;
  border-radius: 30px;
  font-size: 1.1rem;
  width: 100%;
  max-width: 600px;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.3);
}
.search-input:focus { 
  outline: none; 
  border-color: #00d2ff; 
  box-shadow: inset 0 0 10px rgba(0,210,255,0.1), 0 0 30px rgba(0, 210, 255, 0.3); 
  background: rgba(0, 210, 255, 0.05); 
}

.btn {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.btn:hover { 
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.1));
  transform: translateY(-2px);
  border-color: #00d2ff;
  box-shadow: 0 8px 20px rgba(0,210,255,0.3);
}

/* Footer / Legal */
footer {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(0deg, #07080e, transparent);
  margin-top: 60px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 210, 255, 0.3), rgba(247, 37, 133, 0.3), transparent);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

footer a { 
  color: var(--text-secondary); 
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}
footer a:hover { 
  color: #00d2ff; 
  text-shadow: 0 0 10px rgba(0,210,255,0.5);
}

.legal-content {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--bg-surface);
  line-height: 1.6;
}
.legal-content h1, .legal-content h2 { color: var(--text-primary); margin-top: 0; }
.legal-content p { color: var(--text-secondary); }

/* Language Toggle */
.lang-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  overflow: hidden;
}

.lang-flag-emoji {
  font-size: 1.4rem;
  line-height: 1;
  transition: transform 0.3s;
}

.lang-toggle:hover {
  background: rgba(0, 210, 255, 0.1);
  border-color: #00d2ff;
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.3);
}

.lang-toggle:hover .lang-flag-emoji {
  transform: scale(1.15);
}

/* Language Switcher (3 Sprachen mit SVG-Flaggen) */
.lang-switcher {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
  opacity: 0.55;
  filter: grayscale(0.7);
}

.lang-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.lang-btn:hover {
  opacity: 1;
  filter: grayscale(0);
  transform: scale(1.08);
  border-color: rgba(0, 210, 255, 0.5);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.3);
}

.lang-btn.active {
  opacity: 1;
  filter: grayscale(0);
  border-color: #00d2ff;
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.4);
}

[data-i18n] { transition: opacity 0.2s; }
