:root {
  --cube-gray: #808080;
  --cube-border: #2c2c2c;
  --background: #f5f5f5;
  --text-color: #333;
  --header-bg: #fff;
  --primary-color: #007bff;
  --success-color: #28a745;
  --danger-color: #dc3545;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--background);
  color: var(--text-color);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: -webkit-fill-available;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--header-bg);
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.15rem;
  color: var(--text-color);
}

header p {
  font-size: 0.85rem;
  color: #666;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 1rem;
  gap: 0.75rem;
  overflow-y: auto;
}

/* Screens */
.screen {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.screen h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

/* Menu Screen */
#exercise-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.exercise-button-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.exercise-button {
  flex: 1;
  background: var(--header-bg);
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.exercise-button:hover,
.exercise-button:active {
  border-color: var(--primary-color);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.exercise-button strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.exercise-button span {
  color: #666;
  font-size: 0.9rem;
}

.general-info-button {
  margin-top: 0.5rem;
  border-style: dashed;
}

.btn-info {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  background: var(--header-bg);
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--primary-color);
  transition: all 0.2s ease;
  touch-action: manipulation;
  flex-shrink: 0;
}

.btn-info:hover,
.btn-info:active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

/* Info Screen */
.info-content {
  background: var(--header-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
  text-align: left;
}

.info-content h3 {
  font-size: 1.05rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.info-content h3:first-child {
  margin-top: 0;
}

.info-content p {
  margin-bottom: 0.75rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.info-content ul {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}

.info-content li {
  margin-bottom: 0.35rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

/* Ready Screen */
.ready-instructions {
  background: var(--header-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.key-hints {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.key-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.screen-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

kbd {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  background: #eee;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 0 #999;
}

/* Running Screen */
#running-screen {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  margin-bottom: 0.5rem;
}

#round-counter {
  font-size: 1.25rem;
  font-weight: bold;
}

/* Cube Container */
#cube-container {
  max-width: 400px;
  width: 100%;
  transition: background-color 0.1s ease;
  border-radius: 8px;
  flex-shrink: 0;
}

#cube {
  width: 100%;
  height: auto;
  display: block;
}

.cube-field {
  fill: var(--cube-gray);
  stroke: var(--cube-border);
  stroke-width: 2;
}

/* Hervorgehobenes Feld (zu erratendes Feld) */
.cube-field.highlight {
  fill: #505050;
  stroke: #ffffff;
  stroke-width: 3;
}

/* Feedback Animation */
.feedback-correct {
  background-color: rgba(40, 167, 69, 0.3);
}

.feedback-wrong {
  background-color: rgba(220, 53, 69, 0.3);
}

/* Answer Buttons */
#answer-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 400px;
  padding: 0 1rem;
}

.btn-answer {
  flex: 1;
  justify-content: center;
  padding: 1rem 1.5rem;
  font-size: 1.2rem;
  font-weight: 600;
  min-height: 60px;
}

.btn-exit {
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover,
.btn-success:active {
  background: #218838;
}

.btn-success kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover,
.btn-danger:active {
  background: #c82333;
}

.btn-danger kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

/* Color Choice Buttons */
#color-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
  padding: 0 1rem;
}

.btn-color {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-color kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

#btn-green {
  background: #00cc00;
}

#btn-green:hover,
#btn-green:active {
  background: #00aa00;
}

#btn-red {
  background: #ee0000;
}

#btn-red:hover,
#btn-red:active {
  background: #cc0000;
}

#btn-blue {
  background: #0066ff;
}

#btn-blue:hover,
#btn-blue:active {
  background: #0055dd;
}

#btn-orange {
  background: #ff8800;
}

#btn-orange:hover,
#btn-orange:active {
  background: #dd7700;
}

/* Corner Position Buttons */
#corner-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
  padding: 0 1rem;
}

.corner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.5rem;
}

.btn-corner {
  background: #4a5568;
  color: white;
  font-weight: 600;
  min-height: 70px;
}

.btn-corner:hover,
.btn-corner:active {
  background: #2d3748;
}

.btn-corner kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

.corner-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* Result Screen */
.result-summary {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.summary-item {
  background: var(--header-bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.summary-label {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.15rem;
}

.summary-value {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--primary-color);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  background: var(--header-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
}

.result-table th,
.result-table td {
  padding: 0.5rem;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.result-table th {
  background: #f8f9fa;
  font-weight: 600;
}

.result-table tbody tr:last-child td {
  border-bottom: none;
}

.result-correct td:nth-child(4) {
  color: var(--success-color);
  font-weight: bold;
}

.result-wrong td:nth-child(4) {
  color: var(--danger-color);
  font-weight: bold;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  min-width: 200px;
}

.btn kbd {
  font-size: 0.75rem;
  padding: 0.15rem 0.3rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover,
.btn-primary:active {
  background: #0056b3;
}

.btn-primary kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover,
.btn-secondary:active {
  background: #545b62;
}

.btn-secondary kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  color: white;
}

/* Desktop: Show kbd hints */
@media (min-width: 769px) {
  main {
    justify-content: center;
    padding: 2rem;
  }

  header {
    padding: 1.5rem;
  }

  header h1 {
    font-size: 2rem;
  }

  #cube-container {
    max-width: 500px;
  }

  #answer-buttons,
  #color-buttons,
  #corner-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 500px;
  }

  .btn-answer {
    min-height: 70px;
  }

  #color-buttons .btn-answer {
    flex: 1 1 45%;
  }

  .btn-exit {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.5rem 1rem;
  }
}

/* Mobile: Hide kbd hints, larger touch targets */
@media (max-width: 768px) {
  .btn kbd {
    display: none;
  }

  .ready-instructions {
    display: none;
  }

  .result-table th:nth-child(2),
  .result-table td:nth-child(2) {
    display: none;
  }

  #answer-buttons,
  #color-buttons,
  #corner-buttons {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: var(--background);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .btn-answer {
    flex: 1;
    min-width: 45%;
  }

  #color-buttons .btn-answer {
    flex: 1 1 45%;
  }

  .btn-exit {
    width: 100%;
    margin-top: 0.5rem;
  }

  main {
    padding-bottom: 180px;
  }
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  color: #999;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

footer a {
  color: #999;
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

/* Legal pages (Impressum, Datenschutz) */
.legal-page {
  text-align: left;
}

.legal-page h2 {
  text-align: center;
}

.legal-content {
  background: var(--header-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.legal-content h3 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.legal-content h3:first-child {
  margin-top: 0;
}

.legal-content h4 {
  font-size: 0.95rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  color: var(--text-color);
}

.legal-content p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.legal-content ul {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}

.legal-content li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.legal-content a {
  color: var(--primary-color);
  text-decoration: none;
}

.legal-content a:hover {
  text-decoration: underline;
}

.legal-actions {
  text-align: center;
  margin-top: 1rem;
}

.legal-actions .btn {
  display: inline-flex;
}

/* Very small screens */
@media (max-width: 380px) {
  header h1 {
    font-size: 1.3rem;
  }

  .summary-item {
    padding: 0.5rem 0.75rem;
  }

  .summary-value {
    font-size: 1.1rem;
  }
}
