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

:root {
  --bg: #121213;
  --bg-light: #1a1a1b;
  --text: #ffffff;
  --text-muted: #818384;
  --border: #3a3a3c;
  --key-bg: #818384;
  --key-text: #ffffff;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --absent-key: #3a3a3c;
  --tile-border: #565758;
  --tile-size: 50px;
  --tile-font: 1.6rem;
  --tile-gap: 4px;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

/* Top bar */
.top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}
.top-bar-logo {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--correct), var(--present));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.top-bar-right {
  position: relative;
}
.top-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}
.top-profile-btn:hover {
  border-color: #8b5cf6;
}
.top-username {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-elo {
  background: #8b5cf6;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  overflow: hidden;
}
.dropdown-header {
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.dropdown-name {
  display: block;
  font-weight: 700;
  font-size: 1rem;
}
.dropdown-elo {
  display: block;
  color: #8b5cf6;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 2px;
}
.dropdown-stats {
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.dropdown-item:hover {
  background: rgba(255,255,255,0.05);
}
.dropdown-danger {
  color: #e74c3c;
}

#app {
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
}
.screen.active {
  display: flex;
}

/* Title */
.title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 6px;
  margin-top: 50px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--correct), var(--present));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 40px;
  font-size: 1rem;
}

/* Menu */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

/* Buttons */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}
.btn-primary {
  background: var(--correct);
  color: white;
}
.btn-secondary {
  background: var(--present);
  color: white;
}
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--correct);
}
.btn-back {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-top: 24px;
}
.btn-small {
  padding: 8px 16px;
  font-size: 0.8rem;
  background: var(--border);
  color: white;
  border-radius: 4px;
}

/* Player count selector */
.player-count-selector {
  display: flex;
  gap: 10px;
  margin: 20px 0 30px;
  justify-content: center;
}
.player-count-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-light);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.player-count-btn.active {
  border-color: var(--correct);
  background: var(--correct);
  color: white;
}
.player-count-btn:hover {
  border-color: var(--correct);
}

/* Inputs */
.input-group {
  width: 100%;
  max-width: 300px;
  margin-bottom: 16px;
  position: relative;
}
.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  font-weight: 700;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus {
  border-color: var(--correct);
}
.name-field {
  letter-spacing: 2px;
  text-transform: none !important;
}
.code-field {
  letter-spacing: 8px;
  text-transform: uppercase;
}
.password-input {
  letter-spacing: 8px;
  text-transform: uppercase;
  padding-right: 48px !important;
}
.input-group input::placeholder {
  letter-spacing: 2px;
  color: var(--text-muted);
}
.btn-eye {
  position: absolute;
  right: 8px;
  top: 8px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.btn-eye:hover {
  opacity: 1;
}
.error-text {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-top: 6px;
  min-height: 20px;
}
.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 8px;
}

/* Hidden mobile input */
.mobile-input {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* Share buttons */
.share-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
  justify-content: center;
}
.btn-share-main {
  padding: 12px 24px;
  font-size: 0.95rem;
}

/* Waiting / Room code */
.room-code-big {
  text-align: center;
  margin: 30px 0 12px;
}
.code-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  padding: 16px 24px;
  background: var(--bg-light);
  border: 2px solid var(--correct);
  border-radius: 12px;
}
.code-box span {
  font-family: 'Courier New', monospace;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--correct);
}

/* Waiting players list */
.waiting-players {
  margin-top: 20px;
  text-align: center;
}
.waiting-players h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.waiting-players ul {
  list-style: none;
  padding: 0;
}
.waiting-players li {
  padding: 8px 20px;
  margin: 4px 0;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  display: inline-block;
  margin-right: 6px;
}
.waiting-players li.creator {
  border-color: var(--correct);
  color: var(--correct);
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--correct);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Game screen */
#game-screen.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Game header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 100%;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  flex-shrink: 0;
}
.game-header h2 {
  font-size: 1.2rem;
  letter-spacing: 4px;
}
.round-info {
  font-size: 0.85rem;
  color: var(--present);
  font-weight: 600;
  margin-top: 2px;
}

/* Boards container */
.boards-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Dual boards (1v1) */
.dual-boards {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 4px 0;
}
.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 340px;
  transition: opacity 0.3s;
}
.board-section.dimmed {
  opacity: 0.4;
}
.board-label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
  padding: 2px 14px;
  border-radius: 4px;
  color: var(--text-muted);
  letter-spacing: 1px;
}
.board-label.active {
  color: var(--correct);
  border-bottom: 2px solid var(--correct);
}
.board-divider {
  width: 2px;
  background: var(--border);
  align-self: stretch;
  margin: 20px 4px;
  border-radius: 1px;
}

