:root {
  --bg: #0b0b0c;
  --surface: #151517;
  --line: #26262a;
  --text: #ededed;
  --muted: #8a8a90;
  --accent: #4ade80;
  --card-red: #d6303a;
  --radius: 8px;
  --space: 16px;
  --tabs: 44px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input {
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- Navigation ---------- */

.tabs {
  display: flex;
  height: var(--tabs);
  padding: 0 var(--space);
  gap: 4px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.tabs a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.fullscreen .tabs {
  display: none;
}

.conn {
  position: fixed;
  top: 14px;
  right: var(--space);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.fullscreen .conn {
  top: auto;
  bottom: 14px;
}

.conn i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--muted);
}

.conn[data-status="online"] i {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Bausteine ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 120ms, background 120ms;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn:hover {
  border-color: var(--muted);
}

.btn:focus-visible,
.input:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06210f;
  font-weight: 600;
}

.btn-primary:hover {
  border-color: var(--text);
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dot {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.22);
}

.muted {
  color: var(--muted);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space);
  height: 100%;
  padding: var(--space);
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  padding: 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Uhr ---------- */

.page-clock {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.page-clock.idle {
  cursor: none;
}

.clock {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 2vh, 24px) clamp(20px, 3vw, 48px) 0;
}

.clock-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space);
  font-size: clamp(20px, 2.4vw, 34px);
  color: var(--muted);
  flex: none;
}

.clock-top .level {
  color: var(--text);
  font-weight: 600;
}

.clock-center {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0px, 1vh, 12px);
}

.timer {
  font-size: min(23vw, 37vh);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  transition: color 120ms;
}

.timer.last-minute {
  color: var(--accent);
}

.timer.pause {
  font-size: min(15vw, 24vh);
  letter-spacing: 0.02em;
}

.timer-note {
  min-height: 1.4em;
  font-size: clamp(18px, 2.2vw, 30px);
  color: var(--muted);
}

.blinds-wrap {
  width: 100%;
  text-align: center;
  overflow: hidden;
}

.blinds {
  display: inline-block;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.clock.manual .blinds {
  font-weight: 700;
}

.clock-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: clamp(60px, 9vh, 76px);
}

.clock-next {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6em;
  font-size: clamp(22px, 3vw, 44px);
  color: var(--muted);
}

.clock-next strong {
  color: var(--text);
  font-weight: 600;
}

.clock-hint {
  min-height: 1.4em;
  text-align: center;
  font-size: clamp(14px, 1.5vw, 22px);
  color: var(--muted);
}

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px clamp(16px, 2.6vw, 40px);
  font-size: clamp(16px, 1.7vw, 24px);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend .dot {
  width: 1em;
  height: 1em;
}

.banner {
  position: fixed;
  top: clamp(52px, 8vh, 80px);
  left: 50%;
  z-index: 15;
  padding: 10px 24px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: clamp(20px, 2.6vw, 38px);
  font-weight: 600;
  white-space: nowrap;
}

.bar {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: opacity 150ms;
}

.idle .bar {
  opacity: 0;
  pointer-events: none;
}

.bar .btn {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
  background: transparent;
  border-color: transparent;
}

.bar .btn:hover {
  border-color: var(--line);
}

.bar .sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.segment {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment button {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}

.segment button.on {
  background: var(--line);
  color: var(--text);
}

.panel {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 16px;
  font-weight: 600;
}

.panel-body {
  padding: 16px 20px 20px;
}

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 20px;
  margin: 0;
}

.keys dt {
  color: var(--text);
  font-weight: 600;
}

.keys dd {
  margin: 0;
  color: var(--muted);
}

/* ---------- Blindtabelle ---------- */

.blind-table {
  width: 100%;
  border-collapse: collapse;
}

