:root {
  --color-bg-start: #eff6ff;
  --color-bg-end: #dbeafe;
  --color-surface: rgba(255, 255, 255, 0.9);
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-navy: #172554;
  --color-muted: #64748b;
  --color-empty: #dbe4f0;
  --color-white: #ffffff;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --board-gap: clamp(3px, calc(14px / var(--board-size, 3)), 9px);
  --shadow-card: 0 24px 60px rgba(30, 64, 175, 0.15);
  --shadow-tile: inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    0 5px 12px rgba(15, 23, 42, 0.16);
  --transition-fast: 180ms ease;
}

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

html {
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.95), transparent 32%),
    linear-gradient(145deg, var(--color-bg-start), var(--color-bg-end));
  color: var(--color-navy);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  color: inherit;
  font: inherit;
}

select,
input {
  color: inherit;
  font: inherit;
}

.game-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: clamp(24px, 5vw, 52px) 18px;
}

.game-header {
  position: relative;
  width: min(100%, 910px);
  max-width: 640px;
  text-align: center;
}

.language-control {
  position: fixed;
  z-index: 10;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 18px rgba(30, 64, 175, 0.12);
  backdrop-filter: blur(10px);
}

.language-control label {
  color: var(--color-muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.language-control select {
  border: 0;
  background: transparent;
  color: var(--color-navy);
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
  outline: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--color-primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.game-header h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.game-header p {
  margin-top: 12px;
  color: var(--color-muted);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.game-header .app-subtitle {
  margin-top: 8px;
  color: var(--color-primary-dark);
  font-weight: 750;
}

.game-header .app-subtitle + #game-instruction {
  margin-top: 5px;
  font-size: clamp(0.84rem, 2vw, 0.96rem);
}

.game-layout {
  display: grid;
  width: min(100%, 910px);
  grid-template-columns: minmax(230px, 310px) minmax(340px, 510px);
  align-items: start;
  justify-content: center;
  gap: 22px;
}

.customizer-card,
.game-card {
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  /* Leave room for the sticky 52px topbar when scrollIntoView() runs on start,
     so the first tile row isn't hidden under the header on mobile. */
  scroll-margin-top: 64px;
}

.game-card__toolbar {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 9px;
}

.configure-button {
  border: 0;
  background: transparent;
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.configure-button:hover {
  text-decoration: underline;
}

.customizer-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.customizer-card h2 {
  font-size: 1.45rem;
  letter-spacing: -0.025em;
}

.customizer-card__intro {
  margin-top: 6px;
  color: var(--color-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.mode-field {
  border: 0;
}

.mode-field legend,
.preview-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 750;
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-option {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.mode-option:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.mode-option.is-active {
  border-color: var(--color-primary);
  background: #dbeafe;
  color: var(--color-primary-dark);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

.mode-option:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.mode-option__icon {
  display: grid;
  min-width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  background: var(--color-white);
  color: var(--color-primary);
  font-size: 0.68rem;
  font-weight: 900;
}

.image-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.image-options[hidden] {
  display: none;
}

.image-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 6px solid var(--color-white);
  border-radius: var(--radius-md);
  background-color: #dbeafe;
  background-image: var(--preview-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.17);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > label:first-child {
  font-size: 0.84rem;
  font-weight: 750;
}

.field__hint {
  overflow: hidden;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-input:focus-visible + .button {
  outline: 4px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

.select-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0 40px 0 13px;
  background-color: #f8fafc;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--color-primary);
  outline: 3px solid rgba(37, 99, 235, 0.15);
}

.text-button {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

.game-card {
  display: flex;
  width: min(100%, 510px);
  flex-direction: column;
  align-items: center;
}

.stats {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: rgba(248, 250, 252, 0.9);
}

.stat__label {
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.stat__value {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.board {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  grid-template-columns: repeat(var(--board-size, 3), 1fr);
  grid-template-rows: repeat(var(--board-size, 3), 1fr);
  gap: var(--board-gap);
  padding: var(--board-gap);
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #cbd5e1;
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.18);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.board--inactive {
  filter: saturate(0.62);
}

.tile,
.tile--empty {
  min-width: 0;
  min-height: 0;
  border-radius: clamp(3px, calc(28px / var(--board-size, 3)), 14px);
}

.tile {
  position: relative;
  border: 0;
  background-color: #93c5fd;
  background-image: var(--puzzle-image);
  background-position: var(--background-position);
  background-repeat: no-repeat;
  background-size: calc(var(--board-size, 3) * 100%) calc(var(--board-size, 3) * 100%);
  box-shadow: var(--shadow-tile);
  cursor: pointer;
  transition: transform var(--transition-fast), filter var(--transition-fast), box-shadow var(--transition-fast);
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.board--numbers .tile {
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 48%),
    linear-gradient(145deg, #60a5fa, #2563eb);
  color: var(--color-white);
  font-size: var(--tile-font-size, 1.65rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.32);
}

.board--numbers .tile::after {
  display: none;
}

.board--dense .tile {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.board--dense .tile--empty {
  background: var(--color-empty);
}

.tile::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 42%);
  content: "";
  pointer-events: none;
}

.tile:hover {
  filter: brightness(1.06);
}

.tile:focus-visible {
  z-index: 2;
  outline: 4px solid rgba(37, 99, 235, 0.42);
  outline-offset: 2px;
}

.tile:active {
  transform: scale(0.96);
}

.tile[aria-disabled="true"] {
  cursor: default;
}

.tile--empty {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.5) 0 2px, transparent 3px) center / 18px 18px,
    var(--color-empty);
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.1);
}

.game-status {
  min-height: 1.4em;
  margin: 14px 0;
  color: var(--color-muted);
  font-size: 0.88rem;
  text-align: center;
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 13px 26px;
  font-weight: 750;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.button--primary {
  background: var(--color-primary);
  color: var(--color-white);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}

.button--secondary {
  width: 100%;
  min-height: 44px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--color-primary-dark);
  box-shadow: none;
  font-size: 0.84rem;
}

.button--secondary:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.button--primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.34);
}

.button:focus-visible {
  outline: 4px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

.button:active {
  transform: translateY(0);
}

.modal[hidden] {
  display: none;
}

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

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(5px);
  animation: fade-in 220ms ease both;
}

.modal__content {
  position: relative;
  width: min(100%, 400px);
  padding: 34px 28px 28px;
  border-radius: var(--radius-lg);
  background: var(--color-white);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.3);
  text-align: center;
  animation: modal-in 280ms cubic-bezier(0.2, 0.85, 0.35, 1.15) both;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--color-muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: #e2e8f0;
  color: var(--color-navy);
}

.modal__close:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.modal__icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 2rem;
  font-weight: 900;
}

.record-message {
  width: fit-content;
  margin: 14px auto 0;
  border-radius: 999px;
  padding: 7px 13px;
  background: #fef3c7;
  color: #92400e !important;
  font-size: 0.78rem;
  font-weight: 800;
}

.record-message--daily {
  background: #dbeafe;
  color: var(--color-primary-dark) !important;
}

.statistics-modal__content {
  width: min(100%, 720px);
  max-height: min(90vh, 820px);
  overflow-y: auto;
  text-align: left;
}

.statistics-modal__content > .eyebrow,
.statistics-modal__content > h2 {
  text-align: center;
}

.statistics-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 22px;
}

.statistics-item {
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}

.statistics-item span,
.statistics-item strong,
.current-size-stats span,
.current-size-stats strong {
  display: block;
}

.statistics-item span,
.current-size-stats span {
  color: var(--color-muted);
  font-size: 0.7rem;
  line-height: 1.25;
}

.statistics-item strong,
.current-size-stats strong {
  margin-top: 5px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.current-size-stats {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  background: #eff6ff;
}

.current-size-stats h3 {
  margin-bottom: 11px;
  font-size: 0.94rem;
}

.current-size-stats__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.statistics-table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

.statistics-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.statistics-table th,
.statistics-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
  white-space: nowrap;
}

.statistics-table th:first-child,
.statistics-table td:first-child {
  text-align: left;
}

.statistics-table th {
  background: #f8fafc;
  color: var(--color-muted);
  font-weight: 750;
}

.statistics-table tr:last-child td {
  border-bottom: 0;
}

.statistics-table tr.is-current-size td {
  background: #eff6ff;
  color: var(--color-primary-dark);
  font-weight: 750;
}

.no-stats-message {
  margin-top: 18px;
  color: var(--color-muted);
  font-size: 0.84rem;
  text-align: center;
}

.button--danger {
  width: 100%;
  margin-top: 18px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.button--danger:hover {
  background: #ffe4e6;
}

.achievements-modal__content {
  width: min(100%, 650px);
  max-height: min(90vh, 820px);
  overflow-y: auto;
}

.achievements-progress {
  margin-top: 8px;
  color: var(--color-muted);
  font-size: 0.86rem;
  text-align: center;
}

.achievements-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.achievement-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.achievement-card--locked {
  opacity: 0.58;
  filter: grayscale(0.5);
}

.achievement-card--unlocked {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.achievement-card__icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--color-white);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
  font-size: 1.55rem;
}

.achievement-card__content {
  min-width: 0;
}

.achievement-card__content strong,
.achievement-card__content span {
  display: block;
}

.achievement-card__content strong {
  font-size: 0.9rem;
}

.achievement-card__description {
  margin-top: 3px;
  color: var(--color-muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.achievement-card__date {
  margin-top: 5px;
  color: var(--color-primary-dark);
  font-size: 0.68rem;
  font-weight: 700;
}

.achievement-card__status {
  border-radius: 999px;
  padding: 5px 8px;
  background: #e2e8f0;
  color: var(--color-muted);
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.achievement-card--unlocked .achievement-card__status {
  background: #dbeafe;
  color: var(--color-primary-dark);
}

.achievement-toast {
  position: fixed;
  z-index: 40;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  width: min(calc(100% - 32px), 340px);
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid #fde68a;
  border-radius: 18px;
  background: rgba(255, 251, 235, 0.96);
  box-shadow: 0 18px 45px rgba(120, 53, 15, 0.2);
  color: #78350f;
  backdrop-filter: blur(12px);
  animation: achievement-toast-in 260ms ease both;
}

.achievement-toast[hidden] {
  display: none;
}

.achievement-toast__icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: #fef3c7;
  font-size: 1.4rem;
}

.achievement-toast__label,
.achievement-toast strong {
  display: block;
}

.daily-modal__content {
  width: min(100%, 460px);
}

.daily-modal__sun {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: #fef3c7;
  color: #d97706;
  font-size: 2rem;
  box-shadow: inset 0 0 0 1px #fde68a;
}

.daily-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 22px 0 0;
  text-align: left;
}

.daily-details div {
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}

.daily-details span,
.daily-details strong {
  display: block;
}

.daily-details span {
  color: var(--color-muted);
  font-size: 0.7rem;
  line-height: 1.25;
}

.daily-details strong {
  margin-top: 5px;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.daily-details .is-completed {
  color: #15803d;
}

.daily-modal__content .button--primary {
  width: 100%;
  margin-top: 18px;
}

.gallery-modal__content {
  width: min(100%, 780px);
  max-height: min(92vh, 860px);
  overflow-y: auto;
  text-align: left;
}

.gallery-modal__content > .eyebrow,
.gallery-modal__content > h2,
.gallery-intro {
  text-align: center;
}

.gallery-intro {
  margin-top: 7px;
  color: var(--color-muted);
  font-size: 0.86rem;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 20px 0 16px;
}

.gallery-filter {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 7px 13px;
  background: #f8fafc;
  color: var(--color-muted);
  font-size: 0.74rem;
  font-weight: 750;
  cursor: pointer;
}

.gallery-filter:hover,
.gallery-filter.is-active {
  border-color: var(--color-primary);
  background: #dbeafe;
  color: var(--color-primary-dark);
}

.gallery-filter:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.gallery-card {
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: #f8fafc;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.gallery-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.gallery-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 2px;
}

.gallery-card__image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e2e8f0;
}

.gallery-card__footer {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 9px;
}

.gallery-card__title {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card__status {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 6px;
  background: #e2e8f0;
  color: var(--color-muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.gallery-card.is-selected .gallery-card__status {
  background: #dbeafe;
  color: var(--color-primary-dark);
}

.gallery-card__fallback {
  display: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  place-items: center;
  background: linear-gradient(145deg, #dbeafe, #bfdbfe);
  color: var(--color-primary-dark);
  font-size: 1.8rem;
}

.gallery-card.has-error .gallery-card__image {
  display: none;
}

.gallery-card.has-error .gallery-card__fallback {
  display: grid;
}

.gallery-modal__content > .button--secondary {
  margin-top: 18px;
}

.achievement-toast__label {
  margin-bottom: 2px;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.achievement-toast strong {
  font-size: 0.92rem;
}

@keyframes achievement-toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

.modal__content h2 {
  font-size: 1.8rem;
  letter-spacing: -0.035em;
}

.modal__content > p {
  margin-top: 8px;
  color: var(--color-muted);
}

.modal__results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.modal__results div {
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}

.modal__results span,
.modal__results strong {
  display: block;
}

.modal__results span {
  margin-bottom: 4px;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.modal__results strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
}

@media (max-width: 480px) {
  .game-shell {
    justify-content: flex-start;
    gap: 14px;
    padding: max(14px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
  }

  .game-header h1 {
    font-size: clamp(1.7rem, 9vw, 2.25rem);
  }

  .language-control {
    position: static;
    width: fit-content;
    margin: 0 auto 12px;
  }

  .game-header p {
    margin-top: 7px;
    font-size: 0.88rem;
  }

  .customizer-card,
  .game-card {
    padding: 12px;
    border-radius: 18px;
  }

  .stats {
    gap: 8px;
    margin-bottom: 12px;
  }

  .game-card__toolbar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 14px;
  }

  .configure-button {
    min-height: 30px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .game-status {
    margin: 9px 0;
    font-size: 0.8rem;
  }

  .button {
    width: 100%;
  }

  .statistics-modal__content {
    max-height: calc(100dvh - 20px);
    padding: 28px 14px 18px;
  }

  .achievements-modal__content {
    max-height: calc(100dvh - 20px);
    padding: 28px 12px 18px;
  }

  .achievement-card {
    grid-template-columns: 42px 1fr;
    gap: 10px;
    padding: 11px;
  }

  .achievement-card__icon {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  .achievement-card__status {
    grid-column: 2;
    width: fit-content;
  }

  .achievement-toast {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
  }

  .daily-modal__content {
    padding: 30px 14px 18px;
  }

  .daily-details {
    gap: 7px;
  }

  .gallery-modal__content {
    max-height: calc(100dvh - 20px);
    padding: 28px 12px 18px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .gallery-card__footer {
    min-height: 46px;
    padding: 7px;
  }

  .statistics-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .current-size-stats__grid {
    gap: 7px;
  }
}

@media (max-width: 760px) {
  .game-layout {
    width: min(100%, 510px);
    grid-template-columns: 1fr;
  }

  .customizer-card {
    display: grid;
    grid-template-columns: minmax(120px, 0.75fr) minmax(150px, 1fr);
    align-items: center;
  }

  .game-layout.is-playing .game-card {
    grid-row: 1;
  }

  .game-layout.is-playing .customizer-card {
    grid-row: 2;
  }

  .game-layout.is-playing .configure-button {
    display: inline-block;
  }

  .game-layout:not(.is-playing) .configure-button {
    display: none;
  }

  .customizer-card > div:first-child,
  .mode-field,
  .field:last-child {
    grid-column: 1 / -1;
  }

  .image-options {
    display: contents;
  }

  .image-options[hidden] {
    display: none;
  }
}

@media (max-width: 420px) {
  .customizer-card {
    display: flex;
  }

  .image-preview {
    width: min(100%, 210px);
    align-self: center;
  }

  .image-options {
    display: flex;
  }

  .mode-option {
    min-height: 54px;
  }
}

@media (max-width: 360px) {
  .stats {
    margin-bottom: 8px;
  }

  .stat {
    padding: 8px 10px;
  }

  .stat__label {
    font-size: 0.72rem;
  }

  .stat__value {
    font-size: 1rem;
  }
}

@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;
  }
}

/* BrainPuz visual system */
:root {
  --bp-bg-page: #F7F6FF;
  --bp-bg-card: #FFFFFF;
  --bp-bg-splash: #26215C;
  --bp-purple-deep: #26215C;
  --bp-purple-mid: #534AB7;
  --bp-purple-soft: #7F77DD;
  --bp-purple-tint: #F7F6FF;
  --bp-border: #DDD9FF;
  --bp-text-primary: #26215C;
  --bp-text-secondary: #8B83C4;
  --bp-text-muted: #C5C0F0;
  --bp-amber: #EF9F27;
  --bp-teal: #1D9E75;
  --bp-white: #FFFFFF;
  --bp-shadow: 0 12px 32px rgba(38, 33, 92, 0.08);
  --color-bg-start: var(--bp-bg-page);
  --color-bg-end: var(--bp-bg-page);
  --color-surface: var(--bp-bg-card);
  --color-primary: var(--bp-purple-mid);
  --color-primary-dark: var(--bp-purple-deep);
  --color-navy: var(--bp-text-primary);
  --color-muted: var(--bp-text-secondary);
  --color-empty: var(--bp-border);
  --color-white: var(--bp-white);
  --radius-lg: 14px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --board-gap: 3px;
  --shadow-card: none;
  --shadow-tile: none;
}

[data-theme="dark"] {
  --bp-bg-page: #0F0D1F;
  --bp-bg-card: #1A1730;
  --bp-bg-splash: #0F0D1F;
  --bp-purple-deep: #EEEDFE;
  --bp-purple-mid: #7F77DD;
  --bp-purple-soft: #534AB7;
  --bp-purple-tint: #1A1730;
  --bp-border: #2E2A50;
  --bp-text-primary: #EEEDFE;
  --bp-text-secondary: #AFA9EC;
  --bp-text-muted: #534AB7;
  --bp-amber: #EF9F27;
  --bp-teal: #1D9E75;
  --bp-white: #1A1730;
  --bp-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
}

html,
body {
  background: var(--bp-bg-page);
  color: var(--bp-text-primary);
  font-family: "Inter", system-ui, sans-serif;
  transition: background 0.2s, color 0.2s;
}

body {
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

button,
select,
input {
  font-family: inherit;
}

button,
strong,
h1,
h2,
h3,
.button,
.stat__value {
  font-weight: 500;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  display: grid;
  height: 52px;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 12px;
  border-bottom: 0.5px solid var(--bp-border);
  background: var(--bp-bg-card);
  transition: background 0.2s, border-color 0.2s;
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  color: var(--bp-text-primary);
  font-size: 17px;
  font-weight: 400;
  text-decoration: none;
}

.brand strong {
  color: var(--bp-amber);
  font-weight: 500;
}

.brand__icon {
  color: var(--bp-purple-mid);
  font-size: 20px;
}

.topbar__slogan {
  display: none;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar__link,
.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--bp-purple-mid);
  cursor: pointer;
}

.topbar__link {
  padding: 0;
  font-size: 20px;
}

.topbar__link span {
  display: none;
}

.topbar__link:hover,
.icon-button:hover {
  background: var(--bp-purple-tint);
}

.topbar__link:focus-visible,
.icon-button:focus-visible,
.mobile-tab:focus-visible,
.size-chips button:focus-visible {
  outline: 2px solid var(--bp-purple-mid);
  outline-offset: 2px;
}

.topbar__nav #statistics-button,
.topbar__nav #daily-challenge-button,
.topbar__gallery {
  display: none;
}

.language-control {
  position: static;
  display: flex;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.language-control label {
  display: none;
}

.language-control select {
  width: 42px;
  min-height: 34px;
  color: var(--bp-text-secondary);
  font-size: 11px;
}

.game-shell {
  display: block;
  min-height: auto;
  padding: 12px 12px 20px;
}

.game-context {
  display: none;
}

.game-layout {
  display: block;
  width: 100%;
}

.game-card,
.customizer-card,
.modal__content,
.statistics-item,
.current-size-stats,
.achievement-card,
.daily-details div,
.gallery-card {
  background-color: var(--bp-bg-card);
  color: var(--bp-text-primary);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.game-card {
  display: flex;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.board-shell {
  order: 1;
  width: 100%;
  padding: 3px;
  border: 0.5px solid var(--bp-border);
  border-radius: 14px;
  background: var(--bp-bg-card);
}

.board {
  gap: 3px;
  padding: 0;
  border-radius: 11px;
  background: var(--bp-border);
  box-shadow: none;
}

.tile,
.tile--empty {
  border-radius: clamp(1px, calc(18px / var(--board-size, 3)), 7px);
}

.tile {
  box-shadow: none;
  transition: opacity 0.15s, transform 0.15s;
}

.tile--empty {
  background: var(--bp-border);
  box-shadow: none;
}

.stats {
  order: 2;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 8px 0 0;
}

.stat {
  position: relative;
  display: grid;
  min-height: 72px;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 3px 8px;
  padding: 10px 12px;
  border: 0.5px solid var(--bp-border);
  border-radius: 10px;
  background: var(--bp-bg-card);
}

.stat--best {
  display: none;
}

.stat__icon {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  color: var(--bp-purple-mid);
  font-size: 17px;
}

.stat--best .stat__icon {
  color: var(--bp-amber);
}

.stat__value {
  grid-column: 1;
  font-size: 22px;
  line-height: 1;
}

.stat__label {
  grid-column: 1;
  color: var(--bp-text-secondary);
  font-size: 11px;
  font-weight: 400;
}

.streak-card {
  order: 3;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 0.5px solid var(--bp-border);
  border-radius: 10px;
  background: var(--bp-bg-card);
}

.streak-card__icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #FFF3D6;
  color: var(--bp-amber);
}

.streak-card strong,
.streak-card span {
  display: block;
}

.streak-card strong {
  font-size: 13px;
}

.streak-card div > span {
  margin-top: 2px;
  color: var(--bp-text-secondary);
  font-size: 11px;
}

.game-status {
  order: 4;
  min-height: 1.2em;
  margin: 10px 0;
  color: var(--bp-text-muted);
  font-size: 11px;
}

.game-actions {
  order: 5;
  display: flex;
  width: 100%;
  gap: 8px;
}

.button {
  min-height: 46px;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
}

.button--primary {
  flex: 1;
  background: var(--bp-purple-mid);
  color: #FFFFFF;
  box-shadow: none;
}

.button--primary:hover {
  background: var(--bp-purple-deep);
  color: #FFFFFF;
  transform: scale(1.01);
  box-shadow: none;
}

.action-icon-button {
  display: inline-grid;
  width: 46px;
  min-width: 46px;
  padding: 0;
  place-items: center;
  border: 0.5px solid var(--bp-border);
  background: var(--bp-bg-card);
  color: var(--bp-purple-mid);
  font-size: 18px;
}

.desktop-restart {
  display: none;
}

.config-overlay {
  position: fixed;
  z-index: 29;
  inset: 0;
  background: rgba(15, 13, 31, 0.48);
}

.config-overlay[hidden] {
  display: none;
}

.customizer-card {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  max-height: min(82dvh, 680px);
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 48px rgba(15, 13, 31, 0.22);
  transform: translateY(105%);
  transition: transform 0.22s ease, background 0.2s;
  visibility: hidden;
}

.customizer-card.is-open {
  transform: translateY(0);
  visibility: visible;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  flex: 0 0 auto;
  align-self: center;
  border-radius: 999px;
  background: var(--bp-border);
}

.customizer-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.customizer-card__header h2 {
  font-size: 18px;
  font-weight: 500;
}

.section-kicker,
.mode-field legend,
.preview-label,
.field > label:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--bp-text-secondary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sheet-close {
  flex: 0 0 auto;
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-option {
  min-height: 46px;
  gap: 7px;
  border: 0.5px solid var(--bp-border);
  border-radius: 10px;
  background: transparent;
  color: var(--bp-text-secondary);
  font-size: 13px;
  font-weight: 400;
}

.mode-option.is-active {
  border-color: var(--bp-purple-mid);
  background: var(--bp-purple-mid);
  color: #FFFFFF;
  box-shadow: none;
}

.mode-option__icon {
  display: none;
}

.image-options {
  gap: 12px;
}

.reference-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-preview {
  width: 56px;
  min-width: 56px;
  border: 0.5px solid var(--bp-border);
  border-radius: 10px;
  box-shadow: none;
}

.reference-info {
  min-width: 0;
}

.reference-info span,
.reference-info strong {
  display: block;
}

.reference-info span {
  color: var(--bp-text-secondary);
  font-size: 11px;
}

.reference-info strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-info .text-button {
  margin-top: 5px;
  color: var(--bp-purple-mid);
  font-size: 12px;
}

.button--secondary {
  min-height: 40px;
  border: 0.5px dashed var(--bp-border);
  background: transparent;
  color: var(--bp-text-secondary);
  font-size: 12px;
  box-shadow: none;
}

.field__hint,
#restore-image-button {
  display: none;
}

.size-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}

.size-chips::-webkit-scrollbar {
  display: none;
}

.size-chips button {
  min-width: 64px;
  min-height: 42px;
  flex: 1 0 auto;
  border: 0.5px solid var(--bp-border);
  border-radius: 8px;
  background: transparent;
  color: var(--bp-text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.size-chips button.is-active {
  border: 1.5px solid var(--bp-purple-mid);
  background: var(--bp-purple-tint);
  color: var(--bp-purple-mid);
}

.mobile-tabbar {
  position: fixed;
  z-index: 14;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 0.5px solid var(--bp-border);
  background: var(--bp-bg-card);
}

.mobile-tab {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--bp-text-muted);
  font-size: 10px;
  cursor: pointer;
}

.mobile-tab i {
  font-size: 20px;
}

.mobile-tab.is-active {
  color: var(--bp-purple-mid);
}

.modal__backdrop {
  background: rgba(15, 13, 31, 0.55);
}

.modal__content {
  border: 0.5px solid var(--bp-border);
  border-radius: 14px;
  box-shadow: var(--bp-shadow);
}

.modal__close {
  background: var(--bp-purple-tint);
  color: var(--bp-text-secondary);
}

.statistics-item,
.modal__results div,
.daily-details div {
  background: var(--bp-purple-tint);
}

.current-size-stats,
.achievement-card--unlocked {
  border-color: var(--bp-border);
  background: var(--bp-purple-tint);
}

.gallery-card,
.achievement-card,
.statistics-table-wrap {
  border-color: var(--bp-border);
}

.statistics-table th {
  background: var(--bp-purple-tint);
  color: var(--bp-text-secondary);
}

@media (hover: hover) and (pointer: fine) {
  .tile:hover {
    opacity: 0.85;
  }

  .tile--empty:hover {
    opacity: 1;
  }
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }

  .topbar {
    height: 56px;
    padding: 0 24px;
  }

  .brand {
    font-size: 19px;
  }

  .topbar__nav #statistics-button,
  .topbar__nav #daily-challenge-button,
  .topbar__gallery {
    display: inline-grid;
  }

  .language-control select {
    width: auto;
  }

  .game-shell {
    padding: 24px;
  }

  .game-context {
    display: flex;
    width: min(100%, 760px);
    justify-content: center;
    gap: 6px;
    margin: 0 auto 14px;
    color: var(--bp-text-secondary);
    font-size: 12px;
  }

  .game-card {
    max-width: 760px;
  }

  .stat--best {
    display: grid;
  }

  .stats {
    order: 1;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 0 10px;
  }

  .board-shell {
    order: 2;
    padding: 14px;
  }

  .streak-card {
    display: none;
  }

  .game-status {
    order: 3;
    margin: 12px 0;
    font-size: 12px;
  }

  .game-actions {
    order: 4;
  }

  .desktop-restart {
    display: inline-grid;
  }

  #configure-button {
    display: inline-grid;
  }

  .mobile-tabbar {
    display: none;
  }
}

@media (min-width: 1024px) {
  .topbar {
    grid-template-columns: 1fr auto 1fr;
    padding: 0 32px;
  }

  .topbar__slogan {
    display: block;
    color: var(--bp-text-secondary);
    font-size: 12px;
    font-style: italic;
    text-align: center;
  }

  .topbar__nav {
    justify-self: end;
    gap: 4px;
  }

  .topbar__link {
    display: inline-flex !important;
    width: auto;
    height: 36px;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    color: var(--bp-text-secondary);
    font-size: 13px;
  }

  .topbar__link i {
    display: none;
  }

  .topbar__link span {
    display: inline;
  }

  .game-shell {
    padding: 24px 32px 36px;
  }

  .game-context {
    display: none;
  }

  .game-layout {
    display: grid;
    width: min(100%, 1180px);
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    gap: 24px;
    margin: 0 auto;
  }

  .customizer-card {
    position: static;
    z-index: auto;
    display: flex;
    max-height: none;
    gap: 20px;
    overflow: visible;
    padding: 20px;
    border: 0.5px solid var(--bp-border);
    border-radius: 14px;
    box-shadow: none;
    transform: none;
    visibility: visible;
  }

  .sheet-handle,
  .sheet-close,
  .customizer-card__header {
    display: none;
  }

  .image-preview {
    width: 100%;
  }

  .reference-row {
    display: block;
  }

  .reference-info {
    display: none;
  }

  .button--secondary {
    width: 100%;
  }

  .size-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    overflow: visible;
  }

  .size-chips button {
    min-width: 0;
  }

  .game-card {
    max-width: none;
  }

  .board-shell {
    padding: 20px;
  }

  #configure-button {
    display: none;
  }

  .config-overlay {
    display: none !important;
  }
}

/* Compact UX adjustments */
:root {
  --bp-bg-page: #eef0f5;
  --bp-bg-card: #ffffff;
  --bp-purple-deep: #4338ca;
  --bp-purple-mid: #4f46e5;
  --bp-purple-soft: #7b8fb5;
  --bp-purple-tint: #f6f7fb;
  --bp-border: #dde2ec;
  --bp-text-primary: #1a2540;
  --bp-text-secondary: #94a3b8;
  --bp-text-muted: #b0bdd0;
  --bp-success: #16a34a;
  --bp-danger: #e24b4a;
  --color-empty: var(--bp-bg-page);
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 7px;
  --board-gap: 3px;
  --number-tile-primary-light: #4F46E5;
  --number-tile-secondary-light: #3730A3;
  --number-tile-primary-dark: #3730A3;
  --number-tile-secondary-dark: #2A228A;
  --number-tile-text: #FFFFFF;
  --number-tile-focus-light: #FFFFFF;
  --number-tile-focus-dark: #C7D2FE;
  /* Next-move hint focus (yellow, no board overlay) */
  --hint-focus-color: #FCD34D;
  --hint-focus-glow: rgba(252, 211, 77, 0.7);
  --hint-focus-width: 2.5px;
  --hint-label-bg: #1A2540;
  --hint-label-text: #FFFFFF;
  --empty-tile-light: #EEF2FF;
  --empty-tile-dark: #111827;
  --empty-dot-light: rgba(55, 48, 163, 0.18);
  --empty-dot-dark: rgba(199, 210, 254, 0.22);
}

[data-theme="dark"] {
  --bp-bg-page: #0d1018;
  --bp-bg-card: #141720;
  --bp-purple-deep: #6366f1;
  --bp-purple-mid: #818cf8;
  --bp-purple-soft: #3d4a60;
  --bp-purple-tint: #10131b;
  --bp-border: #1a1e2a;
  --bp-text-primary: #dde2f0;
  --bp-text-secondary: #3d4a60;
  --bp-text-muted: #3d4a60;
  --color-empty: var(--bp-bg-page);
}

body {
  overflow-x: hidden;
  background: var(--bp-bg-page);
}

.topbar {
  position: sticky;
  display: flex;
  height: 60px;
  justify-content: flex-end;
  padding: 0 14px;
  background: var(--bp-bg-card);
}

.brand {
  position: absolute;
  left: 50%;
  gap: 8px;
  transform: translateX(-50%);
  color: var(--bp-text-primary);
}

.brand__icon {
  font-size: 20px;
}

.brand__copy {
  display: grid;
  justify-items: start;
  line-height: 1.15;
}

.brand__row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.brand__name {
  font-size: 26px;
  font-weight: 500;
  white-space: nowrap;
}

.brand__name strong {
  color: var(--bp-text-primary);
  font-weight: 700;
}

.brand__name span {
  color: var(--bp-purple-mid);
  font-weight: 700;
}

.topbar__slogan {
  display: block;
  margin-top: 2px;
  margin-left: 27px;
  color: var(--bp-purple-mid);
  font-size: 13px;
  font-style: normal;
  font-weight: 500;
  white-space: nowrap;
}

.topbar__subtitle {
  margin-top: 1px;
  color: var(--bp-text-secondary);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.topbar__nav {
  justify-self: end;
  gap: 4px;
}

.topbar__link {
  display: none !important;
}

.language-control select {
  width: 42px;
  min-height: 30px;
  padding: 0 14px 0 4px;
  border: 0;
  background-color: transparent;
  color: var(--bp-text-secondary);
  font-size: 11px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

.game-shell {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 14px 12px 76px;
}

.game-layout {
  min-width: 0;
}

.game-card {
  width: 100%;
  max-width: 560px;
  min-width: 0;
  flex-direction: column;
}

.board-shell {
  width: min(100%, 480px);
  max-width: 480px;
  align-self: center;
  padding: 4px;
  border-color: var(--bp-border);
  border-radius: 9px;
  background: var(--bp-bg-card);
}

.board {
  gap: 3px;
  padding: 0;
  border-radius: 6px;
  background: var(--bp-bg-page);
}

.tile,
.tile--empty {
  border-radius: 3px;
}

.tile {
  transition: opacity 150ms ease;
}

.board--numbers .tile {
  background-image: none;
  box-shadow: 0 10px 18px rgba(26, 37, 64, 0.08);
  color: var(--number-tile-text);
  font-size: var(--tile-font-size, 1.65rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: none;
}

.board--numbers .tile.number-tile-primary {
  background-color: var(--number-tile-primary-light);
}

.board--numbers .tile.number-tile-secondary {
  background-color: var(--number-tile-secondary-light);
}

[data-theme="dark"] .board--numbers .tile {
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .board--numbers .tile.number-tile-primary {
  background-color: var(--number-tile-primary-dark);
}

[data-theme="dark"] .board--numbers .tile.number-tile-secondary {
  background-color: var(--number-tile-secondary-dark);
}

.board--numbers .tile::after {
  display: none;
}

.tile.is-pressing-valid {
  transform: scale(0.93);
  transition: transform 100ms ease-in;
}

.tile.is-pressing-invalid {
  transform: scale(0.96);
  transition: transform 80ms ease-in;
}

.tile.is-releasing-invalid {
  transform: scale(1);
  transition: transform 80ms ease-out;
}

.tile.is-sliding {
  transform: translate(var(--slide-x), var(--slide-y)) scale(1);
  transition: transform 160ms ease-out;
  z-index: 5;
}

.tile.is-settling {
  filter: brightness(1.015);
  transform: none;
  transition: filter 80ms ease;
}

.tile--empty,
.board--dense .tile--empty {
  background-color: var(--empty-tile-light);
  background-image: radial-gradient(circle, var(--empty-dot-light) 1px, transparent 1px);
  background-size: 10px 10px;
  box-shadow: none;
}

.board--numbers .tile:focus-visible {
  outline: 3px solid var(--number-tile-focus-light);
  outline-offset: -3px;
}

[data-theme="dark"] .board--numbers .tile:focus-visible {
  outline-color: var(--number-tile-focus-dark);
}

@media (hover: hover) and (pointer: fine) {
  .board--numbers .tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(26, 37, 64, 0.12);
  }

  [data-theme="dark"] .board--numbers .tile:hover {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.3);
  }
}

.board--numbers .tile.is-pressing-valid {
  box-shadow: 0 8px 14px rgba(26, 37, 64, 0.1);
}

[data-theme="dark"] .board--numbers .tile.is-pressing-valid {
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.26);
}

.stats {
  width: min(100%, 480px);
  max-width: 480px;
  align-self: center;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 58px;
  padding: 8px 12px;
  border-radius: 8px;
}

.stat--best {
  display: none !important;
}

.stat__value {
  font-size: 20px;
  color: var(--bp-text-primary);
  transform-origin: left center;
}

.stat__value.is-bumping {
  animation: stat-bump 200ms ease;
}

.stat__label {
  color: var(--bp-text-muted);
  font-size: 10px;
}

.stat__icon {
  font-size: 15px;
}

@keyframes stat-bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.streak-card {
  display: none;
}

.completion-banner {
  order: 0;
  width: min(100%, 480px);
  margin: 0 auto 8px;
  color: var(--bp-success);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.game-status {
  width: min(100%, 480px);
  min-height: 1.2em;
  align-self: center;
  margin: 9px 0;
  color: var(--bp-text-muted);
  font-size: 11px;
  text-align: center;
}

.game-actions {
  width: min(100%, 480px);
  align-self: center;
}

.button {
  min-height: 40px;
  padding: 11px;
  border-radius: 9px;
  font-size: 13px;
}

.button--primary {
  border: 0;
  background: #4f46e5;
  color: #ffffff;
  transition: background 150ms ease, transform 150ms ease;
}

.button--primary:hover {
  background: #4338ca;
  transform: none;
}

.game-card.is-complete .button--primary {
  background: var(--bp-success);
}

.action-icon-button {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  overflow: hidden;
  padding: 0;
  font-size: 17px;
  text-indent: 0;
  white-space: nowrap;
}

.action-icon-button::before,
.action-icon-button::after {
  display: none !important;
  content: none !important;
}

.restart-confirmation {
  order: 6;
  width: min(100%, 480px);
  align-self: center;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 7px;
  color: var(--bp-text-secondary);
  font-size: 11px;
}

.restart-confirmation:not([hidden]) {
  display: flex;
}

.restart-confirmation button {
  padding: 3px 5px;
  border: 0;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

#restart-confirm-yes {
  color: var(--bp-danger);
}

#restart-confirm-no {
  color: var(--bp-text-secondary);
}

.customizer-card {
  color: var(--bp-text-primary);
}

.customizer-card__header > div {
  display: none;
}

.customizer-card__header {
  min-height: 26px;
  justify-content: flex-end;
}

.section-kicker,
.mode-field legend,
.preview-label,
.field > label:first-child {
  margin-bottom: 6px;
  color: var(--bp-text-muted);
  font-size: 9px;
  letter-spacing: 0.6px;
}

.mode-selector {
  gap: 5px;
}

.mode-option {
  min-height: 34px;
  padding: 5px;
  border-radius: 7px;
  font-size: 11px;
}

.mode-option.is-active {
  border-color: #4f46e5;
  background: #4f46e5;
}

.button--secondary {
  width: 100%;
  min-height: 32px;
  padding: 7px;
  border-color: #c8d4e0;
  border-radius: 7px;
  font-size: 11px;
}

.size-chips {
  flex-wrap: wrap;
  gap: 4px;
  overflow: visible;
  padding: 0;
}

.size-chips button {
  min-width: calc(25% - 3px);
  min-height: 29px;
  flex: 1 0 calc(25% - 3px);
  padding: 5px;
  border-radius: 6px;
  font-size: 11px;
}

.size-chips button.is-active {
  border: 0.5px solid var(--bp-purple-mid);
  background: transparent;
  color: var(--bp-purple-mid);
  font-weight: 500;
}

#max-level-hint,
#file-name {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }

  .topbar {
    height: 64px;
    padding: 0 24px;
  }

  .brand {
    position: absolute;
  }

  .topbar__link {
    display: inline-flex !important;
    width: auto;
    height: 30px;
    gap: 0;
    padding: 0 5px;
    color: #7b8fb5;
    font-size: 12px;
  }

  .topbar__link i {
    display: none;
  }

  .topbar__link span {
    display: inline;
  }

  .game-shell {
    padding: 18px 24px 32px;
  }

  .game-layout {
    display: grid;
    width: 100%;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 14px;
  }

  .customizer-card {
    position: static;
    z-index: auto;
    display: flex;
    max-height: none;
    gap: 15px;
    overflow: visible;
    padding: 14px;
    border: 0.5px solid var(--bp-border);
    border-radius: 10px;
    box-shadow: none;
    transform: none;
    visibility: visible;
  }

  .sheet-handle,
  .sheet-close,
  .customizer-card__header {
    display: none;
  }

  .reference-row {
    display: block;
  }

  .image-preview {
    width: 100%;
    border-radius: 8px;
  }

  .reference-info {
    display: none;
  }

  .size-chips {
    display: flex;
    flex-wrap: wrap;
  }

  .size-chips button {
    min-width: calc(25% - 3px);
    flex-basis: calc(25% - 3px);
  }

  .game-card {
    max-width: 596px;
  }

  .stats {
    order: 1;
    margin: 0 0 8px;
  }

  .board-shell {
    order: 2;
    padding: 4px;
  }

  .game-status {
    order: 3;
  }

  .game-actions {
    order: 4;
  }

  .restart-confirmation {
    order: 5;
  }

  .desktop-restart {
    display: inline-grid;
  }

  #configure-button {
    display: none;
  }

  .mobile-tabbar {
    display: none;
  }
}

@media (max-width: 899px) {
  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  .topbar__nav {
    max-width: 82px;
  }

  .brand__name {
    font-size: 22px;
  }

  .topbar__slogan {
    font-size: 11px;
  }

  .topbar__subtitle {
    max-width: 210px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
  }

  .desktop-restart {
    display: none;
  }

  .game-context {
    display: none;
  }

  .board-shell {
    order: 1;
  }

  .stats {
    order: 2;
    margin: 8px 0 0;
  }

  .game-status {
    order: 3;
  }

  .game-actions {
    order: 4;
  }

  .restart-confirmation {
    order: 5;
  }

  .mobile-tabbar {
    display: flex;
  }
}

@media (min-width: 900px) and (max-width: 1099px) {
  .topbar__link {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .topbar {
    height: 58px;
    padding: 0 8px;
  }

  .brand {
    left: 42%;
  }

  .brand__name {
    font-size: 20px;
  }

  .topbar__subtitle {
    max-width: 175px;
  }

  .game-shell {
    padding-inline: 8px;
  }
}

/* Final interaction layer */
[data-theme="dark"] .tile--empty,
[data-theme="dark"] .board--dense .tile--empty {
  background-color: var(--empty-tile-dark);
  background-image: radial-gradient(circle, var(--empty-dot-dark) 1px, transparent 1px);
  background-size: 10px 10px;
}

.help-button {
  border: 0.5px solid var(--bp-border);
  font-size: 18px;
}

.image-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gallery-outline-button,
.image-action-grid .button--secondary {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.gallery-outline-button span,
.image-action-grid .button--secondary span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.own-image-mobile-label {
  display: inline;
}

.own-image-desktop-label {
  display: none;
}

.gallery-outline-button {
  border: 0.5px solid var(--bp-purple-mid);
  color: var(--bp-purple-mid);
}

.image-action-grid .button--secondary {
  border: 0.5px solid var(--bp-border);
  color: var(--bp-text-secondary);
}

.config-done-button {
  width: 100%;
  min-height: 56px;
  margin-top: 6px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
}

.btn-config {
  order: 5;
  display: inline-flex;
  width: min(100%, 480px);
  height: 44px;
  align-items: center;
  justify-content: center;
  align-self: center;
  gap: 7px;
  margin-top: 8px;
  border: 1px solid var(--bp-purple-mid);
  border-radius: 9px;
  background: transparent;
  color: var(--bp-purple-mid);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.modal__content,
.customizer-card {
  position: relative;
}

.modal__close,
.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0.5px solid var(--bp-border);
  border-radius: 50%;
  background: var(--bp-purple-tint);
  color: var(--bp-text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, transform 100ms ease, color 120ms ease;
}

.modal__close > *,
.sheet-close > * {
  pointer-events: none;
}

.modal__close:hover,
.sheet-close:hover {
  background: color-mix(in srgb, var(--bp-purple-tint) 82%, var(--bp-border));
  color: var(--bp-text-primary);
}

.modal__close:active,
.sheet-close:active {
  transform: scale(0.93);
}

.statistics-modal__content,
.achievements-modal__content,
.daily-modal__content,
.gallery-modal__content {
  padding-top: 68px;
  padding-bottom: 50px;
}

@media (min-width: 600px) {
  .statistics-modal__content,
  .achievements-modal__content,
  .daily-modal__content,
  .gallery-modal__content {
    padding-top: 68px;
    padding-bottom: 50px;
  }
}

.customizer-card__header {
  min-height: 48px;
}

.board-shell {
  position: relative;
  overflow: hidden;
}

.victory-overlay {
  position: absolute;
  z-index: 8;
  inset: 4px;
  display: grid;
  overflow: hidden;
  place-items: center;
  border-radius: 6px;
  background: #16a34a;
  color: #ffffff;
  animation: victory-in 300ms ease-out both;
}

.victory-overlay[hidden] {
  display: none;
}

.victory-overlay__content {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(92%, 420px);
  align-items: center;
  flex-direction: column;
  text-align: center;
}

.victory-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.victory-badge,
.victory-record {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.victory-badge--daily {
  background: #dbeafe;
  color: #1d4ed8;
}

#victory-title {
  font-size: 28px;
  font-weight: 700;
}

#victory-summary {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

#victory-size,
#victory-hints {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.victory-record {
  background: #fde047;
  color: #713f12;
}

.victory-detail-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.victory-detail {
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  text-align: left;
}

.victory-detail span,
.victory-detail strong {
  display: block;
}

.victory-detail span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 11px;
}

.victory-detail strong {
  margin-top: 4px;
  color: #ffffff;
  font-size: 16px;
}

.victory-actions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.victory-actions button {
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#victory-play-again {
  background: #ffffff;
  color: #15803d;
}

#victory-level-up {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

#victory-share-button,
#victory-download-button,
#victory-statistics-button,
#victory-achievements-button,
#victory-gallery-button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 23, 42, 0.16);
  color: #ffffff;
}

.victory-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -10%;
  width: 7px;
  height: 12px;
  background: var(--confetti-color);
  animation: confetti-fall var(--confetti-duration) linear infinite;
  animation-delay: var(--confetti-delay);
}

@keyframes victory-in {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes confetti-fall {
  from { transform: translate3d(0, -20px, 0) rotate(0deg); }
  to { transform: translate3d(var(--confetti-drift), 115vh, 0) rotate(720deg); }
}

.tutorial-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(13, 16, 24, 0.64);
}

.tutorial-overlay[hidden] {
  display: none;
}

.tutorial-card {
  position: fixed;
  z-index: 84;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  width: calc(100% - 32px);
  max-width: 390px;
  padding: 66px 18px 18px;
  border-radius: 12px;
  background: var(--bp-bg-card);
  color: var(--bp-text-primary);
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

.tutorial-step-label {
  color: var(--bp-purple-mid);
  font-size: 11px;
  font-weight: 700;
}

#tutorial-text {
  margin: 8px 0 14px;
  font-size: 15px;
  font-weight: 500;
}

body.tutorial-open .board-shell {
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.45);
  pointer-events: none;
}

.tutorial-highlight {
  position: fixed;
  z-index: 83;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  text-shadow: inherit;
  transform: translate(0, 0);
}

.tutorial-highlight[hidden] {
  display: none;
}

.tutorial-highlight.is-pulsing {
  filter: brightness(1.28) saturate(1.15);
  animation: tutorial-highlight-pulse 900ms ease-in-out infinite;
}

.tutorial-highlight.is-sliding {
  filter: brightness(1.25) saturate(1.15);
  animation: tutorial-highlight-slide 400ms ease-in-out infinite alternate;
}

.tile.tutorial-pulse {
  z-index: 4;
  animation: tutorial-pulse 900ms ease-in-out infinite;
}

.tile.tutorial-slide {
  z-index: 4;
  animation: tutorial-slide 400ms ease-in-out infinite alternate;
}

.tile.tutorial-order,
.tile--empty.tutorial-order {
  z-index: 3;
  transform: translate(var(--tutorial-order-x), var(--tutorial-order-y));
  transition: transform 400ms ease-in-out;
}

@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.75); }
  50% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); }
}

@keyframes tutorial-slide {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--tutorial-x), var(--tutorial-y)); }
}

