:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5d6678;
  --primary: #5b4ae6;
  --primary-dark: #4131c8;
  --accent: #f28b2d;
  --success: #087f5b;
  --danger: #d92d45;
  --border: #dfe3ec;
  --shadow: 0 10px 30px rgba(31, 42, 68, 0.08);
  --focus: #1677ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  transform: translateY(-160%);
}
.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  text-align: center;
  padding: 2.25rem 1rem 1.25rem;
  background: radial-gradient(circle at top, #eeeaff 0, transparent 68%);
}

.app-header h1 {
  margin: 0;
  font-size: 2.5rem;
}
.app-header p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.game-active .app-header {
  padding: 0.65rem 1rem 0.35rem;
  background: transparent;
}
.game-active .app-header h1 {
  font-size: 1.35rem;
}
.game-active .app-header > p,
.game-active .header-meta,
.game-active .game-discovery {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-discovery {
  max-width: 1100px;
  width: 100%;
  margin: 1rem auto 0;
  padding: 0 1rem;
}
.discovery-heading,
.discovery-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.discovery-heading h2 {
  margin: 0.15rem 0 0;
  font-size: 1.55rem;
}
.eyebrow {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.discovery-tools {
  margin-top: 0.85rem;
}
.search-games {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: min(100%, 340px);
  padding: 0 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.search-games:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.16);
}
.search-games input {
  width: 100%;
  border: 0;
  padding-inline: 0;
  outline: 0;
  background: transparent;
}
.filter-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-chip {
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}
.filter-chip.active {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: #eeecff;
  font-weight: 700;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.menu-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}

.menu-card:hover,
.menu-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.menu-card h3 {
  margin: 0 0 0.5rem;
  color: var(--primary);
}
.menu-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.game-card-top,
.game-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.game-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eeecff;
  font-size: 1.35rem;
}
.game-kind {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.game-kind.advanced {
  color: #7c3aed;
}
.game-card-title,
.game-card-desc,
.game-card-stat {
  display: block;
}
.game-card-title {
  margin-top: 0.85rem;
  color: var(--primary-dark);
  font-size: 1.08rem;
  font-weight: 800;
}
.game-card-desc {
  min-height: 2.6em;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.game-card-meta {
  justify-content: flex-start;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.game-card-meta span {
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
}
.game-card-stat {
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}
.menu-empty {
  grid-column: 1 / -1;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.game-header h2 {
  margin: 0;
  flex: 1;
  text-align: center;
}

#game-score {
  font-weight: 700;
  color: var(--primary);
  min-width: 90px;
  text-align: right;
}

#game-stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  min-height: 300px;
  overflow-wrap: anywhere;
}

.game-messages {
  max-width: 680px;
  margin: 0 auto;
}
.game-messages:empty {
  display: none;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-dark);
}
.btn.secondary {
  background: var(--border);
  color: var(--text);
}
.btn.secondary:hover {
  background: #d1d5db;
}
.btn.danger {
  background: var(--danger);
  color: #fff;
}

input[type="text"],
input[type="number"] {
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.message {
  padding: 0.75rem;
  border-radius: 8px;
  margin: 1rem 0;
  font-weight: 600;
}
.message.success {
  background: #d1fae5;
  color: #065f46;
}
.message.error {
  background: #fee2e2;
  color: #991b1b;
}
.message.info {
  background: #dbeafe;
  color: #1e40af;
}

.app-footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Game-specific shared styles */
.tile-grid {
  display: grid;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}

.responsive-game-grid {
  width: min(100%, var(--grid-max)) !important;
  max-width: var(--grid-max);
  grid-template-columns: repeat(
    var(--grid-columns),
    minmax(0, 1fr)
  ) !important;
  gap: var(--grid-gap, 8px) !important;
}

.responsive-game-grid > * {
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  aspect-ratio: 1;
}

.sudoku-cell.sudoku-peer {
  background: #f1f3ff !important;
}
.sudoku-cell.sudoku-match {
  background: #dcd8ff !important;
}
.sudoku-cell.sudoku-conflict {
  background: #ffe4e8 !important;
  color: var(--danger) !important;
}
.sudoku-cell.sudoku-given {
  color: var(--text) !important;
  font-weight: 800;
}

.tile {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  background: #e0e7ff;
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
}

.tile.selected {
  background: var(--primary);
  color: #fff;
}

.tile.correct {
  background: var(--success);
  color: #fff;
}
.tile.wrong {
  background: var(--danger);
  color: #fff;
}

.controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.timer-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.timer-bar > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s linear;
}

.list-pill {
  display: inline-block;
  background: #e0e7ff;
  color: var(--primary-dark);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin: 0.2rem;
  font-size: 0.85rem;
}

/* Word Dominoes */
.domino-game {
  width: min(100%, 820px);
  margin: 0 auto;
  text-align: center;
}

.domino-intro {
  max-width: 650px;
  margin: 0 auto 1rem;
  color: var(--muted);
  line-height: 1.55;
}

.domino-scorebar {
  display: grid;
  grid-template-columns: 260px 220px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem 1rem;
  margin: 0 auto 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #d8d4fe;
  border-radius: 12px;
  background: #faf9ff;
  color: #3730a3;
}

.domino-scorebar.timed {
  grid-template-columns: 260px 220px;
}

.domino-mode,
.domino-english {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.domino-mode select,
.domino-english select {
  min-height: 38px;
  padding: 0.35rem 2rem 0.35rem 0.55rem;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #fff;
  color: var(--primary-dark);
  font: inherit;
  font-weight: 700;
}

#domino-phrase-score {
  grid-column: 1 / -1;
  text-align: center;
}

.domino-scorebar.timed #domino-phrase-score {
  grid-column: 1;
}

