* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: #0f1115;
  color: #e8eaed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header {
  padding: 14px 20px 4px;
  text-align: center;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #b8bcc4;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1a1d24 0%, #0f1115 75%);
}

#stage:focus-visible {
  box-shadow: inset 0 0 0 2px #74256c;
}

#dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.total {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-size: 16px;
  color: #c5c9d2;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  padding: 6px 12px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.total strong {
  color: #fff;
  font-weight: 700;
  font-size: 22px;
}

.bottom {
  padding: 4px 14px 10px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: stretch;
}

.controls {
  flex: 1.6 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-label {
  font-size: 14px;
  color: #e8eaed;
  font-weight: 700;
  min-width: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.counter {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1d24;
  border-radius: 12px;
  padding: 3px;
  gap: 4px;
}

.counter button {
  width: 44px;
  height: 36px;
  border: none;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: #2a2e38;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.counter button:active { transform: scale(0.92); }
.counter button:disabled { opacity: 0.25; cursor: not-allowed; }

.counter-value {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.roll-button {
  /* Höhe entspricht zwei Würfel-Zeilen (2 × 42px + 6px gap) */
  height: 90px;
  flex-shrink: 0;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: #74256c;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.roll-button:active { transform: scale(0.97); }
.roll-button:disabled { opacity: 0.5; cursor: not-allowed; }

.history {
  list-style: none;
  margin: 0;
  padding: 6px;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  background: #14171d;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.history:empty::before {
  content: "Verlauf";
  color: #4a4e57;
  font-size: 11px;
  text-align: center;
  padding: 8px 0;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.history-entry {
  background: #1a1d24;
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hist-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.hist-spec {
  font-size: 11px;
  color: #b8bcc4;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-total {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.hist-values {
  font-size: 10px;
  color: #6d717b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Schmale Viewports: Layout bleibt nebeneinander, wird aber kompakter,
   damit auf Handys nichts in die Spalte rutscht. */
@media (max-width: 480px) {
  .bottom { padding: 4px 8px 8px; gap: 8px; }
  .row { gap: 8px; }
  .row-label { min-width: 0; font-size: 13px; gap: 6px; }
  .swatch { width: 12px; height: 12px; }
  .counter { padding: 2px; gap: 2px; }
  .counter button { width: 36px; height: 32px; font-size: 20px; }
  .counter-value { font-size: 17px; min-width: 22px; }
  /* Höhe = 2 Würfel-Zeilen auf Mobile: 2 × 36px + 5px gap */
  .roll-button { height: 77px; font-size: 16px; border-radius: 12px; }
  .controls { gap: 5px; }
  .side-panel { gap: 5px; }
  .hist-spec { font-size: 10px; }
  .hist-total { font-size: 14px; }
  .hist-values { font-size: 9px; }
}
