:root {
  --bg: #f7f7f5;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --text: #16202a;
  --muted: #6b7280;
  --line: #dde2e7;
  --line-dark: #c8d0d9;
  --key: #e6eaef;
  --green: #6aaa64;
  --yellow: #c9b458;
  --gray: #787c7e;
  --primary: #102a43;
  --primary-2: #183b5b;
  --accent: #f0b429;
  --danger: #8a2d2d;
  --danger-soft: #f8ecec;
  --success-soft: #edf8ef;
  --button-text: #ffffff;
  --shadow: 0 14px 40px rgba(16, 42, 67, 0.08);
  --shadow-soft: 0 8px 24px rgba(16, 42, 67, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --font-body: "Inter", Arial, sans-serif;
  --app-max-width: 620px;
  --logo-max-width: 420px;
  --tile-size: clamp(52px, 11vw, 64px);
  --tile-gap: clamp(6px, 1vw, 8px);
  --key-height: clamp(52px, 9vw, 62px);
  --key-font: clamp(0.875rem, 1.9vw, 1.1rem);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(240, 180, 41, 0.08), transparent 25%),
    radial-gradient(circle at top right, rgba(16, 42, 67, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  justify-content: center;
  padding: 14px 14px 24px;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
}

.brand-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}

.logo {
  display: block;
  width: 100%;
  max-width: var(--logo-max-width);
  height: auto;
  object-fit: contain;
  border-radius: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 14px;
}

.tab-btn {
  border: 1px solid rgba(16, 42, 67, 0.08);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  color: var(--text);
  padding: 13px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--button-text);
  border-color: transparent;
}

.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.surface-card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(16, 42, 67, 0.08);
  box-shadow: var(--shadow);
  border-radius: 22px;
}

.player-card {
  padding: 14px;
  margin-bottom: 14px;
}

.player-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  min-height: 52px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.input-wrap:focus-within {
  border-color: rgba(16, 42, 67, 0.28);
  box-shadow:
    0 0 0 4px rgba(16, 42, 67, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}

#player-name {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 14px 0;
}

#player-name::placeholder {
  color: #98a2b3;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border: none;
  border-radius: 14px;
  padding: 0 18px;
  min-height: 52px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease, background 180ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:active,
.secondary-btn:active,
.danger-btn:active {
  transform: translateY(1px) scale(0.99);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--button-text);
  box-shadow: 0 10px 24px rgba(16, 42, 67, 0.18);
}

.secondary-btn {
  width: 100%;
  background: linear-gradient(135deg, #fff7e8, #fff2cc);
  color: var(--primary);
  border: 1px solid rgba(240, 180, 41, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.danger-btn {
  width: 100%;
  background: linear-gradient(135deg, #fff1f1, #ffe4e4);
  color: var(--danger);
  border: 1px solid rgba(138, 45, 45, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.dunce-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 0 18px;
  min-height: 52px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #5a1a00;
  background: linear-gradient(135deg, #ff6b6b, #ff9f43, #ffd32a, #0be881, #00d2d3, #ff6b81);
  background-size: 250% 100%;
  border: 2px solid rgba(255, 107, 107, 0.4);
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.25);
  transition: transform 180ms ease, box-shadow 180ms ease, background-position 400ms ease;
}

.dunce-btn:hover {
  transform: translateY(-1px);
  background-position: 100% 0;
  box-shadow: 0 12px 28px rgba(255, 107, 107, 0.35);
}

.dunce-btn:active {
  transform: translateY(1px) scale(0.99);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(16, 42, 67, 0.12);
}

.player-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(16, 42, 67, 0.08);
  color: var(--muted);
  font-size: 0.95rem;
}

.meta-pill svg {
  width: 16px;
  height: 16px;
}

.meta-pill-button {
  border: 1px solid rgba(16, 42, 67, 0.08);
  cursor: pointer;
}

#mode-pill {
  background: #fff2e5;
  border-color: rgba(240, 180, 41, 0.35);
  color: #8a4b00;
}

.name-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff4e8;
  border: 1px solid rgba(240, 180, 41, 0.28);
  color: #8a4b00;
  font-size: 0.95rem;
  line-height: 1.45;
}

.board-locked {
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 14px;
}

.board-locked-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(16, 42, 67, 0.08);
  color: var(--primary);
}

.board-locked h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.board-locked p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.board-shell {
  position: relative;
  padding: 14px;
  margin-bottom: 14px;
  outline: none;
}

.board-head {
  margin-bottom: 10px;
}

.board-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.guess-feedback {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff4e8;
  border: 1px solid rgba(240, 180, 41, 0.28);
  color: #8a4b00;
  font-size: 0.95rem;
  line-height: 1.45;
}

.guess-feedback.error {
  background: #fff1f1;
  border-color: rgba(138, 45, 45, 0.22);
  color: var(--danger);
}

.board {
  display: grid;
  gap: var(--tile-gap);
  justify-content: center;
  margin: 6px 0 14px;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: var(--tile-gap);
}

.row.shake {
  animation: rowShake 420ms ease;
}

@keyframes rowShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  user-select: none;
  border-radius: 14px;
  transform-origin: center;
  box-shadow: 0 4px 10px rgba(16, 42, 67, 0.04);
  backface-visibility: hidden;
}

