:root {
  --bg: #4d6d7d;
  --panel: #dbe4e8;
  --text: #243540;
  --bit-on: #4a9d5b;
  --bit-on-tint: #cfead4;
  --bit-off: #93a6ae;
  --accent: #e8823c;
  --bubble: #ecdcc0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.js-hint {
  margin: 0;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--text);
  text-align: center;
}

/* Buttons: dunkler Text auf Orange, weil Weiß-auf-Orange den 4.5:1-Kontrast reißt */
button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  min-height: 44px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button:focus-visible,
.bit-tile:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

/* Kopf */

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 8px;
}

.subtitle {
  margin: 0;
  font-size: 1.1rem;
}

/* Erklär-Szene */

.scene {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.figure {
  position: relative;
  width: 120px;
  height: 160px;
  flex-shrink: 0;
}

.figure__head {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #e8c9a0;
}

.figure__hair {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 66px;
  height: 34px;
  background: #1c1c22;
  border-radius: 50% 50% 0 0;
}

.figure__body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  background: #2f5233;
  clip-path: polygon(25% 0, 75% 0, 100% 100%, 0 100%);
}

.figure__arm {
  position: absolute;
  bottom: 20px;
  right: 6px;
  width: 18px;
  height: 46px;
  background: #3a6640;
  border-radius: 10px;
  transform: rotate(18deg);
}

.bubble {
  position: relative;
  flex: 1;
  min-width: 240px;
  background: var(--bubble);
  border-radius: 16px;
  padding: 18px 22px;
}

.bubble::after {
  content: "";
  position: absolute;
  left: -14px;
  bottom: 24px;
  border-width: 10px 14px 10px 0;
  border-style: solid;
  border-color: transparent var(--bubble) transparent transparent;
}

.bubble p {
  margin: 0;
}

/* Tafel / Bit-Reihe */

.board,
.karte {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

.board h2,
.versuche h2 {
  margin-top: 0;
}

.board__hint {
  margin-top: 0;
}

.bit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}

.bit-fallback {
  border-collapse: collapse;
  width: 100%;
}

.bit-fallback th,
.bit-fallback td {
  border: 1px solid var(--bit-off);
  padding: 6px 10px;
  text-align: center;
}

.bit-tile {
  flex: 1 1 64px;
  min-width: 64px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #fff;
  color: var(--text);
  border: 3px solid var(--bit-off);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.bit-tile__value {
  font-size: 0.95rem;
  opacity: 0.85;
}

.bit-tile__state {
  font-size: 1.6rem;
  font-weight: 700;
}

.bit-tile.is-on {
  background: var(--bit-on-tint);
  border-color: var(--bit-on);
  border-style: double;
  transform: translateY(-6px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}

.readout {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.readout__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.readout__label {
  font-size: 0.85rem;
  opacity: 0.75;
}

.readout__value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

/* Versuche */

.karte h3 {
  margin-top: 0;
}

.karte.is-solved {
  animation: pulse 0.6s ease;
  border: 3px solid var(--bit-on);
}

@keyframes pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.feedback {
  min-height: 1.4em;
  font-weight: 600;
}

.bit-row--small {
  max-width: 300px;
}

.footer {
  text-align: center;
  margin-top: 32px;
  font-size: 0.9rem;
  opacity: 0.85;
}

@media (max-width: 480px) {
  .bit-tile {
    flex-basis: calc(25% - 10px);
  }
}
