:root {
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --border: #d3d6da;
  --bg: #ffffff;
  --text: #1a1a1b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: #fafafa;
  color: var(--text);
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

h1 {
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.subtitle {
  text-align: center;
  color: #666;
  margin-top: -8px;
}

.screen.hidden { display: none; }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 420px;
  margin: 16px auto;
}

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; margin-top: 12px; }

input[type="text"], input:not([type]), input[type="range"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
}

#code-input, #name-input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 16px; }

button {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 15px;
}

button.primary {
  background: var(--correct);
  color: white;
  border: none;
  font-weight: 600;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.divider { text-align: center; color: #999; margin: 16px 0; font-size: 13px; }

.error { color: #c0392b; font-size: 13px; min-height: 18px; }
.hint { color: #666; font-size: 13px; text-align: center; }

.share-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.share-row input { flex: 1; }
.share-row button { width: auto; }

.settings-row { margin: 16px 0; }

#player-list { list-style: none; padding: 0; }
#player-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 6px;
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.badge.ready { background: var(--correct); color: white; }
.badge.waiting { background: #eee; color: #666; }
.badge.host { background: #333; color: white; margin-right: 6px; }

.game-header { display: flex; justify-content: space-between; align-items: center; max-width: 900px; margin: 0 auto 10px; gap: 12px; }
#game-message { font-weight: 600; min-height: 22px; }
#timer-display {
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #f0f0f0; padding: 4px 14px; border-radius: 6px; letter-spacing: 1px;
}
#timer-display.urgent { color: #c0392b; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.game-body { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.board-area { display: flex; flex-direction: column; align-items: center; }

#board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}
.board-row { display: grid; grid-template-columns: repeat(5, 50px); gap: 6px; }
.tile {
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border);
  font-size: 24px; font-weight: 700; text-transform: uppercase;
  background: white;
}
.tile.correct { background: var(--correct); border-color: var(--correct); color: white; }
.tile.present { background: var(--present); border-color: var(--present); color: white; }
.tile.absent { background: var(--absent); border-color: var(--absent); color: white; }

#keyboard { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.kb-row { display: flex; gap: 5px; }
.kb-key {
  min-width: 32px; height: 42px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; background: #d3d6da; font-weight: 600; font-size: 13px;
  cursor: pointer; text-transform: uppercase; border: none;
}
.kb-key.correct { background: var(--correct); color: white; }
.kb-key.present { background: var(--present); color: white; }
.kb-key.absent { background: var(--absent); color: white; }
.kb-key.wide { min-width: 50px; font-size: 11px; }

.leaderboard-area { min-width: 280px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }

.mini-tiles { display: flex; gap: 3px; }
.mini-tile {
  width: 22px; height: 22px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  background: #f9f9f9; border-radius: 2px;
}
.mini-tile.filled { border-color: #999; background: #eee; }

#final-table { max-width: 500px; margin: 20px auto; }
#again-btn { max-width: 300px; margin: 20px auto; display: block; }

@media (max-width: 480px) {
  .tile { width: 42px; height: 42px; font-size: 20px; }
  .board-row { grid-template-columns: repeat(5, 42px); }
}
