/* Global */
body {
    margin: 0;
    padding: 0;
    background-color: #000;
    background: #000 url('img/background.png') no-repeat bottom center;
    color: #fff;
    font-family: sans-serif;
    text-align: center;
  }
  
  /* Header */
  header {
    margin: 0.5em 0;
  }
  header img {
    width: 50%;
    height: auto;
    display: block;
    margin: 0 auto;
  }
  
  /* Status */
  #status {
    margin: 0.5em 0;
  }
  
  /* Manuelle Eingabe */
  #manualInput input {
    background: #222;
    color: #fff;
    border: 1px solid #555;
    padding: 4px;
    margin-right: 4px;
  }
  #manualButtons button,
  #manualInput button {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 2px;
    padding: 4px 8px;
    cursor: pointer;
  }
  
  /* Tabelle */
  table {
    border-collapse: collapse;
    width: auto;
    margin: 1em auto;
    table-layout: fixed;
    display: inline-block;
    vertical-align: top;
  }

  /* Spieler hinzufügen Button */
  #addPlayerButton {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 0.5em auto;
    padding: 8px 16px;
    cursor: pointer;
    display: block;
  }

  #tablesContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 1.2em;
  }

  /* Spieler-Container nebeneinander */
  #tablesContainer > div {
    width: fit-content;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0 0.65em;
  }

  #tablesContainer > div > div {
    width: 100%;
    text-align: center;
  }

  #tablesContainer .tableArea {
    display: flex;
    justify-content: center;
  }

  #tablesContainer table {
    display: table;
    margin: 1em auto;
  }

  /* Inaktive Spieler: nur Tabelle halbtransparent */
  #tablesContainer .tableArea.inactive {
    opacity: 0.5;
  }

  /* Aktivieren Button über Tabelle */
  .playerActivateBtn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 0.5em auto;
    padding: 8px 16px;
    cursor: pointer;
    display: block;
  }
  .playerActivateBtn:disabled {
    background: #666;
    cursor: not-allowed;
  }

  /* Löschen-Buttons pro Spieler */
  .playerDeleteBtn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 0.5em auto;
    padding: 8px 16px;
    cursor: pointer;
    display: block;
    opacity: 0.5;
  }
  .playerDeleteBtn:not([disabled]) {
    opacity: 1;
    cursor: pointer;
  }
  .playerConfirmDeleteBtn {
    background: #8b0000;
    color: #fff;
    border: 1px solid #f55;
    margin: 0.5em auto;
    padding: 8px 16px;
    cursor: pointer;
    display: block;
  }
  th, td {
    border: 1px solid #fff;
    padding: 4px 8px;
    text-align: center;
    box-sizing: border-box;
  }
  tfoot td {
    font-weight: bold;
  }
  
  /* Spielername größer */
  .player-name {
    font-size: 1.5em;
    font-weight: bold;
  }

  /* Treffer-Markierung */
  tr.hit td {
    color: #FFD700;
  }
  tr.miss td {
    color: #FF6B6B;
  }
  
  /* Aktuelle Wurfzeile und Summenzeile */
  tr.current-row td,
  tfoot tr.current-row td {
    font-size: 3em;
    font-weight: bold;
    height: 56px;
    line-height: 56px;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Bull- und Total-Zeile: keine so große Schrift beim Hervorheben */
  table tbody tr:last-child.current-row td,
  table tfoot tr.current-row td {
    font-size: 2em;
  }

  /* Ziel-Spalte der hervorgehobenen Bull-Zeile kleiner als Punkte/Treffer */
  tbody tr:last-child.current-row td:first-child {
    font-size: 2em;
  }

  /* Bei Spielende bleibt die letzte Zielzeile gleich hoch wie ein Highlight */
  table.highlight-complete tbody tr:last-child td {
    font-size: 2em;
    font-weight: bold;
    height: 56px;
    line-height: 56px;
    padding-top: 0;
    padding-bottom: 0;
  }
  
  /* Summenzeile immer Gold und hervorgehoben */
  table tfoot tr {
    color: #FFD700;
    font-weight: bold;
    font-size: 2em;
  }

  /* Feste Spaltenbreite für Ziel-Spalte */
  table th:first-child,
  table td:first-child {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Punkte- und Treffer-Spalte konstant halten */
  table th:nth-child(2),
  table td:nth-child(2),
  table th:nth-child(3),
  table td:nth-child(3) {
    width: 75px;
    min-width: 75px;
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Input-Felder im Bearbeitungsmodus */
  .hit-input {
    background: #222;
    color: #fff;
    border: 0;
    box-shadow: inset 0 0 0 1px #555;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font: inherit;
    line-height: inherit;
    text-align: center;
  }

  /* Edit-Controls */
  #controlButtons {
    margin: 1em auto;
    width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .left-buttons, .center-buttons, .right-buttons {
    display: flex;
  }
  .center-buttons {
    flex: 1;
  }
  #controlButtons button {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 2px;
    width: 150px;
    padding: 8px 16px;
    cursor: pointer;
  }
  #autoPlayerBtn,
  #manualPlayerBtn {
    width: 150px;
    height: auto;
    padding: 6px 8px;
    white-space: nowrap;
  }
  #controlButtons #manualPlayerBtn {
    background: #8b0000 !important;
    color: #fff !important;
    border: 1px solid #f55 !important;
  }
  #controlButtons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* Controls Footer */
  #controlsFooterWrapper {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 51;
    margin: 0;
    padding: 0.5em 1em 0.75em;
    background: rgba(0, 0, 0, 0.88);
    border-top: 1px solid #333;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35);
    text-align: center;
    transition: all 0.3s ease;
  }

  #controlsFooterWrapper.collapsed {
    padding: 0.35em 1em;
  }

  #controlsFooterContent {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 0.5em;
    justify-content: center;
    align-items: center;
  }

  #controlsFooterContent #manualInput {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35em;
    margin: 0;
  }

  #controlsFooterContent #manualInput input {
    margin-right: 0;
    min-width: 110px;
  }

  #controlsFooterContent #manualButtons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3em;
  }

  #controlsFooterContent #controlButtons {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3em;
  }

  #controlsFooterContent #controlButtons .left-buttons,
  #controlsFooterContent #controlButtons .center-buttons,
  #controlsFooterContent #controlButtons .right-buttons {
    display: flex;
    flex: 0 0 auto;
    justify-content: center;
    flex-wrap: wrap;
  }

  #controlsFooterContent #manualButtons button,
  #controlsFooterContent #controlButtons button {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    margin: 0;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85em;
  }

  #controlsFooterContent #controlButtons #manualPlayerBtn {
    background: #8b0000 !important;
    color: #fff !important;
    border: 1px solid #f55 !important;
  }

  #controlsFooterContent button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .controlsToggleBtn {
    position: absolute;
    top: 6px;
    right: 8px;
    background: #444;
    color: #fff;
    border: 1px solid #555;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.85em;
    border-radius: 3px;
    transition: background 0.2s ease;
  }

  .controlsToggleBtn:hover {
    background: #666;
  }

  #appContainer {
    padding-bottom: 120px;
  }

  #playerOverviewWrapper {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 49;
    margin: 0;
    padding: 0.5em 1em 0.75em;
    background: rgba(0, 0, 0, 0.88);
    border-top: 1px solid #444;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.45);
    text-align: center;
    transition: all 0.3s ease;
  }

  #playerOverviewWrapper.collapsed {
    padding: 0.35em 1em;
  }

  .overviewToggleBtn {
    position: absolute;
    top: 6px;
    right: 8px;
    background: #444;
    color: #fff;
    border: 1px solid #555;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.85em;
    border-radius: 3px;
    transition: background 0.2s ease;
  }

  .overviewToggleBtn:hover {
    background: #666;
  }

  #playerOverviewTitle {
    margin: 0.25em 0;
  }

  #playerOverviewTable {
    width: 300px;
    table-layout: auto;
    display: table;
    margin: 0.5em auto 0;
  }

  #playerOverviewTable th:first-child,
  #playerOverviewTable td:first-child {
    width: 70%;
    max-width: none;
    white-space: normal;
    color: #fff;
  }

  #playerOverviewTable th:last-child,
  #playerOverviewTable td:last-child {
    width: 30%;
  }

  #playerOverviewTable tbody td {
    font-size: 2em;
    font-weight: bold;
  }

  #playerOverviewTable tbody td:last-child {
    color: #FFD700;
  }
