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

html {
  height: 100%;
}

:root {
  /* ── Doodle Jump palette ── */
  --bg:           #ede8d5;      /* graph paper cream */
  --surface:      #fdfaf2;      /* white paper */
  --surface2:     #f0e8d4;      /* slightly tinted paper */
  --accent:       #c8341a;      /* DJ red — logo, errors, highlights */
  --green:        #5a9e2e;      /* platform green */
  --green-dark:   #3d7020;      /* platform shadow/border */
  --green-light:  #7bc840;      /* lighter green for text on dark */
  --text:         #2a1e0e;      /* dark ink */
  --text-muted:   #8a7a60;      /* faded ink */
  --border:       #a89878;      /* ink border */
  --border-light: #d4c8a8;      /* faint rule line */
  --grid-line:    rgba(90, 120, 180, 0.12); /* blue-ish grid lines */

  --box-size: 52px;
  --box-gap:  6px;
}

/* ── Base ── */
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  min-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Logo ── */
.logo {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-weight: 700;
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
}

.logo span {
  display: inline-block;
  transform: rotate(var(--r, 0deg)) scale(var(--s, 1)) translateY(var(--y, 0px));
}

/* ── Landing page ── */
.landing {
  width: 100%;
  max-width: 580px;
  height: 100%;
  padding: 20px 20px 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.landing h1.logo {
  font-size: 3.6rem;
  width: 100%;
  justify-content: center;
  margin-bottom: 4px;
  filter: drop-shadow(2px 3px 0px rgba(200, 52, 26, 0.2));
}

.landing .tagline {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 1rem;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

/* ── Error message ── */
.error-msg {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 1.4em;
  margin-bottom: 10px;
  text-align: left;
  padding-left: 2px;
}

.error-msg:empty {
  display: none;
}

.input-shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.input-error {
  border-color: var(--accent) !important;
}

/* ── Inputs ── */
.input-group input,
input[type="text"] {
  flex: 1;
  padding: 11px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
  box-shadow: 2px 2px 0 var(--border-light);
}

.input-group input:focus,
input[type="text"]:focus {
  border-color: var(--accent);
}

input.locked {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.75;
  border-style: dashed;
  user-select: none;
  padding-left: 32px;
}

input.locked:focus {
  border-color: var(--border);
}


/* ── Buttons — platform style ── */
button {
  padding: 10px 20px;
  background: var(--green);
  color: #fff;
  border: 2px solid var(--green-dark);
  border-bottom: 4px solid var(--green-dark);
  border-radius: 24px;
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, border-bottom-width 0.1s;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

button:hover {
  filter: brightness(1.07);
}

button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

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

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--border);
}

/* ── Leaderboard ── */
.leaderboard-section {
  margin-top: 10px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.leaderboard-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: -2px;
  padding-left: 8px;
  position: relative;
  z-index: 1;
}

.lb-tab {
  padding: 10px 14px;
  font-size: 0.82rem;
  border-radius: 12px 12px 0 0;
  border-bottom: none;
  background: var(--surface2);
  color: var(--text-muted);
  border: 2px solid var(--border-light);
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  font-weight: 700;
}

.lb-tab.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green-dark);
  border-bottom-color: var(--green);
}

.lb-tab:hover:not(.active) {
  background: var(--surface);
}

.leaderboard-card {
  background: var(--surface);
  border-radius: 12px;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border-light);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  max-height: 340px;
  display: flex;
  flex-direction: column;
}

#leaderboard-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  gap: 10px;
  font-size: 0.9rem;
}

.lb-row:last-child { border-bottom: none; }

.lb-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  background: var(--surface2);
  color: var(--text-muted);
}

