* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #fff;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  color: #cfd2e3;
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover { color: #fff; }

.wrap {
  text-align: center;
}

h1 { margin-bottom: 2px; font-size: 1.25rem; }

.auth-box {
  margin: 6px 0;
  min-height: 30px;
}

.auth-form[hidden],
.auth-loggedin[hidden] {
  display: none;
}

.auth-form {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.auth-form input {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #3a3a5c;
  background: #232345;
  color: #fff;
  font-size: 0.85rem;
  width: 120px;
}

.auth-form input::placeholder { color: #6b7399; }

.auth-form button,
.auth-loggedin button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: #4361ee;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.auth-form button:hover,
.auth-loggedin button:hover { background: #3348c4; }

.auth-loggedin {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: #cfd2e3;
  font-size: 0.9rem;
}

.auth-error {
  color: #ff6b6b;
  margin-top: 6px;
  min-height: 1em;
  font-size: 0.8rem;
}

.score { color: #cfd2e3; margin-bottom: 6px; font-size: 0.9rem; }

.canvas-wrap {
  display: flex;
  justify-content: center;
  min-height: 0;
}

canvas {
  background: #8ecae6;
  border: 2px solid #4361ee;
  border-radius: 8px;
  aspect-ratio: 800 / 450;
  height: min(900px, calc(100vh - 200px));
  width: auto;
  max-width: 96vw;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.restart-btn {
  margin-top: 8px;
  background: #4361ee;
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.restart-btn:hover { background: #3348c4; }

a.restart-btn {
  display: inline-block;
  text-decoration: none;
}

.leaderboard-btn {
  margin-left: 8px;
  background: #232345;
}

.leaderboard-btn:hover { background: #2f2f5c; }

.leaderboard-wrap {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

.leaderboard-list {
  background: #16213e;
  border: 2px solid #4361ee;
  border-radius: 8px;
  padding: 10px;
  margin-top: 16px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: monospace;
}

.leaderboard-row.you {
  background: rgba(67, 97, 238, 0.25);
  border: 1px solid #4361ee;
  font-weight: 700;
}

.leaderboard-row .rank {
  width: 32px;
  color: #8890b5;
  flex-shrink: 0;
}

.leaderboard-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.leaderboard-row .points {
  flex-shrink: 0;
}

.leaderboard-divider {
  text-align: center;
  color: #6b7399;
  padding: 2px 0;
}

.hint {
  color: #8890b5;
  margin-top: 6px;
  font-size: 0.8rem;
}

.credit {
  color: #6b7399;
  margin-top: 4px;
  font-size: 0.7rem;
}
