* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1b1420;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #f4ead1;
  padding: 16px;
}

.game-wrap {
  width: 100%;
  max-width: 900px;
}

h1 {
  text-align: center;
  margin: 0 0 4px;
  font-size: clamp(22px, 4vw, 32px);
  color: #ffb347;
  text-shadow: 0 2px 0 #7a3b12;
}

.subtitle {
  text-align: center;
  margin: 0 0 16px;
  color: #d8c9a3;
  font-size: 14px;
}

.canvas-shell {
  position: relative;
  width: 100%;
  border: 4px solid #5c3a21;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background: #87ceeb;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  touch-action: none;
}

.toast {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(20, 10, 5, 0.85);
  border: 2px solid #ffcf6b;
  color: #ffcf6b;
  font-weight: 700;
  font-size: clamp(12px, 2.4vw, 16px);
  padding: 8px 16px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 10, 5, 0.55);
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s ease;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  padding: 16px 24px;
  background: rgba(20, 10, 5, 0.6);
  border-radius: 10px;
}

.overlay-title {
  font-size: clamp(18px, 3.5vw, 28px);
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffcf6b;
  margin-bottom: 8px;
  text-shadow: 0 2px 0 #7a3b12;
}

.overlay-sub {
  font-size: clamp(12px, 2.2vw, 15px);
  color: #f4ead1;
}

.wildlife-signs {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 16px);
  margin: 4px 0 12px;
}

.sign {
  width: clamp(38px, 8vw, 54px);
  height: clamp(38px, 8vw, 54px);
  background: #ffcc00;
  border: 3px solid #161311;
  border-radius: 4px;
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.sign span {
  display: inline-block;
  transform: rotate(-45deg);
  font-size: clamp(16px, 4vw, 24px);
  filter: grayscale(1) contrast(1.6) brightness(0.75);
}

.score-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.score-form.hidden {
  display: none;
}

.name-input {
  width: 100%;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 2px solid #5c3a21;
  background: #f4ead1;
  color: #3a1f0f;
  font-size: 14px;
  text-align: center;
}

.name-input:focus {
  outline: 2px solid #ffb347;
}

.submit-btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  background: #ffb347;
  color: #3a1f0f;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.submit-btn:hover:not(:disabled) {
  background: #ffcf6b;
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.submit-status {
  font-size: 12px;
  color: #d8c9a3;
  min-height: 14px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.score-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 15px;
  letter-spacing: 1px;
}

.score-box b {
  color: #ffcf6b;
  margin-left: 4px;
}

.controls-hint {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: #b6a888;
}

@media (max-width: 480px) {
  .controls-hint {
    display: none;
  }
}

.leaderboard-panel {
  margin-top: 16px;
  border: 3px solid #5c3a21;
  border-radius: 10px;
  background: #2a1c14;
  overflow: hidden;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #5c3a21;
  color: #ffcf6b;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.refresh-btn {
  border: none;
  background: transparent;
  color: #ffcf6b;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.refresh-btn:hover {
  background: rgba(255, 207, 107, 0.15);
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 260px;
  overflow-y: auto;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 14px;
  border-bottom: 1px solid rgba(244, 234, 209, 0.08);
}

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

.leaderboard-list li:nth-child(1) .lb-rank { color: #ffd700; }
.leaderboard-list li:nth-child(2) .lb-rank { color: #c7c7c7; }
.leaderboard-list li:nth-child(3) .lb-rank { color: #cd7f32; }

.lb-rank {
  width: 28px;
  font-weight: 800;
  color: #b6a888;
}

.lb-name {
  flex: 1;
  color: #f4ead1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 700;
  color: #ffcf6b;
  font-variant-numeric: tabular-nums;
}

.lb-empty {
  padding: 14px;
  text-align: center;
  color: #b6a888;
  font-size: 13px;
  justify-content: center;
}