@keyframes tutorial-highlight-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 3px #ffffff,
      0 0 0 7px rgba(79, 70, 229, 0.95),
      0 0 26px 12px rgba(129, 140, 248, 0.65);
  }
  50% {
    box-shadow:
      0 0 0 3px #ffffff,
      0 0 0 11px rgba(79, 70, 229, 0.45),
      0 0 38px 18px rgba(129, 140, 248, 0.9);
  }
}

@keyframes tutorial-highlight-slide {
  from {
    transform: translate(0, 0);
    box-shadow: 0 0 0 3px #ffffff, 0 0 28px 12px rgba(129, 140, 248, 0.75);
  }
  to {
    transform: translate(var(--tutorial-x), var(--tutorial-y));
    box-shadow: 0 0 0 3px #ffffff, 0 0 38px 16px rgba(129, 140, 248, 0.95);
  }
}

@media (min-width: 900px) {
  .btn-config,
  .config-done-button {
    display: none;
  }

  .sheet-close {
    display: none;
  }

  .own-image-mobile-label {
    display: none !important;
  }

  .own-image-desktop-label {
    display: inline !important;
  }
}

@media (max-width: 899px) {
  #configure-button {
    display: none;
  }

  .customizer-card {
    position: fixed;
    z-index: 30;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(82dvh, 680px);
    margin: 0;
    overflow-y: auto;
    padding-top: 14px;
    transform: translateY(105%);
    visibility: hidden;
  }

  .customizer-card.is-open {
    transform: translateY(0);
    visibility: visible;
  }

  .tutorial-card {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .own-image-desktop-label {
    display: none !important;
  }

  .own-image-mobile-label {
    display: inline !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .victory-overlay,
  .confetti-piece,
  .tile.tutorial-pulse,
  .tile.tutorial-slide,
  .tutorial-highlight {
    animation: none;
  }
}

/* Step 7: limited hints and future rewarded-ad entry point. */
.hint-controls {
  order: 6;
  width: min(100%, 480px);
  align-self: center;
  margin-top: 8px;
}

.hint-card {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border: 0.5px solid #dde2ec;
  border-radius: 12px;
  background: #ffffff;
  color: var(--bp-text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 100ms ease, box-shadow 120ms ease;
}

.hint-card:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--bp-purple-mid) 26%, #dde2ec);
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.08);
}