.lb-rank.gold   { background: #D4A020; color: #fff; }
.lb-rank.silver { background: #a89878; color: #fff; }
.lb-rank.bronze { background: #b87333; color: #fff; }

.lb-username {
  flex: 1;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-stats {
  text-align: right;
  flex-shrink: 0;
}

.lb-score {
  font-weight: 700;
  color: var(--green-dark);
  font-size: 0.95rem;
}

.lb-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lb-type-toggle {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}

.lb-type {
  flex: 1;
  padding: 9px 8px;
  font-size: 0.85rem;
  background: var(--surface2);
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid var(--border-light);
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
}

.lb-type.active {
  color: var(--accent);
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.lb-type:first-child { border-right: 1px solid var(--border-light); }

.lb-countdown {
  padding: 8px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.lb-countdown span {
  font-weight: 700;
  color: var(--text);
}

.lb-empty {
  padding: 24px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.lb-my-rank {
  padding: 8px 12px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface2);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.lb-row-me {
  background: rgba(90, 158, 46, 0.12);
  border-left: 3px solid var(--green);
}

.lb-you-badge {
  font-size: 0.65rem;
  background: var(--green);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* ── Room list ── */
.room-list {
  background: var(--surface);
  border-radius: 12px;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border-light);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  max-height: 340px;
}

.room-list h2 {
  padding: 10px 16px;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

#room-list-container {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.room-item:last-child { border-bottom: none; }

.room-item:hover { background: var(--surface2); }

.room-item .room-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-item .room-id {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--text);
}

.room-item .room-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.room-status-waiting { color: var(--green-dark); font-weight: 700; }
.room-status-playing { color: var(--accent); font-weight: 700; }

.room-item button {
  padding: 5px 14px;
  font-size: 0.9rem;
}

.no-rooms {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

#error-msg { font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive; }

/* ── Game layout ── */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  width: 100%;
  max-width: 1020px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding: 14px;
  gap: 14px;
}

.game-main {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.game-sidebar {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* ── Paper card (shared by header, timer, scoreboard, chat, overlays) ── */
.game-header,
.timer-container,
.word-display-container,
.scoreboard,
.chat-container {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--border-light);
}

/* ── Header ── */
.game-header {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header h1.logo {
  font-size: 2.2rem;
}

.round-info {
  font-size: 1.05rem;
  color: var(--text-muted);
}

.round-info span {
  color: var(--text);
  font-weight: 700;
}

/* ── Timer ── */
.timer-container {
  padding: 14px 18px;
}

.timer-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 1rem;
  color: var(--text-muted);
}

.timer-label #timer-display {
  font-weight: 700;
  color: var(--text);
  font-size: 1.1rem;
}

.timer-bar-bg {
  height: 10px;
  background: var(--border-light);
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
}

#timer-bar {
  height: 100%;
  background: var(--green);
  border-radius: 6px;
  transition: width 1s linear, background-color 0.5s;
  width: 100%;
}

#timer-bar.warning { background: #d98820; }
#timer-bar.danger  { background: var(--accent); }

/* ── Word display ── */
.word-display-container {
  padding: 24px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#word-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}

.word-row {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--box-gap);
  justify-content: center;
}

.letter-box {
  width: var(--dyn-box-size, var(--box-size));
  height: var(--dyn-box-size, var(--box-size));
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom: 4px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: calc(var(--dyn-box-size, var(--box-size)) * 0.58);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--border-light);          /* blank box: faint placeholder */
  flex-shrink: 0;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.letter-box.revealed {
  background: var(--green);
  border-color: var(--green-dark);
  border-bottom-color: var(--green-dark);
  color: #fff;
}

.letter-box.revealed.just-revealed {
  animation: pop 0.3s ease;
}

@keyframes pop {
  0%   { transform: scale(1)    translateY(0); }
  40%  { transform: scale(1.18) translateY(-4px); }
  100% { transform: scale(1)    translateY(0); }
}

/* ── Lobby overlay ── */
#lobby-overlay {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#lobby-overlay h2 {
  font-size: 1.6rem;
  color: var(--text);
}

#lobby-overlay .room-code {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--accent);
}

#lobby-overlay .waiting-text {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Game-over overlay ── */
#game-over-overlay {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#game-over-overlay h2 {
  font-size: 2.2rem;
  color: var(--accent);
}

.final-scores {
  width: 100%;
  max-width: 360px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 1.1rem;
  color: var(--text);
}

.score-row:last-child { border-bottom: none; }

.score-row.winner {
  color: var(--green-dark);
  font-weight: 700;
}

/* ── Game over stats ── */
.game-over-stats {
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-summary {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.stat-summary .stat-score {
  color: var(--green-dark);
}

.stat-summary .stat-time {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
}

.stat-board {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 20px;
}

.stat-board-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
}

.stat-board-ranks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.stat-rank-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-rank-pos {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--border-light);
}

.stat-rank-pos.top1 { color: #D4A020; }
.stat-rank-pos.top2 { color: #a89878; }
.stat-rank-pos.top3 { color: #b87333; }

.stat-rank-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Scoreboard ── */
.scoreboard { overflow: hidden; }
.mobile-score-strip { display: none; }

.scoreboard h3 {
  padding: 12px 16px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.player-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 1rem;
}

.player-entry:last-child { border-bottom: none; }

.player-entry .player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.player-entry .host-badge {
  font-size: 0.72rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.player-entry .bot-badge {
  font-size: 0.72rem;
  background: var(--text-muted);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.player-entry .player-score {
  font-weight: 700;
  color: var(--green-dark);
  font-size: 1.05rem;
}

/* ── Chat ── */
.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.chat-container h3 {
  padding: 12px 16px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}

.chat-message {
  font-size: 1rem;
  line-height: 1.4;
  word-break: break-word;
  color: var(--text);
}

.chat-message .chat-username {
  font-weight: 700;
  color: var(--accent);
}

.chat-message.error {
  color: var(--accent);
  font-style: italic;
}

.chat-message.system {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.chat-message.winner-msg {
  color: var(--green-dark);
  font-weight: 700;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-row input:focus  { border-color: var(--green); }
.chat-input-row input:disabled { opacity: 0.45; }

.chat-input-row button {
  padding: 8px 12px;
  font-size: 1rem;
  border-radius: 16px;
  border-bottom-width: 2px; /* override platform 3D — flat fits the input row */
  flex-shrink: 0;
  min-width: 0;
}

/* ── Round countdown overlay ── */
.countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  pointer-events: none;
}

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

.countdown-number {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 8rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 4px 4px 0 var(--green-dark), 0 0 40px rgba(90, 158, 46, 0.5);
  animation: countdownPop 0.8s ease-out;
}

@keyframes countdownPop {
  0%   { transform: scale(2); opacity: 0; }
  30%  { transform: scale(0.9); opacity: 1; }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Toast notification ── */
#notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom: 4px solid var(--border);
  border-radius: 14px;
  padding: 12px 24px;
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  transition: transform 0.3s ease;
  z-index: 1000;
  max-width: 90vw;
  text-align: center;
  box-shadow: 3px 3px 0 var(--border-light);
}

#notification.show  { transform: translateX(-50%) translateY(0); }
#notification.success { border-color: var(--green); color: var(--green-dark); }
#notification.info    { border-color: var(--accent); color: var(--accent); }

/* ── How to Play ── */
.how-to-play {
  text-align: left;
  background: var(--surface2);
  border-radius: 10px;
  padding: 14px 18px;
  width: 100%;
  max-width: 340px;
}

.how-to-play h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.how-to-play ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.how-to-play li {
  font-size: 0.9rem;
  color: var(--text);
  padding-left: 16px;
  position: relative;
}

.how-to-play li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--green);
  font-weight: 700;
}

/* ── Empty states ── */
.empty-state {
  padding: 28px 20px;
  text-align: center;
}

.empty-state-text {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 0;
}

/* ── Auth bar (logged-in: avatar + name + sign out + create room in one row) ── */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  object-fit: cover;
  flex-shrink: 0;
}

.auth-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-logout {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.auth-logout:hover { text-decoration: underline; color: var(--accent); }

.create-btn-inline {
  margin-left: auto;
  padding: 8px 18px;
  font-size: 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Google sign-in ── */
.google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 2px 2px 0 var(--border-light);
}

.google-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

.google-btn svg { flex-shrink: 0; }

.google-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Feedback & Support links ── */
.page-links {
  position: fixed;
  bottom: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 999;
}

.page-links a {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 700;
}

.page-links a:hover { text-decoration: underline; }

.page-links-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  flex-shrink: 0;
}

.page-links-inline a {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 700;
}

.page-links-inline a:hover { text-decoration: underline; }

/* ── Username modal ── */
.username-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.username-modal .modal-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--border-light);
  padding: 32px 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.username-modal .modal-card h2 {
  font-size: 1.4rem;
  color: var(--text);
}

.username-modal .modal-card input {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
  font-size: 1.1rem;
  outline: none;
}

.username-modal .modal-card input:focus { border-color: var(--accent); }

/* ── Auto-restart countdown ── */
#auto-restart-countdown {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ── Mute button ── */
.mute-btn {
  background: transparent;
  border: none;
  border-bottom: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  color: var(--text-muted);
}

.mute-btn:hover { opacity: 1; }

/* Chat toggle + overlay: hidden on desktop */
.chat-toggle-btn { display: none; }
.chat-overlay-panel { display: none; }

/* ── Responsive ── */
@media (max-width: 900px) {

  /* ── Mobile game: fixed viewport layout (no scroll) ── */
  .game-layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    gap: 0;
  }

  .game-main {
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: column;
    flex: none;
    min-height: 0;
    overflow: visible;
    gap: 0;
  }

  .game-sidebar {
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: visible;
    gap: 0;
  }

  /* Compact header */
  .game-header {
    padding: 8px 12px;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    border-top: none;
  }

  .game-header h1.logo { font-size: 1.4rem; }

  /* Compact timer */
  .timer-container {
    padding: 6px 12px;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
  }

  .timer-label { margin-bottom: 4px; font-size: 0.85rem; }
  .timer-label #timer-display { font-size: 0.9rem; }
  .timer-bar-bg { height: 6px; }

  /* Word display — fill remaining vertical space */
  .word-display-container {
    position: relative;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    padding: 8px 10px;
    flex: none;
    min-height: 0;
    overflow-y: visible;
    justify-content: flex-start;
  }

  #word-display { gap: 16px; }

  /* Hide scoreboard + chat log on mobile — only keep the input */
  .scoreboard { display: none; }

  /* Mobile score strip — compact horizontal scores below header */
  .mobile-score-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: nowrap;
  }

  .mobile-score-strip:empty { display: none; }

  .mobile-score-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text);
  }

  .mobile-score-chip .chip-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-score-chip .chip-pts {
    font-weight: 700;
    color: var(--accent);
  }
  .chat-container h3 { display: none; }
  #chat-log { display: none; }

  .chat-container {
    border-radius: 0;
    box-shadow: none;
    border: none;
    min-height: 0;
    overflow: hidden;
    flex-shrink: 0;
  }

  /* ── Input bar at bottom ── */
  .chat-input-row {
    z-index: 100;
    background: var(--surface);
    border-top: 2px solid var(--border);
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .chat-input-row input {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  /* ── Mobile chat overlay: just above the input row ── */
  .mobile-chat-overlay {
    padding: 4px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
  }

  .mobile-chat-overlay .mobile-chat-line {
    background: rgba(253, 250, 242, 0.92);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.3;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: chatFadeIn 0.2s ease;
  }

  .mobile-chat-line .chat-username {
    font-weight: 700;
    color: var(--accent);
  }

  @keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  :root {
    --box-size: 38px;
    --box-gap: 4px;
  }

  /* Lobby */
  #lobby-overlay .room-code { font-size: 2rem; }

  /* Landing page */
  .landing h1.logo { font-size: 3.8rem; }
  .landing .tagline { font-size: 1rem; margin-bottom: 20px; }
  .landing { padding: 24px 16px; }

  .input-group input { min-width: 0; }

  #notification { font-size: 0.95rem; padding: 10px 16px; }

  /* ── Touch targets: 44px minimum ── */
  .room-item button { min-height: 44px; padding: 10px 16px; }
  .mute-btn { min-width: 44px; min-height: 44px; padding: 8px; display: inline-flex; align-items: center; justify-content: center; }
  .chat-input-row input { padding: 12px 14px; min-height: 44px; }
  .chat-input-row button { min-height: 44px; padding: 10px 14px; }

  /* ── Chat toggle button (inline next to Send, mobile only) ── */
  .chat-toggle-btn {
    display: flex;
    min-height: 44px;
    min-width: 44px;
    padding: 8px;
    font-size: 1.2rem;
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    border: 2px solid var(--border);
    border-bottom: 3px solid var(--border);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }
  .chat-toggle-btn:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
  }

  /* ── Chat overlay bottom sheet ── */
  .chat-overlay-panel {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    z-index: 150;
    flex-direction: column;
  }
  .chat-overlay-panel.open {
    display: flex;
  }
  .chat-overlay-backdrop {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
  }
  .chat-overlay-sheet {
    background: var(--surface);
    border-top: 2px solid var(--border);
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .chat-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
  }
  .chat-overlay-header h3 {
    font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', cursive;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .chat-overlay-close {
    min-height: 44px;
    min-width: 44px;
    background: transparent;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-overlay-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
}

@media (max-width: 480px) {
  .landing h1.logo { font-size: 2.8rem; }

  .room-list h2 { padding: 10px 14px; font-size: 0.95rem; }
  .room-item { padding: 10px 14px; }
  .room-item .room-id { font-size: 1rem; }
  .room-item button { padding: 10px 12px; font-size: 0.9rem; min-height: 44px; }

  .game-header h1.logo { font-size: 1.2rem; }

  :root {
    --box-size: 32px;
    --box-gap: 3px;
  }
}
