.scc-app {
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #20272d;
  --line: #35414a;
  --text: #f4f7f8;
  --muted: #9ca9b2;
  --accent: #f0b429;
  --accent-text: #f0b429;
  --danger: #d94b4b;
  --ok: #52b788;
  --cell-bg: #263139;
  --tile-new-bg: #5a4315;
  --tile-new-text: #fff6d8;
  --cell: 30px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 12px;
  box-sizing: border-box;
}

.scc-app.scc-theme-light {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #e9edf1;
  --line: #d2d9df;
  --text: #1b2126;
  --muted: #5a6770;
  --accent: #e8b021;
  --accent-text: #8a5a00;
  --danger: #c0392b;
  --ok: #2e7d52;
  --cell-bg: #c7d0d6;
  --tile-new-bg: #f5e2a4;
  --tile-new-text: #4a3a08;
}

.scc-app * {
  box-sizing: border-box;
}

.scc-topbar,
.scc-setup,
.scc-turns,
.scc-result,
.scc-grid-panel,
.scc-log-panel,
.scc-footer {
  max-width: 980px;
  margin: 0 auto 12px;
}

.scc-shift-label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 6px;
}

.scc-shift-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 640px) {
  .scc-shift-buttons {
    grid-template-columns: 1fr 1fr;
  }
}

.scc-topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.scc-topbar h1,
.scc-grid-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.scc-status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.scc-score {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scc-score span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
}

.scc-camera {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scc-camera video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #050607;
}

.scc-camera-actions,
.scc-turns,
.scc-footer,
.scc-grid-head {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scc-camera-actions,
.scc-footer,
.scc-grid-head {
  padding: 10px;
}

.scc-turns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.scc-extra-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.scc-extra-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 8px;
}

.scc-extra-row {
  display: grid;
  gap: 8px;
}

.scc-extra-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  padding: 8px 10px;
}

.scc-extra-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 650;
}

button:disabled {
  opacity: 0.55;
}

.scc-player {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.scc-player span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #1d1705;
}

.scc-result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 60px;
}

.scc-result strong {
  color: var(--accent-text);
}

.scc-empty,
.scc-note {
  color: var(--muted);
}

.scc-error {
  color: var(--danger);
}

.scc-candidates {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.scc-candidate {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  min-height: 58px;
}

.scc-candidate strong {
  color: var(--accent);
  font-size: 20px;
}

.scc-warn {
  display: block;
  color: #f2a35c;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.scc-grid-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scc-grid-head {
  justify-content: space-between;
  align-items: center;
}

.scc-grid-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scc-entry-hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
  padding: 0 10px 8px;
}

.scc-keyboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 10px;
}

.scc-keyboard button {
  min-height: 44px;
  padding: 0;
  font-size: 17px;
}

.scc-cell.is-cursor {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.scc-grid-wrap {
  overflow: auto;
  padding: 10px;
}

/* Brett-Styles gegen fremde Theme-CSS abgehaertet (!important + .scc-app-Praefix),
   damit Themes mit table{width:100%} oder td{padding:...} das Brett nicht aufblaehen. */
.scc-app .scc-grid {
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  min-width: 0 !important;
  width: auto !important;
  table-layout: fixed;
}

.scc-app .scc-grid th,
.scc-app .scc-grid td {
  border: 1px solid var(--line) !important;
  text-align: center;
  padding: 0 !important;
  margin: 0;
  vertical-align: middle;
}

.scc-app .scc-grid th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  width: 20px;
  height: var(--cell);
}

.scc-app .scc-cell {
  width: var(--cell);
  height: var(--cell);
  min-width: var(--cell);
  position: relative;
  background: var(--cell-bg);
}

.scc-app .scc-cell input {
  width: 100%;
  height: 100%;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  box-shadow: none !important;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-size: calc(var(--cell) * 0.46);
  text-transform: uppercase;
  position: relative;
  z-index: 2;
}

.scc-cell.is-new input {
  background: var(--tile-new-bg);
  color: var(--tile-new-text);
}

.scc-cell.has-tile input {
  font-weight: 750;
  background: #eee1c0;
  color: #1f1b13;
}

.scc-cell.bonus-DL {
  background: #292d4d;
}

.scc-cell.bonus-TL {
  background: #8d302f;
}

.scc-cell.bonus-DW {
  background: #b69416;
}

.scc-cell.bonus-TW {
  background: #7d7a31;
}

.scc-cell.scc-start-field {
  background: #d8ae22;
}

.scc-cell.scc-start-field::before {
  content: "";
  position: absolute;
  inset: 26%;
  background: #17202a;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 35%);
  opacity: 0.55;
}

.scc-cell.is-cursor {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.35);
}

.scc-cursor-arrow {
  position: absolute;
  top: 1px;
  right: 2px;
  z-index: 3;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-text);
  pointer-events: none;
}

.scc-bonus-label {
  position: absolute;
  inset: auto 2px 1px 2px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.62);
  font-size: 9px;
  line-height: 1;
  pointer-events: none;
  font-weight: 750;
}