.domino-scorebar.timed #domino-timer {
  grid-column: 2;
  text-align: center;
}

.domino-scorebar strong,
#domino-timer {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

#domino-timer {
  color: #0f766e;
  font-weight: 850;
}

#domino-timer.urgent {
  color: var(--danger);
}

.domino-scorebar small {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.4;
}

.domino-board {
  position: relative;
  overflow: hidden;
  padding: 1.1rem;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.95) 0 7%, transparent 7.5%),
    radial-gradient(circle at 88% 86%, rgba(255, 255, 255, 0.7) 0 9%, transparent 9.5%),
    linear-gradient(145deg, #eef2ff, #f5f3ff 55%, #ecfeff);
  box-shadow: inset 0 1px 0 #fff, 0 12px 30px rgba(79, 70, 229, 0.1);
}

.domino-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.domino-round-title {
  text-align: left;
}

#domino-progress {
  width: 5.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.domino-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.14);
}

.domino-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #8b5cf6, #06b6d4);
  transition: width 0.35s ease;
}

.domino-trail {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 1rem 0.25rem 0.7rem;
}

.domino-placed {
  display: inline-flex;
  min-width: 76px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.8rem;
  border: 2px solid #a5b4fc;
  border-radius: 11px;
  background: #fff;
  color: #3730a3;
  box-shadow: 0 5px 0 #c7d2fe, 0 8px 16px rgba(49, 46, 129, 0.12);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.035em;
}

.domino-placed.current {
  border-color: var(--accent);
  background: #fffbeb;
  color: #92400e;
  box-shadow: 0 5px 0 #fde68a, 0 8px 16px rgba(146, 64, 14, 0.12);
}

.domino-connector {
  color: #818cf8;
  font-size: 1.4rem;
  font-weight: 900;
}

.domino-feedback {
  display: flex;
  height: 3rem;
  align-items: center;
  justify-content: center;
  color: #0f766e;
  font-weight: 800;
}

.domino-feedback.error {
  color: #991b1b;
}

.domino-feedback.info {
  color: #1e40af;
}

.domino-feedback-copy {
  width: min(100%, 360px);
  text-align: left;
}

.domino-clue {
  height: 4.5rem;
  max-width: 560px;
  margin: 0.75rem auto 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  color: #4338ca;
  line-height: 1.4;
}

.domino-clue.placeholder {
  visibility: hidden;
}

.domino-prompt {
  min-height: 1.55rem;
  margin: 1.15rem 0 0.75rem;
  font-size: 1.05rem;
}

.domino-prompt:not(.complete) strong {
  display: inline-block;
  width: 8rem;
  text-align: left;
}

.domino-tray {
  min-height: 54px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  max-width: 780px;
  margin: 0 auto;
}

.domino-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 470px);
  min-height: 44px;
  margin-inline: auto;
}

.domino-controls .btn {
  white-space: nowrap;
}