.hint-card:active:not(:disabled) {
  transform: scale(0.98);
}

.hint-card:disabled {
  color: var(--bp-text-muted);
  cursor: not-allowed;
  opacity: 1;
}

.hint-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--bp-purple-mid) 35%, transparent);
  outline-offset: 2px;
}

.hint-card__main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.hint-card__icon {
  display: inline-flex;
  width: 24px;
  min-width: 24px;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
  font-size: 18px;
}

.hint-card__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.hint-card__title {
  overflow: hidden;
  color: #4f46e5;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint-card__subtitle {
  overflow: hidden;
  color: #94a3b8;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint-card__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.hint-card__meta-label {
  color: #94a3b8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hint-dot {
  display: inline-flex;
  width: 12px;
  height: 12px;
  align-items: center;
  justify-content: center;
  color: #dde2ec;
  font-size: 10px;
  line-height: 1;
}

.hint-dot--available {
  color: #4f46e5;
}

.hint-dot--used {
  color: #dde2ec;
}

[data-theme="dark"] .hint-card {
  border-color: rgba(148, 163, 184, 0.18);
  background: #111827;
}

[data-theme="dark"] .hint-card__subtitle,
[data-theme="dark"] .hint-card__meta-label {
  color: #94a3b8;
}

[data-theme="dark"] .hint-dot--used {
  color: #475569;
}