.tile.filled {
  border-color: #98a2b3;
  box-shadow: 0 8px 18px rgba(16, 42, 67, 0.08);
}

.tile.correct {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.tile.present {
  background: var(--yellow);
  border-color: var(--yellow);
  color: white;
}

.tile.absent {
  background: var(--gray);
  border-color: var(--gray);
  color: white;
}

.tile.flip {
  animation: flip 320ms ease forwards;
}

.tile.reset-flip {
  animation: resetFlip 520ms ease forwards;
}

@keyframes flip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

@keyframes resetFlip {
  0% { transform: rotateX(0deg) scale(1); opacity: 1; }
  45% { transform: rotateX(90deg) scale(0.96); opacity: 0.7; }
  55% { transform: rotateX(90deg) scale(0.96); opacity: 0.45; }
  100% { transform: rotateX(0deg) scale(1); opacity: 1; }
}

.board-actions {
  display: flex;
  justify-content: center;
}

@keyframes guessShimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

.board-enter-btn {
  min-width: 170px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
  background: linear-gradient(
    110deg,
    #0d2137 0%,
    #1a3f6f 25%,
    #2e6db4 45%,
    #5aa0e8 55%,
    #2e6db4 70%,
    #1a3f6f 85%,
    #0d2137 100%
  );
  background-size: 250% auto;
  box-shadow:
    0 10px 24px rgba(16, 42, 67, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: guessShimmer 3s linear infinite;
  border: 1px solid rgba(90, 160, 232, 0.25);
}

.board-enter-btn:hover {
  animation-duration: 1.2s;
  box-shadow:
    0 14px 32px rgba(16, 42, 67, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.board-enter-btn:active {
  animation-play-state: paused;
}

.post-fail-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.keyboard {
  display: grid;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  min-width: 34px;
  height: var(--key-height);
  padding: 0 8px;
  border: none;
  border-radius: 10px;
  background: var(--key);
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  font-size: var(--key-font);
  box-shadow: 0 4px 8px rgba(16, 42, 67, 0.05);
  transition: transform 120ms ease, opacity 120ms ease;
}

.key:active {
  transform: translateY(1px) scale(0.98);
}

.key.wide {
  min-width: 62px;
  padding-inline: 12px;
}

.key.correct {
  background: var(--green);
  color: white;
}

.key.present {
  background: var(--yellow);
  color: white;
}

.key.absent {
  background: var(--gray);
  color: white;
}

.leaderboard-top {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.82));
  border: 1px solid rgba(16, 42, 67, 0.08);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-card-featured {
  min-height: 128px;
  padding: 18px 18px;
  border-radius: 24px;
}

.stat-card-large {
  min-height: 128px;
}

.stat-card-compact {
  min-height: 108px;
}

.stat-card.crown {
  background: linear-gradient(180deg, #fff8e8, #fff3d1);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(16, 42, 67, 0.08);
  color: var(--primary);
  flex: 0 0 auto;
}

.stat-card-featured .stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
}

.crown .stat-icon {
  background: rgba(240, 180, 41, 0.2);
  color: #a66b00;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-card-featured .stat-icon svg {
  width: 26px;
  height: 26px;
}

.stat-label {
  margin: 0 0 4px;
  font-size: 0.83rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.stat-label-strong {
  font-size: 1rem;
  color: var(--primary);
}

.stat-card h3 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.05;
  color: var(--text);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.stat-card-featured h3 {
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.stat-subline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-card-featured .stat-subline {
  font-size: 1rem;
}

.leaderboard-card {
  padding: 14px;
}

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.leaderboard-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.leaderboard-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(16, 42, 67, 0.06);
  border: 1px solid rgba(16, 42, 67, 0.08);
}

.leaderboard-mode-tab {
  min-width: 98px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.leaderboard-mode-tab:hover {
  transform: translateY(-1px);
}

.leaderboard-mode-tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(16, 42, 67, 0.08);
}

.leaderboard-mode-panel {
  display: none;
}

.leaderboard-mode-panel.active {
  display: block;
}

.leaderboard-list {
  display: grid;
  gap: 12px;
}

.leaderboard-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(250,251,252,0.9));
  border: 1px solid rgba(16, 42, 67, 0.08);
  box-shadow: 0 2px 8px rgba(16, 42, 67, 0.04);
}

.leaderboard-item.rank-1 {
  background:
    linear-gradient(180deg, rgba(255,250,235,0.98), rgba(255,245,214,0.92)) padding-box,
    linear-gradient(135deg, #f6d776, #dbaf22, #fff3c4, #c99700) border-box;
  border: 1px solid transparent;
  box-shadow: 0 14px 30px rgba(209, 153, 0, 0.14);
}

.leaderboard-item.rank-2 {
  background:
    linear-gradient(180deg, rgba(249,250,251,0.98), rgba(240,244,247,0.94)) padding-box,
    linear-gradient(135deg, #c8d0db, #8b97a6, #f3f6f8, #7d8794) border-box;
  border: 1px solid transparent;
  box-shadow: 0 12px 24px rgba(123, 135, 148, 0.12);
}

.leaderboard-item.rank-3 {
  background:
    linear-gradient(180deg, rgba(252,246,241,0.98), rgba(246,236,227,0.94)) padding-box,
    linear-gradient(135deg, #d89a63, #a85b24, #f1c6a2, #94501e) border-box;
  border: 1px solid transparent;
  box-shadow: 0 10px 20px rgba(169, 84, 27, 0.11);
}

.rank-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.rank-badge.gold {
  background: linear-gradient(135deg, #f0b429, #d48a00);
}

.rank-badge.silver {
  background: linear-gradient(135deg, #a8b2bd, #7b8794);
}

.rank-badge.bronze {
  background: linear-gradient(135deg, #c97a3d, #a3541b);
}

.player-main {
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.player-name-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name-row > strong,
.player-name-row .clown-name-wrap {
  max-width: 100%;
}

.player-name {
  display: inline-block;
  line-height: 1.02;
  font-family: var(--font-body);
  letter-spacing: -0.03em;
}

.player-name.normal-rank-1 {
  color: #233245;
  font-weight: 900;
}

.player-name.normal-rank-2 {
  color: #2b3642;
  font-weight: 850;
}

.player-name.normal-rank-3 {
  color: #334050;
  font-weight: 825;
}

.player-name.normal-rank-default {
  color: var(--text);
  font-weight: 800;
}

.player-name.tie-group {
  white-space: normal;
  line-height: 1.15;
}

.clown-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  max-width: 100%;
  flex-wrap: nowrap;
}

.clown-stack,
.dunce-hat-wrap,
.clown-side {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.clown-rainbow {
  display: inline-block;
  background-color: #ef4444;
  background-image: linear-gradient(90deg, #ff3b30 0%, #ff7a00 14%, #ffd400 28%, #39d353 42%, #00bcd4 58%, #5b6cff 74%, #c026d3 88%, #ff4fa3 100%);
  background-size: 180% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 1px 0 rgba(255,255,255,0.18);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.clown-icon,
.dunce-icon {
  display: block;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

.dunce-icon {
  width: 30px;
  height: 30px;
}

.rank-size-1 .player-name,
.player-name.rank-size-1,
.rank-size-1 {
  font-size: 1.5rem;
}

.rank-size-2 .player-name,
.player-name.rank-size-2,
.rank-size-2 {
  font-size: 1.28rem;
}

.rank-size-3 .player-name,
.player-name.rank-size-3,
.rank-size-3 {
  font-size: 1.14rem;
}

.rank-size-4 .player-name,
.player-name.rank-size-4,
.rank-size-4 {
  font-size: 1rem;
}

.you-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f1fb;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.dunce-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff2e5, #ffe1d4);
  color: #8a4b00;
  font-size: 0.75rem;
  font-weight: 800;
  border: 1px solid rgba(240, 180, 41, 0.32);
}

.player-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.player-total {
  text-align: right;
}

.player-total .points {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.player-total .label {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  border-radius: 18px;
  background: rgba(255,255,255,0.75);
  border: 1px dashed var(--line-dark);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 30, 0.48);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-width: 100%;
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  border: 1px solid rgba(16, 42, 67, 0.08);
  box-shadow: 0 24px 60px rgba(16, 42, 67, 0.18);
  border-radius: 24px;
}

.modal-close-btn {
  position: sticky;
  top: 12px;
  margin-left: auto;
  margin-right: 12px;
  margin-top: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(16, 42, 67, 0.08);
  background: rgba(255,255,255,0.96);
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.modal-content {
  padding: 4px 20px 22px;
}

.modal-kicker {
  margin: 0 0 8px;
  color: #8a4b00;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding-right: 44px;
}

.modal-content h2 {
  margin: 0 0 14px;
  font-size: 1.8rem;
  line-height: 1.05;
  color: var(--primary);
  padding-right: 44px;
}

.modal-catchphrase {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.instructions-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.instructions-copy p,
.example-blocks p {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.example-blocks {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.example-row {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.example-tile {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.9);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
}

.example-tile.correct {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.example-tile.present {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #fff;
}

.example-tile.absent {
  background: var(--gray);
  border-color: var(--gray);
  color: #fff;
}

.modal-primary-btn {
  width: 100%;
}

@media (max-width: 640px) {
  :root {
    --app-max-width: 100%;
    --logo-max-width: 100%;
    --tile-size: min(16.5vw, 62px);
    --key-height: 54px;
  }

  body {
    padding-inline: 10px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .player-fields,
  .leaderboard-top {
    grid-template-columns: 1fr;
  }

  .tabs {
    gap: 8px;
  }

  .tab-btn {
    padding: 12px;
  }

  .player-meta {
    flex-direction: column;
  }

  .leaderboard-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .leaderboard-item {
    grid-template-columns: auto 1fr;
  }

  .player-total {
    grid-column: 1 / -1;
    text-align: left;
    padding-left: 54px;
  }

  .key {
    min-width: 30px;
    padding: 0 6px;
  }

  .key.wide {
    min-width: 54px;
  }

  .clown-name-wrap {
    gap: 6px;
  }

  .clown-icon,
  .dunce-icon {
    width: 24px;
    height: 24px;
  }

  .rank-size-1 .player-name,
  .player-name.rank-size-1,
  .rank-size-1 {
    font-size: 1.34rem;
  }

  .rank-size-2 .player-name,
  .player-name.rank-size-2,
  .rank-size-2 {
    font-size: 1.2rem;
  }

  .rank-size-3 .player-name,
  .player-name.rank-size-3,
  .rank-size-3 {
    font-size: 1.08rem;
  }

  .leaderboard-mode-tabs {
    width: 100%;
  }

  .leaderboard-mode-tab {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
  }

  .board-enter-btn {
    width: 100%;
    min-width: 0;
  }

  .keyboard {
    position: sticky;
    bottom: 0;
    z-index: 30;
    margin-top: 10px;
    padding: 10px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    background: rgba(247, 247, 245, 0.98);
    backdrop-filter: blur(14px);
    box-shadow: 0 -12px 28px rgba(16, 42, 67, 0.12), 0 0 0 1px rgba(16, 42, 67, 0.08);
  }

  .modal-overlay {
    padding: 0;
    align-items: stretch;
    justify-items: stretch;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .modal-close-btn {
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    margin-right: 12px;
  }

  .modal-content {
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .modal-content h2 {
    font-size: 1.52rem;
  }

  .example-row {
    gap: 6px;
  }

  .example-tile {
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
  }
}

.post-fail-actions::before {
  content: "Enter clown mode, max 10 points.";
  display: block;
  margin-bottom: 2px;
  color: #8a4b00;
  font-weight: 700;
  text-align: center;
}

.keyboard--name-focused {
  opacity: 0.4;
  pointer-events: none;
}