.domino-choice {
  flex: 0 1 96px;
  width: 96px;
  min-width: 0;
  min-height: 54px;
  padding: 0.7rem 0.55rem;
  border: 2px solid #c7d2fe;
  border-radius: 12px;
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 0 #e0e7ff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.domino-choice:hover:not(:disabled),
.domino-choice:focus-visible {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #c7d2fe;
}

.domino-choice.tried,
.domino-choice:disabled {
  border-color: #e5e7eb;
  background: #f3f4f6;
  color: #9ca3af;
  box-shadow: none;
  text-decoration: line-through;
  cursor: default;
}

.domino-placed.future,
.domino-connector.future,
.domino-choice.placed {
  visibility: hidden;
  pointer-events: none;
}

/* Animation hooks */
@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.animate-pop {
  animation: pop 0.25s ease-out;
}

.animate-shake {
  animation: shake 0.3s ease-in-out;
}

.animate-pulse {
  animation: pulse 0.6s ease-out;
}

/* End-of-round panel (replaces auto-restart timers) */
.end-panel {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  text-align: center;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 44px);
  gap: 0.35rem;
  justify-content: center;
  margin: 0.85rem auto 0;
}
.direction-pad .btn {
  padding: 0;
  font-size: 1.25rem;
}
.direction-up {
  grid-column: 2;
}
.direction-left {
  grid-column: 1;
  grid-row: 2;
}
.direction-down {
  grid-column: 2;
  grid-row: 2;
}
.direction-right {
  grid-column: 3;
  grid-row: 2;
}

.expression-builder {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.expression-builder .btn {
  min-width: 44px;
  padding-inline: 0.7rem;
}
.round-locked {
  opacity: 0.78;
}
.end-panel.success {
  border-color: var(--success);
  background: #ecfdf5;
}
.end-panel.error {
  border-color: var(--danger);
  background: #fef2f2;
}
.end-panel h3 {
  margin: 0 0 0.5rem;
}
.end-panel p {
  margin: 0.25rem 0;
  color: var(--text);
}

/* Ad & storefront promo areas — labelled, reserved-height, never in-game */
.menu-ad-mount {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 1rem;
  width: 100%;
}
.ad-area {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1.25rem 1rem 0.75rem;
  text-align: center;
  overflow: hidden;
}
.ad-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.house-ad {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  background: #fffbeb;
  text-align: center;
}
.house-ad:hover {
  border-color: var(--accent);
}
.house-ad.compact {
  margin-top: 1rem;
  font-size: 0.9rem;
}
.house-ad-body {
  display: block;
  margin: 0.15rem 0 0.35rem;
}
.house-ad-cta {
  display: inline-block;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 0.85rem;
}
.menu-card.store-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fffbeb;
  border-color: var(--accent);
}
.menu-card.store-card h3 {
  color: var(--accent);
}

/* Engagement layer: streak chip, stats screen, achievements */
.header-meta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.streak-chip {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.streak-chip.active {
  background: #fef3c7;
  color: #92400e;
}
.streak-line {
  font-weight: 700;
  color: #92400e;
}

.stats-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 50;
  overflow-y: auto;
}
.stats-panel {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  max-width: 640px;
  width: 100%;
}
.stats-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.stats-head h2 {
  margin: 0;
}
.stats-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.stats-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
}
.stats-tile b {
  display: block;
  font-size: 1.5rem;
  color: var(--primary);
}
.stats-tile span {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin: 0.75rem 0 1rem;
}
.ach {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
}
.ach .ach-icon {
  font-size: 1.4rem;
  display: block;
}
.ach .ach-name {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  margin-top: 0.2rem;
}
.ach .ach-desc {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}
.ach.locked {
  opacity: 0.35;
  filter: grayscale(1);
}
.ach.unlocked {
  background: #fefce8;
  border-color: var(--accent);
}

.ach-toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fefce8;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin: 0.6rem auto 0;
  max-width: 360px;
  text-align: left;
  font-size: 0.9rem;
  animation: pop 0.4s ease-out;
}
.ach-toast .ach-icon {
  font-size: 1.6rem;
}