[data-theme="dark"] .hint-card:disabled {
  background: #111827;
}

/* Hint label: a compact capsule ABOVE the board, never floating over tiles. */
.hint-label {
  display: flex;
  justify-content: center;
  margin: 0 auto 8px;
  pointer-events: none;
}

.hint-label[hidden] {
  display: none;
}

.hint-label__inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--hint-label-bg);
  color: var(--hint-label-text);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.28);
  animation: hint-message-in 200ms ease both;
}

.hint-label__bulb {
  flex-shrink: 0;
  color: var(--hint-focus-color);
  font-size: 14px;
}

.hint-label__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.hint-label__text strong {
  font-size: 11px;
  font-weight: 600;
}

.hint-label__text small {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

.hint-label__arrow {
  flex-shrink: 0;
  margin-left: 2px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
}

/* Recommended tile: yellow border + glow + subtle pulse. No dark overlay,
   no white glow, no tooltip over tiles. Works for numbers and images. */
.tile.suggested-move {
  position: relative;
  z-index: 4;
  outline: var(--hint-focus-width) solid var(--hint-focus-color);
  outline-offset: calc(-1 * var(--hint-focus-width));
  box-shadow:
    0 0 0 1px rgba(252, 211, 77, 0.35),
    0 0 10px var(--hint-focus-glow);
  animation: hint-pulse 1.5s ease-in-out infinite;
}

/* Keep numbers/images styling identical; only the yellow focus is layered on. */
.board--numbers .tile.suggested-move,
[data-theme="dark"] .board--numbers .tile.suggested-move {
  outline: var(--hint-focus-width) solid var(--hint-focus-color);
  outline-offset: calc(-1 * var(--hint-focus-width));
}

/* On large dense boards a thinner border reads better. */
.board--dense .tile.suggested-move {
  --hint-focus-width: 2px;
}

@keyframes hint-message-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hint-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(252, 211, 77, 0.35),
      0 0 6px rgba(252, 211, 77, 0.5);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(252, 211, 77, 0.45),
      0 0 16px rgba(252, 211, 77, 0.9);
  }
}