.blind-table th {
  padding: 4px 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.blind-table td {
  padding: 3px 4px;
  border-top: 1px solid var(--line);
}

.blind-table .input {
  min-height: 38px;
  padding: 0 8px;
}

.blind-table tr.current td:first-child {
  color: var(--accent);
  font-weight: 600;
}

.blind-table .row-actions {
  white-space: nowrap;
  text-align: right;
}

.mini {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}

.mini:hover {
  color: var(--text);
  border-color: var(--muted);
}

.after-plan {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Info ---------- */

.page-info {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.info {
  --card-h: min(11.6vh, 8vw);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 10px 24px 10px;
}

.ranks {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 0 10px 8px;
  list-style: none;
  color: var(--muted);
  font-size: clamp(15px, 2.2vh, 18px);
  font-weight: 500;
}

.hand-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  grid-auto-flow: column;
  column-gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hand {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
}

.hand.best {
  background: var(--surface);
  box-shadow: inset 1px 0 0 var(--accent);
}

.hand.best .hand-name {
  color: var(--accent);
}

.hand-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hand-rank {
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.hand-name {
  font-size: clamp(18px, 2.7vh, 22px);
  font-weight: 600;
  line-height: 1.15;
}

.cards {
  flex: none;
  display: flex;
  gap: 6px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: calc(var(--card-h) * 0.72);
  height: var(--card-h);
  background: #ededed;
  border-radius: 5px;
  color: #141416;
  line-height: 1;
}

.card b {
  font-size: calc(var(--card-h) * 0.34);
  font-weight: 600;
}

.card i {
  font-size: calc(var(--card-h) * 0.3);
  font-style: normal;
}

.card.red {
  color: var(--card-red);
}

.card.off {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
}

.strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.strip-live {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 20px;
}

.strip-live strong {
  font-weight: 600;
}

.strip-live span {
  color: var(--muted);
}

.strip-live .accent {
  color: var(--accent);
}

.strip-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: clamp(14px, 2.2vw, 28px);
  font-size: 16px;
  white-space: nowrap;
}

.strip-chips span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.strip-empty {
  flex: 1;
  color: var(--muted);
}

.strip-actions {
  flex: none;
  display: flex;
  gap: 8px;
}

.strip-actions .btn {
  min-height: 38px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.stack-title {
  font-size: 20px;
  font-weight: 600;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 18px;
}

.stack-list li {
  display: grid;
  grid-template-columns: 20px 44px 1fr;
  align-items: center;
  gap: 8px;
}

.stack-list span:not(.dot) {
  color: var(--muted);
}

.stack-list strong {
  font-weight: 600;
}

/* ---------- Regeln ---------- */

.rules {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.7);
}

.rules-panel {
  width: 100%;
  max-width: 860px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.rules-head {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.rules-head .input {
  min-height: 44px;
}

.rules-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
}

.rule-group {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rule {
  border-bottom: 1px solid var(--line);
}

.rule summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}

.rule summary::-webkit-details-marker {
  display: none;
}

.rule summary::after {
  content: "+";
  color: var(--muted);
}

.rule[open] summary::after {
  content: "−";
}

.rule-text {
  padding-bottom: 14px;
  color: var(--text);
  font-size: 15px;
}

.rule-example {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

.rule-example table {
  margin-top: 6px;
  border-collapse: collapse;
}

.rule-example th,
.rule-example td {
  padding: 3px 14px 3px 0;
  text-align: left;
  font-weight: 400;
}

.rule-example th {
  color: var(--text);
}

.no-result {
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

/* ---------- Steuerung ---------- */

.page-scroll {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.control {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-live {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.control-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space);
  color: var(--muted);
  font-size: 14px;
}

.control-blinds {
  margin-top: 2px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
}

.control-time {
  font-size: 34px;
  font-weight: 600;
}

.control-time.last-minute {
  color: var(--accent);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid .btn {
  min-height: 68px;
  font-size: 18px;
}

.control-grid .wide {
  grid-column: 1 / -1;
}

.control .segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.control .segment button {
  min-height: 52px;
  font-size: 16px;
}

.section-title {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
}

.btn-quiet {
  color: var(--muted);
  background: transparent;
}

/* ---------- Setup ---------- */

.setup {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}

.field-label strong {
  color: var(--text);
  font-weight: 600;
}

.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 8px;
  max-width: 240px;
}

.stepper .input {
  min-height: 48px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.stepper .btn {
  padding: 0;
  font-size: 20px;
}

.chip-input {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 92px 40px;
  gap: 8px;
  align-items: center;
}

.chip-input input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}

.chip-input input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.chip-input input[type="color"]::-webkit-color-swatch {
  border: 0;
}

.chip-input input[type="color"]::-moz-color-swatch {
  border: 0;
}

input[type="range"] {
  width: 100%;
  height: 32px;
  accent-color: var(--accent);
  background: transparent;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.preview h2 {
  font-size: 16px;
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 0 6px 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.data-table td {
  padding: 4px 6px 4px 0;
  border-top: 1px solid var(--line);
}

.data-table .input {
  min-height: 38px;
  padding: 0 8px;
}

.chip-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.summary {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary strong {
  font-weight: 600;
}

.warning {
  color: var(--text);
  padding-left: 10px;
  border-left: 1px solid var(--accent);
  font-size: 14px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.inline-field .input {
  width: 76px;
}

.blind-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.chip-up-note {
  color: var(--muted);
  font-size: 13px;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.setup-actions .btn {
  min-height: 52px;
  flex: 1 1 200px;
}

.running-note {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 480px) {
  .tabs {
    padding: 0 6px;
  }

  .tabs a {
    padding: 0 8px;
  }

  .conn span {
    display: none;
  }

  .conn {
    right: 12px;
    top: 18px;
  }
}