.stats-table-wrap {
  overflow-x: auto;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.stats-table th,
.stats-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.stats-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-panel {
  max-width: 580px;
}

.share-intro,
.share-local-note,
.share-status {
  color: var(--muted);
  line-height: 1.5;
}

.share-preview {
  width: 100%;
  min-height: 150px;
  margin-top: 0.25rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.share-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.share-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  text-align: center;
  text-decoration: none;
}

.share-x {
  background: #111;
  color: #fff;
}

.share-facebook {
  background: #1877f2;
  color: #fff;
}

.share-local-note {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  background: #fff8e6;
  color: #6b4f00;
  font-size: 0.86rem;
}

.share-status {
  min-height: 1.5rem;
  margin: 0.7rem 0 0;
  font-weight: 700;
}

/* How-to-play modal */
.game-header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
#help-btn {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
@media (max-width: 560px) {
  .game-header h2 {
    font-size: 1.1rem;
  }
  #help-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
  }
}
.help-panel {
  max-width: 520px;
}
.help-goal {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
}
.help-rules {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}
.help-rules li {
  margin: 0.35rem 0;
}
.help-example {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.9rem 0.75rem 0.75rem;
  text-align: center;
  margin-bottom: 1rem;
}
.h-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin: 4px 0;
  flex-wrap: wrap;
}
.h-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 4px;
  border-radius: 6px;
  background: #e0e7ff;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
}
.h-tile.hl {
  background: var(--accent);
  color: #fff;
}
.h-tile.good {
  background: var(--success);
  color: #fff;
}
.h-tile.dark {
  background: #374151;
  color: #fff;
}
.h-tile.cage {
  border: 2px solid #374151;
  border-radius: 0;
  background: #fff;
  position: relative;
}
.h-tile.cage:first-child::before {
  content: "3+";
  position: absolute;
  top: 0;
  left: 2px;
  font-size: 0.55rem;
  color: var(--muted);
}
.h-tile.path {
  background: var(--primary);
  color: #fff;
}
.h-arrow {
  font-weight: 700;
  color: var(--muted);
  margin: 0 4px;
}
.h-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0 0;
}
.h-expr {
  font-weight: 700;
  font-size: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}
.h-tower {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.h-block {
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.3rem 1rem;
  text-transform: uppercase;
  font-size: 0.9rem;
}

/* Balloon Pop */
.balloon-area {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  margin: 0.5rem 0;
}
.balloon {
  border-radius: 50% 50% 48% 48%;
  box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.08);
  transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
}
.balloon.straining {
  animation: pulse 0.6s ease-out infinite;
}
.balloon-string {
  width: 2px;
  height: 28px;
  background: var(--muted);
}
.balloon-pop {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--danger);
  animation: pop 0.4s ease-out;
}
.balloon-answer {
  display: flex;
  gap: 1.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.balloon-word {
  display: flex;
  gap: 5px;
}
.balloon-slot {
  width: 30px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 3px solid var(--text);
  font-weight: 700;
  font-size: 1.3rem;
}
.balloon-slot.missed {
  color: var(--danger);
}
@keyframes float-away {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: translateY(-90px) translateX(14px) rotate(6deg);
  }
  60% {
    transform: translateY(-190px) translateX(-10px) rotate(-6deg);
  }
  100% {
    transform: translateY(-340px) translateX(8px) rotate(4deg);
    opacity: 0;
  }
}
.balloon.float-away {
  animation: float-away 2.4s ease-in forwards;
}
@media (prefers-reduced-motion: reduce) {
  .balloon.float-away {
    animation: none;
    opacity: 0.4;
  }
}

/* Confetti (Puzzler.celebrate) */
#confetti-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 90;
}
.confetti {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translateY(105vh) translateX(var(--drift, 0px))
      rotate(var(--spin, 540deg));
    opacity: 0.6;
  }
}

.settings-panel {
  max-width: 560px;
}
.settings-intro,
.settings-note {
  color: var(--muted);
  line-height: 1.5;
}
.settings-list {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0;
}
.settings-list label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.settings-list strong,
.settings-list small {
  display: block;
}
.settings-list small {
  margin-top: 0.2rem;
  color: var(--muted);
}
.settings-list input {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}
.wellbeing-note {
  max-width: 460px;
  margin: 0.8rem auto 0 !important;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: #eef8f4;
  color: #22614e !important;
  font-size: 0.88rem;
}

.large-text {
  font-size: 112.5%;
}
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@media (max-width: 840px) {
  .domino-trail {
    min-height: 124px;
  }
  .domino-tray {
    min-height: 118px;
  }
}