@media (min-width: 900px) {
  .hint-controls {
    width: calc(100% - 62px);
    margin-right: auto;
  }

  .victory-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 899px) {
  .hint-controls {
    order: 6;
  }

  .customizer-card {
    max-height: min(84dvh, 760px);
    padding: 18px 28px calc(28px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
  }

  .customizer-card__header {
    min-height: 56px;
    margin-bottom: 4px;
  }

  .mode-selector {
    gap: 14px;
  }

  .mode-option {
    min-height: 56px;
    padding: 14px 12px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
  }

  .reference-block {
    gap: 14px;
  }

  .reference-row {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 16px;
    border: 0.5px solid #eef2ff;
    border-radius: 20px;
    background: #f8faff;
  }

  .image-preview {
    width: 124px;
    min-width: 124px;
    height: 124px;
    border-radius: 20px;
  }

  .reference-info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
  }

  .reference-info strong {
    font-size: 18px;
    line-height: 1.15;
  }

  .reference-info span,
  .reference-info button {
    font-size: 14px;
  }

  .size-chips {
    gap: 12px;
  }

  .size-chips button {
    min-width: calc(25% - 9px);
    min-height: 52px;
    flex: 1 0 calc(25% - 9px);
    padding: 12px 8px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
  }

  .gallery-outline-button,
  .image-action-grid .button--secondary {
    min-height: 56px;
    gap: 8px;
    padding: 14px 12px;
    border-radius: 14px;
    font-size: 14px;
  }

  .image-action-grid .button--secondary {
    justify-content: center;
  }

  .image-action-grid .button--secondary i,
  .gallery-outline-button i {
    flex-shrink: 0;
    font-size: 18px;
  }

  .config-done-button {
    min-height: 64px;
    margin-top: 10px;
    border-radius: 20px;
    font-size: 17px;
  }

  .btn-config {
    order: 7;
  }

  .restart-confirmation {
    order: 8;
  }

  .victory-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .hint-card {
    padding: 10px 12px;
  }

  .hint-card__main {
    gap: 8px;
  }

  .hint-dots {
    gap: 5px;
  }

  .reference-row {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 12px;
  }

  .image-preview {
    width: 108px;
    min-width: 108px;
    height: 108px;
  }

  .gallery-outline-button,
  .image-action-grid .button--secondary {
    font-size: 13px;
  }

  .image-action-grid .button--secondary {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint-label,
  .hint-label__inner,
  .tile.suggested-move {
    animation: none;
  }
}

/* Compact victory card */
.victory-overlay {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: inherit;
  background: linear-gradient(160deg, #16a34a 0%, #15803d 60%, #14532d 100%);
  color: #ffffff;
  scrollbar-width: thin;
}

.victory-card {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.victory-celebration {
  display: flex;
  flex: 1;
  align-items: center;
  flex-direction: column;
  padding: 24px 20px 20px;
  text-align: center;
}

.victory-record-badge {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
}

.victory-record-badge[hidden],
.victory-daily-badge[hidden] {
  display: none;
}

.victory-avatar-wrap {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.victory-avatar {
  display: grid;
  width: 56px;
  height: 56px;
  overflow: hidden;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 28px;
}

.victory-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.victory-avatar-button {
  min-height: 24px;
  margin: 3px auto 5px;
  padding: 3px 7px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
  cursor: pointer;
}

.victory-avatar-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

#victory-title {
  margin-bottom: 8px;
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
}

.victory-summary {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.victory-daily-badge {
  margin: -4px 0 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.88);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.victory-stats {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.victory-stat {
  min-width: 0;
  padding: 12px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  text-align: center;
}

.victory-stat strong,
.victory-stat span {
  display: block;
}

.victory-stat strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.victory-stat span {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.victory-celebration .victory-actions {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 16px;
}

.victory-celebration .victory-actions button {
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border-radius: 12px;
}

#victory-play-again {
  border: 0;
  background: #ffffff;
  color: #15803d;
  font-size: 14px;
  font-weight: 700;
}

#victory-level-up {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
}

.victory-share-zone {
  padding: 10px 20px 16px;
  background: #14532d;
}

.victory-share-label {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.victory-social-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.victory-social {
  display: flex;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  transition: filter 120ms ease, transform 100ms ease;
}

.victory-social:hover {
  filter: brightness(1.08);
}

.victory-social:active {
  transform: scale(0.93);
}

.victory-social--whatsapp {
  background: #25d366;
}

.victory-social--instagram {
  background: linear-gradient(135deg, #833ab4, #e1306c, #fcaf45);
}

.victory-social--facebook {
  background: #1877f2;
}

.victory-social--copy {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
}

.victory-confetti {
  z-index: 0;
  opacity: 0.6;
}

.game-card.is-complete > .stats,
.game-card.is-complete > .streak-card,
.game-card.is-complete > .game-status,
.game-card.is-complete > .game-actions,
.game-card.is-complete > .hint-controls,
.game-card.is-complete > .btn-config,
.game-card.is-complete > .restart-confirmation {
  display: none;
}

@media (min-width: 900px) {
  .hint-controls {
    width: min(100%, 480px);
    margin-right: 0;
  }

  .hint-card {
    width: calc(100% - 96px);
    margin-right: auto;
  }
}

@media (max-width: 899px) {
  .customizer-card {
    max-height: calc(100dvh - 24px);
    gap: 9px;
    padding: 10px 24px calc(16px + env(safe-area-inset-bottom));
  }

  .customizer-card__header {
    display: contents;
    min-height: 0;
    height: 0;
    margin: 0;
  }

  .sheet-handle {
    margin-bottom: 2px;
  }

  .mode-field legend,
  .preview-label,
  .field > label:first-child {
    margin-bottom: 5px;
  }

  .mode-selector {
    gap: 10px;
  }

  .mode-option {
    min-height: 48px;
    padding: 11px 10px;
    border-radius: 12px;
  }

  .image-options,
  .reference-block {
    gap: 8px;
  }

  .reference-row {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
    padding: 10px;
    border-radius: 16px;
  }

  .image-preview {
    width: 96px;
    min-width: 96px;
    height: 96px;
    border-radius: 16px;
  }

  .reference-info {
    gap: 3px;
  }

  .reference-info strong {
    font-size: 16px;
  }

  .reference-info span,
  .reference-info button {
    font-size: 13px;
  }

  .image-action-grid {
    gap: 8px;
  }

  .gallery-outline-button,
  .image-action-grid .button--secondary {
    min-height: 48px;
    padding: 10px 8px;
    border-radius: 12px;
    font-size: 13px;
  }

  .size-chips {
    gap: 8px;
  }

  .size-chips button {
    min-width: calc(25% - 6px);
    min-height: 44px;
    flex-basis: calc(25% - 6px);
    padding: 8px 5px;
    border-radius: 11px;
    font-size: 13px;
  }

  .config-done-button {
    min-height: 54px;
    margin-top: 2px;
    border-radius: 16px;
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  .victory-celebration {
    padding: 14px 14px 12px;
  }

  .victory-record-badge {
    margin-bottom: 8px;
  }

  .victory-avatar {
    width: 48px;
    height: 48px;
    font-size: 23px;
  }

  .victory-avatar-button {
    margin-bottom: 2px;
  }

  #victory-title {
    margin-bottom: 5px;
    font-size: 25px;
  }

  .victory-summary {
    margin-bottom: 9px;
  }

  .victory-stat {
    padding: 8px 5px;
  }

  .victory-stat strong {
    font-size: 16px;
  }

  .victory-celebration .victory-actions {
    margin-top: 10px;
  }

  .victory-celebration .victory-actions button {
    min-height: 40px;
    padding: 9px;
  }

  .victory-share-zone {
    padding: 8px 14px 10px;
  }

  .customizer-card {
    padding-inline: 18px;
  }
}

/* Step 9: app home and responsive victory sizing */
[hidden] {
  display: none !important;
}

.home-screen {
  width: min(100%, 920px);
  min-height: calc(100dvh - 64px);
  margin: 0 auto;
  padding: 28px 20px 92px;
  color: var(--bp-text-primary);
}

.home-hero {
  display: flex;
  align-items: center;
  flex-direction: column;
  margin-bottom: 22px;
  text-align: center;
}

.home-brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: 15px;
  background: var(--bp-purple-tint);
  color: var(--bp-purple-mid);
  font-size: 26px;
}

.home-hero h1 {
  color: var(--bp-text-primary);
  font-size: clamp(30px, 7vw, 42px);
  letter-spacing: -0.04em;
  line-height: 1;
}

.home-hero h1 strong {
  font-weight: 700;
}

.home-hero h1 span {
  color: #4f46e5;
  font-weight: 700;
}

#home-subtitle {
  margin-top: 7px;
  color: var(--bp-purple-mid);
  font-size: 14px;
  font-weight: 500;
}

#home-tagline {
  max-width: 360px;
  margin-top: 7px;
  color: var(--bp-text-secondary);
  font-size: 12px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
  gap: 14px;
}

.home-card,
.home-quick-actions {
  border: 0.5px solid var(--bp-border);
  border-radius: 18px;
  background: var(--bp-bg-card);
  box-shadow: 0 14px 34px rgba(26, 37, 64, 0.07);
}

.home-card {
  padding: 18px;
}

.home-play-card {
  grid-row: span 2;
}

.home-preview-wrap {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.home-preview {
  position: relative;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border-radius: 18px;
  background-image: var(--home-preview-image);
  background-position: center;
  background-size: cover;
}

.home-number-preview {
  display: none;
  height: 100%;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 5px;
  background: #eef2ff;
}

.home-number-preview span {
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.home-number-preview span:last-child {
  background-color: var(--empty-tile-light);
  background-image: radial-gradient(circle, var(--empty-dot-light) 1px, transparent 1px);
  background-size: 8px 8px;
}

.home-preview--numbers {
  background-image: none;
}

.home-preview--numbers .home-number-preview {
  display: grid;
}

.home-preview-wrap > div:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.home-card-kicker,
#home-difficulty-label {
  color: var(--bp-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

#home-current-name {
  margin-top: 5px;
  overflow: hidden;
  color: var(--bp-text-primary);
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#home-mode-label,
#home-daily-size {
  margin-top: 4px;
  color: var(--bp-text-secondary);
  font-size: 12px;
}

.home-difficulty {
  margin-top: 18px;
}

.home-size-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.home-size-selector button {
  min-height: 42px;
  border: 0.5px solid var(--bp-border);
  border-radius: 10px;
  background: transparent;
  color: var(--bp-text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.home-size-selector button.is-active {
  border: 1.5px solid #4f46e5;
  color: #4f46e5;
  background: var(--bp-purple-tint);
}

.home-primary-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  border: 0;
  border-radius: 14px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.home-daily-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.home-daily-card > div {
  display: flex;
  flex-direction: column;
}

#home-daily-status {
  margin-top: 5px;
  color: #d97706;
  font-size: 18px;
}

#home-daily-status.is-completed {
  color: #16a34a;
}

.home-daily-card button {
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--bp-purple-tint);
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.home-progress-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.home-progress-grid div {
  min-width: 0;
  padding: 10px 7px;
  border-radius: 12px;
  background: var(--bp-bg-page);
  text-align: center;
}

.home-progress-grid strong,
.home-progress-grid span {
  display: block;
}

.home-progress-grid strong {
  color: var(--bp-text-primary);
  font-size: 19px;
}

.home-progress-grid span {
  margin-top: 3px;
  color: var(--bp-text-muted);
  font-size: 9px;
}

.home-quick-actions {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}

.home-quick-actions button,
.home-language-action {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-right: 0.5px solid var(--bp-border);
  background: transparent;
  color: var(--bp-text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.home-quick-actions > :last-child {
  border-right: 0;
}

.home-quick-actions i {
  color: #4f46e5;
  font-size: 18px;
}

.home-language-action {
  position: relative;
  cursor: default;
}

.home-language-action select {
  min-height: 28px;
  padding: 2px 4px;
  border: 0;
  border-radius: 6px;
  background: var(--bp-bg-page);
  color: var(--bp-text-secondary);
  font-size: 10px;
  cursor: pointer;
}

.home-primary-button:focus-visible,
.home-size-selector button:focus-visible,
.home-daily-card button:focus-visible,
.home-quick-actions button:focus-visible,
.home-language-action select:focus-visible {
  outline: 3px solid color-mix(in srgb, #4f46e5 35%, transparent);
  outline-offset: 2px;
}

[data-theme="dark"] .home-number-preview {
  background: #0d1018;
}

[data-theme="dark"] .home-number-preview span:last-child {
  background-color: var(--empty-tile-dark);
  background-image: radial-gradient(circle, var(--empty-dot-dark) 1px, transparent 1px);
}

.game-card.is-complete .board {
  display: none;
}

.game-card.is-complete .board-shell {
  width: min(100%, 480px);
  min-height: 620px;
  overflow: visible;
  padding: 4px;
  aspect-ratio: auto;
}

.game-card.is-complete .victory-overlay {
  position: relative;
  inset: auto;
  width: 100%;
  min-height: 612px;
  max-height: none;
  overflow-y: visible;
}

@media (max-width: 899px) {
  .home-screen {
    min-height: calc(100dvh - 58px);
    padding: 20px 14px calc(76px + env(safe-area-inset-bottom));
  }

  .home-hero {
    margin-bottom: 16px;
  }

  .home-brand-mark {
    width: 42px;
    height: 42px;
    font-size: 23px;
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .home-play-card {
    grid-row: auto;
  }

  .home-card {
    padding: 14px;
    border-radius: 16px;
  }

  .home-preview-wrap {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 13px;
  }

  .home-preview {
    width: 92px;
    height: 92px;
    border-radius: 15px;
  }

  .home-quick-actions {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-radius: 16px;
  }

  .home-quick-actions button,
  .home-language-action {
    min-height: 62px;
    flex-direction: column;
    gap: 4px;
    font-size: 9px;
  }

  .game-card.is-complete .board-shell {
    min-height: 0;
    max-height: calc(100dvh - 132px - env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .game-card.is-complete .victory-overlay {
    min-height: 0;
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .home-hero h1 {
    font-size: 30px;
  }

  #home-tagline {
    font-size: 11px;
  }

  .home-daily-card {
    align-items: stretch;
    flex-direction: column;
  }

  .home-daily-card button {
    width: 100%;
  }
}

/* Post-win deferred sign-in banner (non-blocking, optional). No real auth. */
.save-record-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.22);
  text-align: center;
  animation: hint-message-in 220ms ease both;
}

.save-record-banner[hidden] {
  display: none;
}

.save-record-banner__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: inherit;
}

.save-record-banner__subtitle {
  margin: 4px 0 10px;
  font-size: 12px;
  opacity: 0.75;
}

.save-record-banner__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.save-record-banner__primary,
.save-record-banner__ghost {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.save-record-banner__primary {
  background: #4F46E5;
  color: #fff;
}

.save-record-banner__primary:hover {
  background: #4338CA;
}

.save-record-banner__ghost {
  background: transparent;
  color: inherit;
  border-color: rgba(120, 120, 140, 0.4);
}

.save-record-banner__ghost:hover {
  border-color: rgba(120, 120, 140, 0.7);
}

.save-online-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

/* Minimal welcome screen (first open only). */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 32px 24px 110px;
}

.welcome-screen[hidden] {
  display: none;
}

.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  text-align: center;
  animation: hint-message-in 260ms ease both;
}

.welcome-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 6px;
  border-radius: 22px;
  background: rgba(79, 70, 229, 0.12);
  color: #4F46E5;
  font-size: 36px;
}

.welcome-title {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
}

.welcome-title strong {
  font-weight: 800;
}

.welcome-title span {
  color: #4F46E5;
}

.welcome-subtitle {
  margin: 0;
  color: #4F46E5;
  font-size: 16px;
  font-weight: 600;
}

.welcome-tagline {
  margin: 0 0 16px;
  font-size: 14px;
  opacity: 0.7;
}

.welcome-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  padding: 16px 24px;
  border: none;
  border-radius: 16px;
  background: #4F46E5;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.32);
}

.welcome-play:hover {
  background: #4338CA;
}

[data-theme="dark"] .welcome-mark {
  background: rgba(129, 140, 248, 0.16);
  color: #a5b4fc;
}

[data-theme="dark"] .welcome-title span,
[data-theme="dark"] .welcome-subtitle {
  color: #a5b4fc;
}

/* Login view (deferred sign-in). Buttons present, no real OAuth yet. */
.login-modal__content {
  max-width: 380px;
  text-align: center;
}

.login-providers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.login-provider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid rgba(120, 120, 140, 0.28);
  border-radius: 12px;
  background: #fff;
  color: #1f2937;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.login-provider:hover {
  border-color: rgba(120, 120, 140, 0.5);
  background: #f8fafc;
}

.login-provider__badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  font-size: 18px;
}

.login-provider__badge--google {
  border-radius: 50%;
  background: conic-gradient(from -45deg, #ea4335, #fbbc05, #34a853, #4285f4, #ea4335);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.login-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: rgba(120, 120, 140, 0.85);
  font-size: 13px;
}

.login-separator::before,
.login-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(120, 120, 140, 0.25);
}

.login-guest {
  width: 100%;
}

.login-soon-note {
  margin: 14px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(252, 211, 77, 0.16);
  color: #b45309;
  font-size: 12px;
}

.login-soon-note[hidden] {
  display: none;
}

[data-theme="dark"] .login-provider {
  background: #1e293b;
  color: #e5e7eb;
  border-color: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .login-provider:hover {
  background: #273449;
}

[data-theme="dark"] .login-soon-note {
  background: rgba(252, 211, 77, 0.12);
  color: #fde68a;
}