/* Battle board (single centered) */
.battle-board-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 4px 0;
}

/* Board */
.board {
  display: flex;
  flex-direction: column;
  gap: var(--tile-gap);
}
.board-row {
  display: flex;
  gap: var(--tile-gap);
}
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tile-font);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  transition: transform 0.1s;
  user-select: none;
}
.tile.filled {
  border-color: var(--tile-border);
  animation: pop 0.1s ease;
}
.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
}
.tile.present {
  background: var(--present);
  border-color: var(--present);
}
.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
}
.tile.reveal {
  animation: flip 0.5s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes flip {
  0% { transform: rotateX(0deg); }
  45% { transform: rotateX(90deg); }
  55% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.board-row.shake {
  animation: shake 0.4s ease;
}

/* Message toast */
.message {
  padding: 10px 20px;
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.message.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Keyboard */
.keyboard {
  width: 100%;
  max-width: 520px;
  padding: 4px 0 8px;
  flex-shrink: 0;
}
.keyboard-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 4px;
}
.keyboard button {
  padding: 0;
  height: 52px;
  min-width: 30px;
  flex: 1;
  max-width: 42px;
  border: none;
  border-radius: 6px;
  background: var(--key-bg);
  color: var(--key-text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.keyboard button:hover {
  filter: brightness(1.2);
}
.keyboard button.key-wide {
  max-width: 62px;
  flex: 1.5;
  font-size: 0.72rem;
}
.keyboard button.correct {
  background: var(--correct);
}
.keyboard button.present {
  background: var(--present);
}
.keyboard button.absent {
  background: var(--absent-key);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  padding: 16px;
}
.modal-overlay.hidden {
  display: none;
}
.modal {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}
.modal p {
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}
.modal-stats {
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.8;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
}
.stat-label {
  color: var(--text-muted);
}
.stat-win {
  color: var(--correct);
  font-weight: 700;
}
.stat-lose {
  color: #e74c3c;
  font-weight: 700;
}
.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Reveal word in round modal */
.reveal-word {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--correct) !important;
  margin: 10px 0 !important;
}

/* Scores table */
.scores-table {
  margin: 16px 0;
}
.scores-table table {
  width: 100%;
  border-collapse: collapse;
}
.scores-table th, .scores-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.scores-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

/* Ranking table */
.ranking-table {
  margin: 16px 0;
}
.ranking-table table {
  width: 100%;
  border-collapse: collapse;
}
.ranking-table th, .ranking-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.ranking-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.ranking-row {
  font-weight: 700;
}
.ranking-row.first {
  color: var(--gold);
  font-size: 1.1rem;
}
.ranking-row.second {
  color: var(--silver);
}
.ranking-row.third {
  color: var(--bronze);
}
.rank-medal {
  font-size: 1.2rem;
  margin-right: 4px;
}
.ranking-row .rank-score {
  font-weight: 800;
}

/* Watching state (battle mode, your word being guessed) */
.watching-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px;
  text-align: center;
}
.watching-overlay h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
}
.watching-overlay p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Auth screens */
.login-link {
  margin-top: 30px;
  text-align: center;
}
.login-link p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.btn-sm {
  padding: 10px 20px;
  font-size: 0.85rem;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: var(--bg-light);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--correct);
  color: white;
}
.auth-form {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 300px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  padding: 0 12px;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 300px;
  padding: 12px 20px;
  background: #ffffff;
  color: #333333;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-google:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Ranked */
.btn-ranked {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: white;
  position: relative;
  overflow: hidden;
}
.btn-ranked::before {
  content: '⚔️ ';
}
.ranked-info {
  margin-bottom: 20px;
  text-align: center;
}
.elo-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-light);
  border: 2px solid #8b5cf6;
  border-radius: 12px;
}
.elo-badge.big {
  padding: 20px 40px;
  margin: 20px 0;
}
.elo-label {
  font-size: 0.75rem;
  color: #8b5cf6;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.elo-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}
.elo-badge.big .elo-value {
  font-size: 3rem;
}

/* ELO change display */
.elo-change-display {
  margin: 16px 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.elo-change-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}
.elo-change-positive {
  color: var(--correct);
  font-weight: 700;
}
.elo-change-negative {
  color: #e74c3c;
  font-weight: 700;
}

/* Leaderboard */
.leaderboard-content {
  width: 100%;
  max-width: 400px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 16px 0;
}
.leaderboard-content table {
  width: 100%;
  border-collapse: collapse;
}
.leaderboard-content th,
.leaderboard-content td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.leaderboard-content th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.lb-row-me {
  background: rgba(83,141,78,0.15);
}
.lb-rank {
  font-weight: 700;
  width: 40px;
}
.lb-first { color: var(--gold); }
.lb-second { color: var(--silver); }
.lb-third { color: var(--bronze); }

/* Profile */
.profile-username {
  font-size: 1.8rem;
  letter-spacing: 2px;
  margin-top: 30px;
  margin-bottom: 4px;
}
.profile-stats {
  display: flex;
  gap: 16px;
  margin: 24px 0;
  flex-wrap: wrap;
  justify-content: center;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 70px;
}
.profile-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}
.profile-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}
.profile-extra {
  width: 100%;
  max-width: 300px;
  margin-bottom: 24px;
}
.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-muted);
}
.profile-highlight {
  color: var(--text);
  font-weight: 700;
}
.elo-badge.clickable {
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: var(--bg-light);
  border: 2px solid #8b5cf6;
  border-radius: 12px;
  padding: 12px 24px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.elo-badge.clickable:hover {
  border-color: #a78bfa;
  transform: translateY(-1px);
}
.profile-link {
  font-size: 0.7rem;
  color: #8b5cf6;
  margin-top: 4px;
  letter-spacing: 1px;
}

.hidden {
  display: none !important;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 700px) {
  :root {
    --tile-size: 42px;
    --tile-font: 1.4rem;
    --tile-gap: 3px;
  }
  .title { font-size: 2.4rem; letter-spacing: 4px; }
  .dual-boards { gap: 6px; }
  .code-box span { font-size: 1.8rem; }
}

@media (max-width: 500px) {
  :root {
    --tile-size: 36px;
    --tile-font: 1.2rem;
    --tile-gap: 3px;
  }
  #app {
    padding: 6px 8px;
  }
  .title {
    font-size: 2rem;
    margin-top: 30px;
    letter-spacing: 3px;
  }
  .subtitle { font-size: 0.9rem; margin-bottom: 30px; }
  .game-header { padding: 4px 0; margin-bottom: 2px; }
  .game-header h2 { font-size: 1rem; letter-spacing: 3px; }
  .dual-boards { gap: 4px; padding: 2px 0; }
  .board-label { font-size: 0.75rem; margin-bottom: 2px; padding: 2px 8px; }
  .board-divider { margin: 16px 2px; }
  .keyboard { padding: 2px 0 6px; }
  .keyboard-row { gap: 3px; margin-bottom: 3px; }
  .keyboard button {
    height: 46px;
    min-width: 24px;
    font-size: 0.8rem;
    border-radius: 4px;
  }
  .keyboard button.key-wide {
    max-width: 56px;
    font-size: 0.65rem;
  }
  .code-box span { font-size: 1.5rem; letter-spacing: 8px; }
  .code-box { padding: 12px 16px; }
  .room-code-big { margin: 20px 0 16px; }
  .btn { padding: 12px 24px; font-size: 0.9rem; }
  .modal { padding: 24px 16px; }
  .modal h2 { font-size: 1.3rem; }
  .stat-row { padding: 4px 8px; font-size: 0.85rem; }
  .player-count-btn {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  :root {
    --tile-size: 30px;
    --tile-font: 1rem;
    --tile-gap: 2px;
  }
  .title { font-size: 1.7rem; margin-top: 20px; }
  .keyboard button {
    height: 40px;
    min-width: 20px;
    font-size: 0.7rem;
  }
  .keyboard button.key-wide {
    max-width: 48px;
    font-size: 0.6rem;
  }
}

@media (max-height: 500px) {
  :root {
    --tile-size: 28px;
    --tile-font: 0.9rem;
    --tile-gap: 2px;
  }
  .game-header { padding: 2px 0; margin-bottom: 2px; }
  .game-header h2 { font-size: 0.9rem; }
  .board-label { font-size: 0.7rem; margin-bottom: 1px; }
  .board-divider { margin: 8px 2px; }
  .keyboard button { height: 36px; }
  .keyboard-row { margin-bottom: 2px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .keyboard {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