@media (max-width: 640px) {
  .game-discovery {
    margin-top: 0.5rem;
    padding: 0 0.75rem;
  }
  .discovery-heading,
  .discovery-tools {
    align-items: stretch;
    flex-direction: column;
  }
  .discovery-heading {
    flex-direction: row;
    align-items: center;
  }
  .search-games {
    width: 100%;
  }
  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.15rem 0 0.35rem;
  }
  .filter-chip {
    flex: 0 0 auto;
  }
  .app-header {
    padding: 1.25rem 0.75rem 0.8rem;
  }
  .app-header h1 {
    font-size: 2rem;
  }
  .app-header p {
    font-size: 0.9rem;
  }
  .menu-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  .menu-card {
    padding: 1rem;
  }
  .balloon-answer {
    width: 100%;
    gap: 0.75rem;
  }
  .balloon-word {
    max-width: 100%;
    gap: 2px;
  }
  .balloon-slot {
    width: clamp(18px, 6vw, 30px);
    height: 34px;
    font-size: 1.1rem;
  }
  main {
    padding: 0.5rem;
  }
  #game-stage {
    padding: 0.75rem;
    border-radius: 10px;
    min-height: 240px;
  }
  .game-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.5rem;
  }
  .game-header h2 {
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .game-header-right {
    grid-column: 1 / -1;
    justify-content: space-between;
  }
  #game-score {
    min-width: 0;
  }
  .controls {
    gap: 0.4rem;
  }
  .controls .btn {
    flex: 1 1 auto;
  }
  input[type="text"],
  input[type="number"] {
    max-width: 100%;
  }
  .letter-keyboard {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    max-width: 280px;
  }
  .letter-keyboard > * {
    min-height: 38px;
  }
  .numeric-pad {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    max-width: 260px;
  }
  .numeric-pad > * {
    min-height: 42px;
  }
  .stats-overlay {
    padding: 0;
    align-items: stretch;
  }
  .stats-panel {
    min-height: 100%;
    border-radius: 0;
    padding: 1rem;
  }
  .share-actions {
    grid-template-columns: 1fr;
  }
  .stats-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .domino-board {
    padding: 0.85rem 0.65rem;
    border-radius: 14px;
  }
  .domino-clue {
    height: 6rem;
  }
  .domino-heading {
    align-items: flex-start;
  }
  .domino-scorebar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.55rem;
  }
  .domino-scorebar.timed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .domino-mode {
    justify-content: space-between;
    grid-column: 1 / -1;
  }
  .domino-english {
    justify-content: space-between;
    grid-column: 1 / -1;
  }
  .domino-scorebar strong,
  #domino-timer {
    text-align: center;
  }
  .domino-trail {
    min-height: 220px;
    gap: 0.28rem;
    padding-top: 0.8rem;
  }
  .domino-placed {
    min-width: 64px;
    min-height: 43px;
    padding: 0.55rem 0.58rem;
    font-size: 0.78rem;
  }
  .domino-connector {
    font-size: 1rem;
  }
  .domino-tray {
    min-height: 224px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .domino-choice {
    width: auto;
    min-height: 50px;
    font-size: 0.82rem;
  }
  .domino-feedback {
    height: 4.5rem;
  }
  .domino-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 98px;
  }
  .domino-controls .btn:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .btn {
    padding-inline: 0.75rem;
  }
  .tile {
    font-size: 1rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.resume-badge {
  color: var(--success);
  font-weight: 700;
}

/* Daily challenges hub */
.daily-hub {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 0.5rem;
  width: 100%;
}
.daily-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.daily-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.daily-date {
  font-size: 0.85rem;
  color: var(--muted);
}
.daily-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.daily-chip {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.daily-chip:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.daily-chip.done {
  background: #ecfdf5;
  border-color: var(--success);
  color: #065f46;
}
.daily-chip .daily-tick {
  font-weight: 700;
  margin-right: 0.25rem;
}
.daily-level {
  margin-left: 0.35rem;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  background: #f3e8ff;
  color: #6d28d9;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.daily-chip.done .daily-tick {
  color: var(--success);
}

/* ------------------------------------------------------------------
   Host chrome compatibility - shopping.christmas header, drawer and
   footer. storetheme.css and article.css load BEFORE this file, so
   their element-level rules (body line-height, heading font, bold
   inline-flex .btn, sticky search bar z-index) would otherwise leak
   into the game shell. Everything below the store chrome sits inside
   .puzzler-app; overlays are appended to <body> and handled by name.
   ------------------------------------------------------------------ */
.puzzler-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: normal;
  letter-spacing: normal;
  word-spacing: normal;
}
.puzzler-app h1,
.puzzler-app h2,
.puzzler-app h3,
.stats-panel h2,
.stats-panel h3 {
  font-family: inherit;
}
.puzzler-app .btn,
.stats-panel .btn {
  display: inline-block;
  gap: 0;
  font-weight: normal;
}
/* Spelling Bee bonus words (real words outside the curated list). */
.list-pill.bonus {
  background: #fff7e6;
  border: 1px dashed #f28b2d;
}
/* Puzzler's modals must sit above the store's sticky search bar (200),
   nav (250) and drawer (400). */
.stats-overlay,
#confetti-layer {
  z-index: 1000;
}
/* The store footer's link row does not wrap in storetheme.css, which
   overflows a 375px phone; let it wrap on this page. */
footer .footer-bottom-links {
  flex-wrap: wrap;
}
