:root {
  --bg:      #0d0d0d;
  --surface: #161616;
  --border:  #2a2a2a;
  --text:    #f0f0f0;
  --muted:   #3a3a3a;
  --accent:  #2d6cdf;
  --warning: #c94040;
}

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

html {
  font-family: 'Roboto', sans-serif;
  font-size: min(10vh, 15vw);
  font-weight: bold;
  background-color: var(--bg);
  color: var(--text);
  text-align: center;
  padding: 0;
  transition: background-color 0.5s;
  box-sizing: border-box;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0;
}

.display-center {
  width: 100%;
  padding: 0 clamp(8px, 2vw, 20px);
  box-sizing: border-box;
}

table {
  width: 100%;
}

@media (max-width: 1200px) {
  /* reserved for future breakpoint overrides */
}

.frametime {
  font-size: min(16vh, 52vw);
}

.shotclock {
  font-size: min(38vh, 82vw);
}

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

.paused {
  color: #4a4a4a;
}

input, button {
  font-size: max(1.5vw, 3vh);
  border: none;
  padding: 0.7vw 2.2vw;
  margin-top: 0.4vw;
  margin-bottom: 0.4vw;
  background-color: #1e1e1e;
  color: var(--text);
  border-radius: 0.6vw;
  transition: background 0.15s, transform 0.1s;
  cursor: pointer;
}

button:hover {
  background-color: #282828;
}

button:active {
  background-color: #111;
  transform: translateY(2px);
}

button:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Frame-Zustandsfarben */
html.frame-idle    { background-color: #0d0d0d; }
html.frame-running { background-color: #04120a; }
html.frame-paused  { background-color: #121006; }
html.frame-finished { background-color: #1a0303; }

html.frame-paused .frametime .paused,
html.frame-paused #frametimeend {
  color: #b8a020;
}

/* Puls-Warnung (letzte Sekunden) — animation überschreibt background-color */
html.pulse-warning,
html.frame-idle.pulse-warning,
html.frame-running.pulse-warning,
html.frame-paused.pulse-warning {
  animation: pulse-bg 1s ease-in-out infinite;
}
@keyframes pulse-bg {
  0%   { background-color: #1a0404; }
  50%  { background-color: #3a0606; }
  100% { background-color: #1a0404; }
}

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

hr {
  border: none;
  border-top: 1px solid #1c1c1c;
  margin: 0.5em 0;
}

button + button {
  margin-left: 0.5vw;
}

.display-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.display-label {
  font-size: clamp(18px, 5.5vw, 56px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: 0 0 auto;
  text-align: right;
  padding-right: 0.2em;
  line-height: 1;
}

.display-time {
  flex: 0 0 auto;
  text-align: left;
  line-height: 0.88;
}

/* Corner buttons (Info + Gear) — identisch, nur Position unterschiedlich */
.corner-btn {
  position: fixed;
  font-size: clamp(20px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.04);
  color: #4a4a4a;
  border: 1px solid #222;
  width: 1.65em;
  height: 1.65em;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 100;
  box-shadow: none;
  border-radius: 0.35em;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.5s cubic-bezier(.4,2,.6,1);
}
.corner-btn:hover {
  color: #bbb;
  background: rgba(255, 255, 255, 0.09);
  border-color: #3a3a3a;
}
.corner-btn:active {
  box-shadow: none;
}
.gear-btn {
  top: 0.45em;
  right: 0.45em;
  font-style: normal;
}
.gear-btn:hover  { transform: rotate(60deg); }
.gear-btn:active { transform: rotate(90deg); }
.info-btn {
  top: 0.45em;
  left: 0.45em;
  font-style: italic;
  font-weight: bold;
}
.info-btn:hover  { transform: rotate(-15deg) scale(1.12); }
.info-btn:active { transform: rotate(-25deg) scale(1.05); }
.reset-btn {
  bottom: 0.45em;
  left: 0.45em;
}
.reset-btn:hover  { transform: rotate(-90deg); }
.reset-btn:active { transform: rotate(-180deg); }
.action-btn {
  bottom: 0.45em;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: 1.65em;
  padding: 0 0.6em;
}
.action-btn:hover { transform: translateX(-50%); background: rgba(255,255,255,0.09); border-color: #3a3a3a; color: #bbb; }
.action-btn:active { transform: translateX(-50%); box-shadow: none; }
.pause-btn {
  bottom: 0.45em;
  right: 0.45em;
}
.pause-btn:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* Setup Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.2em;
  padding: 1.8em 2.2em 1.5em;
  font-size: clamp(14px, 2vw, 22px);
  min-width: 300px;
  text-align: left;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

.modal-box.modal-narrow {
  max-width: 420px;
  width: 100%;
}

.modal-box h2 {
  margin: 0 0 1em;
  font-size: 1.25em;
  color: #ddd;
  letter-spacing: 0.05em;
}

.modal-box label {
  display: block;
  margin: 0.85em 0 0.28em;
  color: #555;
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: bold;
}

.modal-box input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  font-size: 1em;
  padding: 0.45em 0.7em;
  border-radius: 0.5em;
  margin: 0;
  background: #1e1e1e;
  border: 1px solid #333;
  color: #eee;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-box input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.25);
}

.modal-actions {
  margin-top: 1.5em;
  display: flex;
  gap: 0.7em;
}
.modal-actions button {
  flex: 1;
  font-size: 1em;
  padding: 0.55em 1em;
  margin: 0;
  border-radius: 0.6em;
  font-weight: bold;
  letter-spacing: 0.04em;
  box-shadow: none;
}
@media (max-width: 600px) {
  .modal-actions {
    flex-direction: column;
    gap: 0.5em;
  }
  .modal-actions button {
    font-size: 1em;
    padding: 0.65em 1em;
    border-radius: 0.7em;
  }
  .modal-box {
    font-size: clamp(16px, 4.5vw, 24px);
    padding: 1.4em 1.5em 1.2em;
    min-width: 0;
    width: calc(100vw - 2.5em);
    box-sizing: border-box;
  }
  .modal-box h2 {
    font-size: 1.3em;
  }
  .modal-box label {
    font-size: 0.8em;
  }
  .modal-box input[type="number"] {
    font-size: 1.1em;
    padding: 0.55em 0.7em;
  }
  .info-content {
    font-size: 1em;
  }
  .gear-btn, .info-btn, .corner-btn {
    font-size: clamp(36px, 9vw, 64px);
  }
}
.modal-actions button[type="submit"] {
  background: var(--accent);
  color: #fff;
}
.modal-actions button[type="submit"]:hover {
  background: #3a7df0;
}
.modal-actions button[type="button"] {
  background: #252525;
  color: #aaa;
}
.modal-actions button[type="button"]:hover {
  background: #2e2e2e;
  color: #ccc;
}

/* Checkbox-Zeile fuer 2. Haelfte */
.shot2-toggle-label {
  display: flex !important;
  align-items: center;
  gap: 0.6em;
  margin-top: 1.1em !important;
  color: #999 !important;
  font-size: 0.82em !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-weight: normal;
  cursor: pointer;
}

/* Halbzeit-Warnhinweis */
.half-flash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(160, 35, 35, 0.96);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: clamp(28px, 8vw, 100px);
  font-weight: bold;
  color: white;
  text-align: center;
  animation: flashfade 2.8s forwards;
}
.half-flash.show {
  display: flex;
}
@keyframes flashfade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Shot abgelaufen — Hintergrundfarbe */
html.shot-expired { background-color: #2a0303; }

/* Time-is-up-Overlay */
.timeup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 350;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.timeup-overlay.show {
  display: flex;
  animation: timeup-fade 2s forwards;
}
.timeup-text {
  font-size: clamp(40px, 12vw, 180px);
  font-weight: bold;
  color: white;
  letter-spacing: 0.05em;
  text-shadow: 0 0 30px rgba(255,80,80,0.7), 0 0 80px rgba(255,0,0,0.3);
  animation: timeup-scale 2s forwards;
}
@keyframes timeup-fade {
  0%   { opacity: 0; background: rgba(160,0,0,0); }
  15%  { opacity: 1; background: rgba(160,0,0,0.55); }
  65%  { opacity: 1; background: rgba(160,0,0,0.55); }
  100% { opacity: 0; background: rgba(160,0,0,0); }
}
@keyframes timeup-scale {
  0%   { transform: scale(0.5); opacity: 0; }
  20%  { transform: scale(1.05); opacity: 1; }
  30%  { transform: scale(0.98); }
  40%  { transform: scale(1.0); }
  70%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

/* Finish-Animation */
.finish-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.finish-overlay.show {
  display: flex;
  animation: finish-fade 3.5s forwards;
}
.finish-text {
  font-size: clamp(60px, 18vw, 260px);
  font-weight: bold;
  color: white;
  letter-spacing: 0.08em;
  text-shadow: 0 0 40px rgba(255,255,255,0.4), 0 0 120px rgba(255,255,255,0.15);
  animation: finish-scale 3.5s forwards;
}
@keyframes finish-fade {
  0%   { opacity: 0; background: rgba(0,0,0,0); }
  12%  { opacity: 1; background: rgba(0,0,0,0.55); }
  70%  { opacity: 1; background: rgba(0,0,0,0.55); }
  100% { opacity: 0; background: rgba(0,0,0,0); }
}
@keyframes finish-scale {
  0%   { transform: scale(0.4); opacity: 0; }
  18%  { transform: scale(1.06); opacity: 1; }
  28%  { transform: scale(0.97); }
  38%  { transform: scale(1.0); }
  75%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(1.08); opacity: 0; }
}


/* Info button — oben links (nur Positionierung, Rest in .corner-btn) */
.info-btn {
  left: 0.45em;
  font-style: italic;
  font-weight: bold;
}
.info-btn:hover  { transform: rotate(-15deg) scale(1.12); }
.info-btn:active { transform: rotate(-25deg) scale(1.05); }

/* Info modal content */
.info-content {
  color: #bbb;
  font-size: 0.88em;
  font-weight: normal;
  line-height: 1.55;
  max-height: 65vh;
  overflow-y: auto;
}
.info-content h3 {
  margin: 0.9em 0 0.3em;
  color: #ddd;
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: bold;
}
.info-content p {
  margin: 0 0 0.3em;
}
.info-content ul {
  margin: 0.2em 0 0;
  padding-left: 1.4em;
}
.info-content li {
  margin-bottom: 0.25em;
}
.info-keys {
  width: 100%;
  border-collapse: collapse;
}
.info-keys td {
  padding: 0.25em 0.5em 0.25em 0;
  vertical-align: middle;
}
.info-keys td:first-child {
  width: 1%;
  white-space: nowrap;
  text-align: left;
}
kbd {
  display: inline-block;
  background: #252525;
  border: 1px solid #444;
  border-radius: 0.3em;
  padding: 0.1em 0.45em;
  font-size: 0.85em;
  font-family: monospace;
  font-weight: normal;
  color: #ccc;
  box-shadow: 0 2px 0 #111;
}
