/* Basis-Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #1a252f;
  --primary-hover: #2c3e50;
  --accent-color: #0066cc;
  --accent-hover: #004d99;
  --secondary-color: #5a6c7d;
  --secondary-hover: #4a5c6d;
  --background: #ffffff;
  --text-color: #ccc7c0;
  --white: #ffffff;
  --success-bg: #c3e6cb;
  --success-text: #ccc7c0;
  --success-border: #28a745;
  --warning-bg: #fff3cd;
  --warning-text: #664d03;
  --warning-border: #ffc107;
  --error-bg: #f8d7da;
  --error-text: #58151c;
  --error-border: #dc3545;
  --border-color: #6c757d;
  --shadow: rgba(0, 0, 0, 0.15);
}

.title {
  color: var(--text-color);
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Skip Link für Tastaturnavigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-color);
  color: var(--white);
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
}

/* Barrierefreiheit: Visuell verstecken, aber für Screen Reader zugänglich */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Fokus-Stile für bessere Tastaturnavigation und so */
*:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Header */
header {
  background: var(--primary-color);
  color: var(--white);
  padding: 1rem 0;
  text-align: center;
}

header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.5rem;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

nav li {
  display: inline-block;
}

nav a {
  color: var(--white);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s ease, transform 0.1s ease;
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

nav a:hover,
nav a:focus {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}

nav a:active {
  transform: scale(0.98);
}

/* Main Content */
main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  flex: 1;
  width: 100%;
}

/* Footer */
footer {
  background: var(--primary-color);
  color: var(--white);
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
}

footer p {
  margin: 0;
}

/* Überschriften Hierarchie */
h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
  color: var(--primary-color);
}

h3 {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  margin-bottom: 1rem;
  color: var(--primary-color);
}

/* Auth Sections */
.auth-section,
.start-section {
  background: var(--white);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  margin: 2rem auto;
  max-width: 500px;
}

.instructions {
  background: #e8f4f8;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 2rem 0;
  border-left: 4px solid var(--accent-color);
}

.instructions ul {
  margin-left: 1.5rem;
  margin-top: 1rem;
}

.instructions li {
  margin-bottom: 0.75rem;
  line-height: 1.8;
}

.auth-form {
  max-width: 400px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 1rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  min-height: 44px; /* Touch-Target-Größe */
}

.form-group input:focus {
  border-color: var(--accent-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

.form-group input:invalid:not(:placeholder-shown) {
  border-color: var(--error-border);
}

.form-group input:valid:not(:placeholder-shown) {
  border-color: var(--success-border);
}

.form-group small {
  color: #666;
  font-size: 0.875rem;
  display: block;
  margin-top: 0.25rem;
}

.hint-text {
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.auth-link {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--primary-color);
}

.auth-link a {
  color: var(--accent-color);
  text-decoration: underline;
  font-weight: 500;
}

.auth-link a:hover,
.auth-link a:focus {
  color: var(--accent-hover);
}

.auth-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn-primary,
.btn-secondary,
button[type="submit"] {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.3s ease;
  min-height: 44px;
  min-width: 44px;
  line-height: 1.5;
}

.btn-primary {
  background: var(--accent-color);
  color: var(--white);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--secondary-color);
  color: var(--white);
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: var(--secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}

.btn-secondary:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Game Section */
.game-section {
  background: var(--white);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
}

.game-info {
  background: #e8f4f8;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--accent-color);
}

.game-info p {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.game-info p:last-child {
  margin-bottom: 0;
}

.guess-form {
  display: flex;
  gap: 1rem;
  align-items: end;
  margin: 1.5rem 0;
}

.guess-form input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  min-height: 44px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.guess-form input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

/* Feedback */
.feedback {
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 4px;
  font-weight: 600;
  border: 2px solid;
  color: var(--accent-color);
}

.feedback.correct {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.feedback.too-low {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.feedback.too-high {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.error-message {
  background: var(--error-bg);
  color: var(--error-text);
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 4px;
  border: 2px solid var(--error-border);
  font-weight: 600;
}

.success-message {
  background: var(--success-bg);
  color: var(--success-text);
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 4px;
  border: 2px solid var(--success-border);
  font-weight: 600;
}

/* Stats Tabelle */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.stat-card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 5px var(--shadow);
  text-align: center;
  border: 1px solid var(--border-color);
}

.stat-card h3 {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-color);
}

/* Highscore Tabelle */
.highscore-section {
  background: var(--white);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  color: var(--primary-color);
}

.highscore-table {
  width: 100%;
  background: var(--white);
  border-collapse: collapse;
  box-shadow: 0 2px 10px var(--shadow);
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
}

.highscore-table caption {
  padding: 1rem;
  font-weight: 600;
  font-size: 1.1rem;
  text-align: left;
  caption-side: top;
}

.highscore-table th,
.highscore-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.highscore-table th {
  background: var(--primary-color);
  color: var(--white);
  font-weight: 600;
}

.highscore-table tbody tr:nth-child(even) {
  background: #f8f9fa;
}

.highscore-table tbody tr:hover {
  background: #e9ecef;
}

.highscore-table tbody tr:focus-within {
  outline: 2px solid var(--accent-color);
  outline-offset: -2px;
}

/* Result Section */
.result-card,
.result-section {
  background: var(--white);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  text-align: center;
  margin: 2rem 0;
  border: 2px solid var(--success-border);
}

.result-section h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.result-section p {
  color: var(--primary-color);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
  nav ul {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }

  .auth-section,
  .game-section,
  .highscore-section,
  .start-section {
    padding: 1rem;
  }

  .guess-form {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .result-actions,
  .auth-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  
  .highscore-table {
    font-size: 0.9rem;
  }
  
  .highscore-table th,
  .highscore-table td {
    padding: 0.75rem 0.5rem;
  }
}

/* Print Styles */
@media print {
  header,
  nav,
  footer,
  .btn-primary,
  .btn-secondary,
  .auth-buttons {
    display: none;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .highscore-table {
    box-shadow: none;
  }
}