:root {
  color-scheme: light;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background-color: #101010;
  color: #1e1e1e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: #101010;
}

.app {
  width: 100vw;
  height: 100vh;
  padding: 0;
  text-align: left;
  background: #101010;
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 8px 12px;
}

.hidden {
  display: none;
}

.title {
  position: absolute;
  top: 16px;
  left: 16px;
}

.hud {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 4px;
  font-size: 0.95rem;
  text-align: right;
}

.player,
.score {
  font-weight: 600;
}

.status {
  font-weight: 600;
  color: #c62828;
  min-height: 1.2em;
}

.board {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  background: #101010;
  border: 2px solid #2f2f2f;
  border-radius: 8px;
  display: block;
}

.controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 12px;
}

button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #1e1e1e;
  background: #1e1e1e;
  color: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
}

button:hover {
  background: #2b2b2b;
}

button:disabled {
  background: #b5b5b5;
  border-color: #b5b5b5;
  cursor: not-allowed;
}

.leaderboard {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: min(300px, 40vw);
  text-align: left;
}

.leaderboard h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.leaderboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard th,
.leaderboard td {
  padding: 6px 8px;
  border-bottom: 1px solid #e0e0e0;
}

.leaderboard th {
  text-align: left;
  font-weight: 600;
  color: #333333;
}

.leaderboard tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard .empty {
  color: #6b6b6b;
  text-align: center;
}

.help {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.85rem;
  color: #4a4a4a;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(90vw, 360px);
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.modal p {
  margin: 0 0 16px;
  color: #555555;
}

.modal-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.modal input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #cfcfcf;
  font-size: 1rem;
}

.error {
  color: #c62828;
  font-size: 0.85rem;
  min-height: 1em;
}

@media (max-width: 720px) {
  .title {
    top: 12px;
    left: 12px;
  }

  .hud {
    top: 56px;
    left: 12px;
    right: 12px;
    text-align: left;
  }

  .controls {
    left: 12px;
    right: 12px;
    justify-content: center;
  }

  .leaderboard {
    top: 120px;
    left: 12px;
    right: 12px;
    bottom: auto;
    width: auto;
  }

  .help {
    display: none;
  }
}
