* {
  box-sizing: border-box;
}

:root {
  --surface: #0b1020;
  --panel: #141a2e;
  --line: #232c47;
  --text: #e8ecf8;
  --muted: #93a0c0;
  --accent: #37e0ff;
  --accent-2: #7cff6b;
  --danger: #ff4f7b;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 70% -10%, #16234a 0%, var(--surface) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 16px;
}

.logo {
  margin: 0;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(55, 224, 255, 0.5);
}

.hud {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.hud__item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hud__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.hud__value {
  font-family: "Consolas", "JetBrains Mono", monospace;
  font-size: 22px;
  font-weight: 700;
}

.hud__value--accent {
  color: var(--accent-2);
}

.hud__value--danger {
  color: var(--danger);
}

.stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-width: 0;
}

#game {
  width: 100%;
  max-width: 720px;
  height: auto;
  max-height: calc(100vh - 110px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0a1226;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 24, 0.72);
  backdrop-filter: blur(4px);
  border-radius: 16px;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(420px, 90%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.panel__title {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--accent);
}

.panel__title--danger {
  color: var(--danger);
}

.panel__text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.panel__hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 14px;
}

.name-field input {
  width: 220px;
  padding: 10px 14px;
  font-size: 16px;
  text-align: center;
  color: var(--text);
  background: #0d1426;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.name-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(55, 224, 255, 0.18);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 34px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn--play {
  color: #04121c;
  background: linear-gradient(180deg, #6ef0ff, #16c3e8);
  box-shadow: 0 8px 24px rgba(55, 224, 255, 0.35);
}

.btn--play:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(55, 224, 255, 0.5);
}

.result-row {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 8px 0 14px;
}

.result {
  display: flex;
  flex-direction: column;
}

.result__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.result__value {
  font-family: "Consolas", monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent-2);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.board__title {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--accent);
}

.board__list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.board__list li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.board__list li:last-child {
  border-bottom: none;
}

.board__list li::before {
  content: counter(rank);
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #0d1426;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.board__list li:nth-child(1)::before {
  background: #ffd75e;
  color: #3a2b00;
}
.board__list li:nth-child(2)::before {
  background: #c9d3e8;
  color: #2a3245;
}
.board__list li:nth-child(3)::before {
  background: #e0955a;
  color: #331a00;
}

.board__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board__val {
  font-family: "Consolas", monospace;
  font-weight: 700;
  color: var(--accent-2);
}

.board__empty {
  color: var(--muted);
  justify-content: center;
}

.live-dot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.live-dot__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px var(--accent-2);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 3;
  }
}