.scc-cell.has-tile .scc-bonus-label,
.scc-cell.is-new .scc-bonus-label {
  color: rgba(0, 0, 0, 0.38);
}

.scc-footer {
  justify-content: space-between;
}

.scc-score-name {
  color: var(--muted);
}

.scc-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scc-theme-toggle {
  white-space: nowrap;
}

/* Steuerbox in der Sidebar (Richtungs-Umschalter + Hinweis), aus dem Brett ausgelagert. */
.scc-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.scc-controls button {
  white-space: nowrap;
}

.scc-controls .scc-entry-hint {
  margin: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.35;
}

/* Extra-Punkte ohne Legen (Bonus, Restpunkte, Korrektur). */
.scc-extra {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.scc-extra-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.scc-extra-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scc-extra-row input {
  width: 84px;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 15px;
}

.scc-extra-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.scc-extra-buttons button {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 13px;
}

/* Setup als zentriertes Overlay */
.scc-setup {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 11, 14, 0.72);
}

.scc-setup[hidden] {
  display: none;
}

.scc-setup-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  width: 100%;
  max-width: 460px;
}

.scc-setup h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.scc-setup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.scc-setup-label {
  color: var(--muted);
}

.scc-count-buttons {
  display: flex;
  gap: 6px;
}

.scc-count-buttons button {
  min-width: 48px;
}

.scc-count-buttons button.is-active {
  background: var(--accent);
  color: #1d1705;
  border-color: var(--accent);
}

.scc-setup-names {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.scc-name-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
}

.scc-name-field input {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  font-size: 16px;
}

.scc-setup-actions {
  display: flex;
  gap: 8px;
}

/* Ergebnis-Aufschluesselung */
.scc-result-head {
  font-size: 16px;
  margin-bottom: 8px;
}

.scc-word {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.scc-word-title {
  font-size: 16px;
}

.scc-range {
  color: var(--muted);
  font-weight: 500;
}

.scc-word-calc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.scc-result-total {
  margin-top: 8px;
  font-size: 16px;
}

/* Spielverlauf-Log */
.scc-log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scc-log-head {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.scc-log-head h2 {
  margin: 0;
  font-size: 18px;
}

.scc-log {
  max-height: 320px;
  overflow: auto;
  padding: 6px 10px 10px;
}

.scc-log-entry {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.scc-log-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.scc-log-num {
  color: var(--muted);
  font-size: 12px;
}

.scc-log-move {
  color: var(--accent-text);
  font-weight: 700;
}

.scc-log-running {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

.scc-log-word {
  margin-top: 4px;
  font-size: 14px;
}

/* Breite Bildschirme: Brett links, Bedienung rechts daneben (kein Scrollen). */
@media (min-width: 1024px) {
  .scc-app {
    padding: 8px 12px;
    /* kein erzwungenes 100vh -> kein Seiten-Scroll trotz oberem Versatz (Adminbar). */
    min-height: auto;
  }

  .scc-topbar {
    max-width: none;
    margin-bottom: 8px;
  }

  /* Brett links so gross wie die Hoehe erlaubt (JS/fitBoard setzt --cell),
     rechts eine schmale Sidebar; der Spielverlauf fuellt deren Resthoehe. */
  .scc-main {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    max-width: none;
    margin: 0;
  }

  .scc-board-col {
    flex: 0 0 auto;
    --cell: 34px;
  }

  .scc-board-col .scc-grid-panel {
    margin: 0;
  }

  .scc-side-col {
    flex: 0 0 340px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 12px;
  }

  .scc-side-col > * {
    margin: 0;
    max-width: none;
  }

  /* Spielverlauf scrollt innerhalb einer begrenzten Hoehe (JS setzt max-height). */
  .scc-side-col .scc-log {
    overflow: auto;
  }

  /* Footer kompakt nebeneinander statt gestapelt. */
  .scc-side-col .scc-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .scc-side-col .scc-footer button {
    font-size: 13px;
    padding: 9px 8px;
  }

  .scc-keyboard {
    gap: 5px;
    padding: 8px;
  }

  .scc-keyboard button {
    min-height: 28px;
    font-size: 14px;
  }
}

/* Maus-Desktops (kein Touch): keine Bildschirm-Tastatur noetig -> Brett nutzt die
   volle Hoehe und wird entsprechend gross. Getippt wird mit der echten Tastatur. */
@media (min-width: 1024px) and (pointer: fine) {
  .scc-keyboard {
    display: none;
  }
}

@media (max-width: 640px) {
  .scc-app {
    padding: 8px;
    /* Brett passt in die Geraetebreite, kein horizontales Scrollen. */
    --cell: min(30px, calc((100vw - 30px) / 16));
  }

  .scc-topbar {
    flex-direction: column;
  }

  .scc-score {
    width: 100%;
    justify-content: stretch;
  }

  .scc-score span {
    flex: 1;
    justify-content: space-between;
  }

  .scc-keyboard {
    grid-template-columns: repeat(7, 1fr);
  }
}
