:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg-top: #0f172a;
  --bg-bottom: #0b1020;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #9fb2d1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(66, 104, 181, 0.2), transparent 35%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body {
  position: relative;
  overscroll-behavior: none;
  color: var(--text);
}

#board {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: grab;
}

#board.dragging {
  cursor: grabbing;
}

.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 11, 22, 0.28);
  backdrop-filter: blur(4px);
}

.card {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
}

.card {
  width: min(380px, 100%);
  padding: 24px;
  border-radius: 18px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.actions-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.join-row,
.action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.action-main {
  width: 100%;
}

input,
select,
.button,
.chip {
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 14px;
  border-radius: 12px;
  outline: none;
}

input {
  letter-spacing: 0.24em;
  text-align: center;
}

input::placeholder {
  color: #7f93b5;
  letter-spacing: 0.24em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button-primary {
  border-color: rgba(191, 219, 254, 0.22);
  background: rgba(59, 130, 246, 0.16);
}

.button-ghost {
  background: rgba(15, 23, 42, 0.72);
}

.button-square {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

.button-icon {
  white-space: nowrap;
}

.button-glyph,
.chip-icon {
  font-size: 15px;
  line-height: 1;
}

.chip-icon-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.chip-code[data-player="One"] .chip-icon-dot {
  background: rgba(239, 68, 68, 0.95);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35);
}

.chip-code[data-player="Two"] .chip-icon-dot {
  background: rgba(59, 130, 246, 0.95);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
}

.error {
  min-height: 18px;
  padding-left: 2px;
  color: #fca5a5;
  font-size: 13px;
}

.settings-card h2 {
  margin: 0;
  font-size: 24px;
}

.settings-stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.settings-field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.settings-field span {
  color: var(--text);
}

.settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.bottom-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.bottom-main,
.bottom-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.bottom-main {
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

#turn-pill {
  min-width: 96px;
  justify-content: center;
}

.clock-panel {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.clock-card {
  display: grid;
  gap: 2px;
  min-width: 88px;
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.clock-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.clock-time {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.clock-card-active {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(30, 41, 59, 0.98);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 12px 24px rgba(0, 0, 0, 0.24);
}

.clock-card-red.clock-card-active {
  border-color: rgba(248, 113, 113, 0.45);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.12), 0 10px 22px rgba(127, 29, 29, 0.28);
}

.clock-card-blue.clock-card-active {
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.12), 0 10px 22px rgba(30, 64, 175, 0.28);
}

.clock-card-critical .clock-time {
  color: #fca5a5;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chip-code {
  max-width: 100%;
  cursor: pointer;
}

#room-code-pill {
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-footer {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
  backdrop-filter: blur(8px);
  font-size: 12px;
  pointer-events: auto;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

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

@media (max-width: 720px) {
  .overlay {
    padding: 16px;
  }

  .card {
    padding: 20px;
  }

  .bottom-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
  }

  .bottom-main {
    min-width: 0;
  }

  .clock-panel {
    justify-content: center;
  }

  .bottom-actions {
    justify-content: flex-end;
    align-self: end;
  }

  .site-footer {
    bottom: 64px;
  }
}

@media (max-width: 520px) {
  .bottom-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bottom-main,
  .clock-panel,
  .bottom-actions {
    justify-content: center;
  }

  .clock-card {
    min-width: 96px;
  }
}
