* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button, .palette-color, .guess-slot, .level-btn, .lang-toggle {
  touch-action: manipulation;
}

:root {
  --accent: #F4A261;
  --accent-dark: #E07A3A;
  --accent-light: #FDDCBC;
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: #e5e5e5;
  --slot-empty: #f5f5f5;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
  overflow: hidden;
  overflow-x: clip;
}

/* Game UI: scrollbars are pure noise and their width shifts layout between
   screens that scroll and screens that don't — hide them everywhere, content
   still scrolls (touch/wheel/keys). */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ---- SCREENS ---- */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  padding: env(safe-area-inset-top, 16px) 20px env(safe-area-inset-bottom, 16px);
}
.screen.active { display: flex; }

/* ---- HOME SCREEN ---- */
#home-screen {
  position: relative;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.home-top-actions {
  position: absolute;
  top: calc(env(safe-area-inset-top, 16px) + 10px);
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.home-secondary-btn {
  width: 100%;
}

.lang-toggle {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  transition: border-color 0.15s, color 0.15s;
}
.home-auth-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-auth-btn.signed {
  color: var(--accent-dark);
  border-color: var(--accent-light);
  background: #fff7f1;
}
.lang-toggle:active {
  border-color: var(--accent);
  color: var(--accent);
}

.app-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}
.app-title span { color: var(--accent); }

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.home-score {
  font-size: 0.86rem;
  color: var(--accent-dark);
  font-weight: 800;
  margin-bottom: 20px;
}

.home-streak {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-dark);
  margin-top: -12px;
  margin-bottom: 18px;
}

.color-preview {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
}
.color-preview .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 16px 48px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(244,162,97,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.3px;
}
.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(244,162,97,0.3);
}

/* ---- LEVEL SELECT ---- */
#level-screen { gap: 0; }

#leaderboard-screen {
  gap: 0;
}

.leaderboard-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 12px;
}

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
  padding: 0 1px 18px;
}

.ach-screen-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
  margin-bottom: 8px;
}
.ach-screen-header h2 {
  min-width: 0;
  text-align: center;
  font-size: clamp(1.05rem, 6vw, 1.3rem);
  white-space: nowrap;
}
.ach-header-count {
  min-width: 0;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.ach-spectrum {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  flex: none;
  height: 5px;
  margin: 0 2px 18px;
  overflow: hidden;
  border-radius: 999px;
}
.ach-spectrum i:nth-child(1) { background: #F07070; }
.ach-spectrum i:nth-child(2) { background: #F4A261; }
.ach-spectrum i:nth-child(3) { background: #F7CE5B; }
.ach-spectrum i:nth-child(4) { background: #6CC87A; }
.ach-spectrum i:nth-child(5) { background: #6AA4F5; }
.ach-spectrum i:nth-child(6) { background: #B48AE8; }

.ach-road-section { --cat: var(--accent); }
.ach-road-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 9px;
}
.ach-road-head h3 { font-size: 0.96rem; font-weight: 800; color: var(--text); }
.ach-road-head > span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ach-campaign-road {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--cat) 32%, #fff);
  border-radius: 24px;
  background: color-mix(in srgb, var(--cat) 10%, #fff);
}
.ach-campaign-line {
  position: absolute;
  left: 38px;
  top: 35px;
  bottom: 35px;
  width: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat) 22%, #fff);
}
.ach-campaign-line > span {
  display: block;
  width: 100%;
  border-radius: inherit;
  background: var(--cat);
}
.ach-route-node {
  position: relative;
  z-index: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform .1s;
}
.ach-route-node:active { transform: scale(.97); }
.ach-route-node.is-campaign {
  display: grid;
  grid-template-columns: 56px minmax(0,1fr) auto;
  align-items: center;
  min-height: 68px;
  padding: 7px 3px;
  text-align: left;
}
.ach-route-node.is-campaign:not(:last-child) {
  border-bottom: 1px solid color-mix(in srgb, var(--cat) 14%, transparent);
}
.ach-route-token {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0;
  border: 3px solid #ebe7e3;
  border-radius: 16px;
  background: #fff;
  color: var(--text-muted);
  box-shadow: 0 4px 0 #dcd7d2;
}
.ach-route-icon { display: grid; place-items: center; font-size: 1.35rem; line-height: 1; }
.ach-route-icon svg { width: 26px; height: 26px; display: block; }
.ach-route-node.is-earned .ach-route-token {
  border-color: var(--cat);
  background: var(--cat);
  color: #fff;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--cat) 72%, #000);
}
.ach-route-node.is-current .ach-route-token {
  border-color: var(--cat);
  color: color-mix(in srgb, var(--cat) 72%, #000);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--cat) 18%, transparent), 0 4px 0 color-mix(in srgb, var(--cat) 30%, #ddd);
  animation: ach-current-lift 2.2s ease-in-out infinite;
}
.ach-route-node.is-locked { opacity: .46; filter: grayscale(.85); }
.ach-route-name { font-size: .82rem; font-weight: 800; }
.ach-route-metric {
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ach-earned-check {
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #211d26;
  color: #fff;
}
.ach-earned-check svg { width: 13px; height: 13px; display: block; }

.ach-tier-ribbon {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 16px 12px 13px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--cat) 34%, #fff);
  border-radius: 22px;
  background: color-mix(in srgb, var(--cat) 10%, #fff);
}
.ach-tier-ribbon::after {
  content: '';
  position: absolute;
  left: calc(16.66% + 24px);
  right: calc(16.66% + 24px);
  top: 40px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat) 24%, #fff);
}
.ach-tier-ribbon .ach-route-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
}
.ach-tier-ribbon .ach-route-token { z-index: 1; margin-bottom: 5px; }
.ach-tier-ribbon .ach-route-name { font-size: .7rem; }
.ach-tier-ribbon .ach-route-metric { font-size: .61rem; text-align: center; }
.ach-tier-mark {
  position: absolute;
  top: -7px;
  left: -7px;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--cat);
  color: #fff;
  font-size: .55rem;
  font-weight: 800;
}

.ach-artifact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ach-artifact {
  position: relative;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 78px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--cat) 34%, #fff);
  border-radius: 20px;
  background: color-mix(in srgb, var(--cat) 9%, #fff);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.ach-artifact::after {
  content: '';
  position: absolute;
  right: -28px;
  bottom: -38px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cat) 15%, transparent);
}
.ach-artifact.is-locked { opacity: .48; filter: grayscale(.85); }
.ach-artifact-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--cat);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--cat) 68%, #000);
  font-size: 1.4rem;
  color: #fff;
}
.ach-artifact-icon svg { width: 26px; height: 26px; display: block; }
.ach-artifact-copy { position: relative; z-index: 1; min-width: 0; }
.ach-artifact-copy strong,
.ach-artifact-copy small { display: block; }
.ach-artifact-copy strong { font-size: .75rem; font-weight: 800; }
.ach-artifact-copy small { margin-top: 4px; font-size: .61rem; color: var(--text-muted); }

/* Achievement detail sheet */
.ach-modal-card { gap: 12px; }
.ach-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ach-modal-icon {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  background: color-mix(in srgb, var(--cat, var(--accent)) 18%, #fff);
}
.ach-modal-icon svg { width: 27px; height: 27px; display: block; }
.ach-modal-icon.is-locked { filter: grayscale(1); opacity: 0.55; }
.ach-modal-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ach-modal-cat {
  display: flex;
  gap: 8px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--cat, var(--accent-dark));
}
.ach-modal-tier { color: var(--text-muted); }
.ach-modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}
.ach-modal-desc {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.ach-modal-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ach-modal-track {
  flex: 1;
  height: 9px;
  border-radius: 999px;
  background: var(--slot-empty);
  overflow: hidden;
}
.ach-modal-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--cat, var(--accent));
}
.ach-modal-num {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ach-modal-state {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cat, var(--accent-dark));
}
.ach-modal-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ach-modal-actions.has-share { grid-template-columns: 1fr 1.35fr; }

@keyframes ach-current-lift {
  50% { transform: translateY(-3px); }
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}

.leaderboard-row.me {
  border-color: var(--accent-light);
  background: #fff8f2;
}

.leaderboard-rank {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.leaderboard-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text);
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 16px;
  flex-shrink: 0;
}
.btn-back {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  color: var(--text);
  min-width: 40px;
}
.screen-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.pvp-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pvp-connection-chip {
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  background: #f8f8f8;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pvp-connection-chip.ok {
  border-color: #cde8d2;
  background: #eefaf0;
  color: #1f6d35;
}

.pvp-connection-chip.warn {
  border-color: #f2dfb3;
  background: #fff8e8;
  color: #8a6110;
}

.pvp-dev-icon {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- PVP SCREEN ---- */
#pvp-screen {
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pvp-panel {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}

/* One-time deduction hint under the history */
.deduction-hint {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-light);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 2px 0 6px;
  flex-shrink: 0;
  animation: hintIn 0.3s ease both;
}
@keyframes hintIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Nudge pulse on the analysis button (first loss only) */
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,162,97,0.55); }
  50%      { box-shadow: 0 0 0 8px rgba(244,162,97,0); }
}
.btn-pulse { animation: btnPulse 1.2s ease-in-out 3; }

/* Locked home entry (Infinite before Stage 1 is cleared) */
.home-secondary-btn.locked { opacity: 0.5; }

/* A finished daily is an achievement, not a disabled control — so it keeps full
   opacity and gets the warm accent treatment instead of a gray-out: tinted
   fill, accent border, muted label, and the app's own stroke check in accent. */
#btn-daily.is-done {
  border-color: var(--accent-light);
  background: rgba(253, 220, 188, 0.32);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#btn-daily.is-done .daily-label { color: var(--text-muted); }
/* Offline tag on the Daily button: a quiet second word, not a glued separator. */
#btn-daily .daily-tag {
  margin-left: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
#btn-daily.is-done .daily-done-mark {
  display: inline-flex;
  color: var(--accent-dark);
}
#btn-daily.is-done .daily-done-mark svg { width: 18px; height: 18px; display: block; }

/* The playable Daily is one continuous spectrum made from the six colors used
   by the game. Keeping the full gradient visible at once avoids the broken-up
   progress-bar look of the old travelling sheen. */
#btn-daily.is-live {
  color: #252129;
  border-color: transparent;
  background: linear-gradient(
    105deg,
    #F07070 0%,
    #F4A261 18%,
    #F7CE5B 36%,
    #6CC87A 56%,
    #6AA4F5 78%,
    #B48AE8 100%
  );
  box-shadow:
    0 5px 16px rgba(106, 164, 245, 0.18),
    0 2px 8px rgba(244, 162, 97, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
  position: relative;
  overflow: hidden;
}
#btn-daily.is-live::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0) 48%);
}

/* Segmented control (matchmaking strategy) */
.seg-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--slot-empty);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}
.seg-option {
  border: none;
  border-radius: 9px;
  background: transparent;
  padding: 9px 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-option.selected {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Demoted join-by-code entry in the PvP menu */
.pvp-code-link {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  align-self: center;
}

/* Daily world stats line on the result screen */
/* Awarded-points chip. Reusable: any element with this class + setPointsBadge().
   Soft accent box so a credit reads as a reward, not as body copy. */
.points-badge {
  align-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 0 auto 10px;
  padding: 5px 12px 6px;
  border-radius: 11px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.points-badge-unit {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.75;
}

.result-world {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 2px 0 6px;
}

/* Game analysis modal — "deduction funnel" */
.analysis-card { max-height: 82vh; overflow-y: auto; }
.analysis-score {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-dark);
  margin: 6px 0 2px;
}
#analysis-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}
.analysis-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px;
}
.funnel-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
}
.analysis-dots { display: flex; gap: 3px; flex-shrink: 0; }
.dot-mini { width: 13px; height: 13px; border-radius: 50%; }
.funnel-track {
  position: relative;
  flex: 1;
  height: 22px;
  min-width: 0;
  background: var(--slot-empty);
  border-radius: 6px;
  overflow: hidden;
}
.funnel-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}
.funnel-fill.q-strong { background: #6CC87A; }
.funnel-fill.q-ok     { background: #F4C15B; }
.funnel-fill.q-weak   { background: #cfcfcf; }
.funnel-fill.q-wasted { background: #F07070; }
.funnel-num {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
}
.funnel-row.show-num .funnel-num { display: flex; }
.funnel-row.show-num .funnel-fill { opacity: 0.35; }
.funnel-icon { flex-shrink: 0; width: 20px; text-align: center; font-size: 0.95rem; }
/* The coach line only appears when it has a real diagnosis, so it no longer
   needs a filled block shouting for attention — a quiet accent rule is enough. */
#analysis-note,
.chain-analysis-note {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  color: #5f5f5f;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 11px;
}
.chain-analysis-round {
  padding: 11px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  background: #fff;
}
.chain-analysis-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.chain-analysis-head strong {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
}
.chain-analysis-head span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}
.chain-analysis-funnel {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.chain-analysis-note { margin-top: 10px; }

/* "Cracking the safe": result-screen code dots snap in like lock tumblers */
@keyframes dotSnap {
  0%   { transform: scale(0) rotate(-120deg); opacity: 0; }
  70%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.dot-snap {
  animation: dotSnap 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@media (prefers-reduced-motion: reduce) {
  .dot-snap { animation: none; }
}

/* "Victory paints the world" wash (striped with the cracked code's colors) */
.win-wash {
  position: fixed;
  inset: 0;
  z-index: 2500; /* under the confetti canvas (3000) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.win-wash.show { opacity: 0.45; }

/* Campaign teaser: locked future stages */
.stage-section.coming-soon {
  opacity: 0.55;
}
.level-btn.soon-tile {
  border-style: dashed;
  color: var(--text-muted);
  cursor: default;
}

/* Room form: app-icon style mode cards */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1;
  padding: 6px 2px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--slot-empty);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.mode-card:active { transform: scale(0.94); }
.mode-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(244,162,97,0.25);
}
.mode-card-emoji { font-size: 1.5rem; line-height: 1; }
.mode-card-emoji svg { width: 24px; height: 24px; display: block; }
.mode-card-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.15;
}
.mode-card.selected .mode-card-label { color: var(--accent-dark); }

/* Room form: sliders */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 28px;
}
.slider-value {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.pvp-panel-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}

.pvp-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

.input-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
}

.input-control:focus {
  outline: none;
  border-color: var(--accent);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}

.pvp-btn {
  width: 100%;
  margin-top: 4px;
}

.pvp-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  /* break-word, never break-all: this class also carries prose (analysis coach
     line, result subtitles), and break-all split words and numbers mid-glyph
     ("try te/sting colors", "8/3%"). Long unbroken tokens — room codes, guest
     nicknames — still wrap, but only when they genuinely do not fit. */
  overflow-wrap: break-word;
}

.pvp-auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pvp-auth-btn {
  padding: 10px 12px;
  font-size: 0.86rem;
  flex: 1 1 calc(50% - 4px);
}

.pvp-dev-config {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pvp-status {
  gap: 6px;
  font-size: 0.9rem;
}

.pvp-status-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.pvp-status-label {
  color: var(--text-muted);
  font-weight: 600;
}

.pvp-status-value {
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

.pvp-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0 2px;
}

.pvp-vs-card {
  width: min(100%, 560px);
  margin: auto;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.pvp-vs-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.pvp-vs-name {
  font-weight: 800;
  color: var(--text);
  font-size: 1rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pvp-vs-rating {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pvp-vs-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pvp-vs-title {
  font-weight: 900;
  font-size: 2rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.pvp-vs-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.pvp-vs-countdown {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
  min-height: 1.1em;
}

.pvp-vs-progress {
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: #ececec;
  overflow: hidden;
}

.pvp-vs-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.pvp-search-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 8px 4px 10px;
}

.pvp-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid #e8e8e8;
  border-top-color: var(--accent);
  animation: pvpSpin 0.9s linear infinite;
}

@keyframes pvpSpin {
  to { transform: rotate(360deg); }
}

#pvp-searching-status {
  min-height: 1.1em;
}

#pvp-created-code {
  letter-spacing: 1.4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  /* Warm dim + blur instead of a flat neutral gray: the old scrim turned the
     cream UI behind it muddy (most visible with the analysis sheet open). */
  background: rgba(74, 45, 22, 0.32);
  -webkit-backdrop-filter: blur(3px) saturate(112%);
  backdrop-filter: blur(3px) saturate(112%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 200;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions {
  display: flex;
  width: 100%;
}

.modal-actions .btn-primary {
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.modal-actions-stack {
  flex-direction: column;
  gap: 10px;
}

/* Board rules sheet (mechanics chip → modal). */
.mech-facts {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.mech-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.mech-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.mech-row-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-light);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mech-row-icon svg { width: 17px; height: 17px; display: block; }
.mech-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mech-row-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.mech-row-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Apple sign-in button per Apple HIG: black, white label, SF-style. */
.btn-apple {
  background: #000;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 0;
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.btn-apple:active { transform: scale(0.97); }

.btn-plain {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
}

/* scrollable container for stages */
.levels-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0 0 16px;
}

/* stage section */
.stage-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stage-header-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-dark);
}
.stage-header-title svg {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 3px;
}
.stage-header-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stage-levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.level-btn {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.1s;
  position: relative;
}
.level-btn:active { transform: scale(0.93); }
.level-btn.unlocked {
  border-color: var(--accent-light);
  background: var(--accent-light);
}
.level-btn.current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(244,162,97,0.45);
}
.level-btn.locked {
  opacity: 0.35;
  cursor: default;
}
.level-btn .lock-icon { font-size: 0.85rem; }

/* ---- GAME SCREEN ---- */
#game-screen {
  gap: 0;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
  flex-shrink: 0;
}
.game-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.game-level-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
/* Header facts are separate spans laid out with a gap — a wider gap than a word
   space reads as a separator without spending a bullet glyph on it. */
.game-level {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
/* Tappable mechanics chip: the board's icon recipe + a "?" affordance. */
.mech-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.mech-chip:active { transform: scale(0.92); }
.mech-chip svg { width: 14px; height: 14px; display: block; }
.mech-chip-q {
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.75;
}
.game-attempts {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.game-attempts .attempts-num { color: var(--accent); }

.pvp-competition-card {
  min-width: 132px;
  max-width: 150px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 7px 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pvp-track-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Live opponent solving progress during a round — the "pressure bar". */
.pvp-opp-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.pvp-opp-progress-label {
  width: 34px;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
}
.pvp-opp-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: var(--slot-empty, #f1ece6);
  overflow: hidden;
}
.pvp-opp-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 0.45s ease;
}

.pvp-track-name {
  width: 34px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.pvp-track-dots {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}

.pvp-track-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e2e2e2;
  border: 1px solid rgba(0,0,0,0.04);
}

.pvp-track-dot.current {
  background: var(--accent);
}

.pvp-track-dot.done {
  background: #6CC87A;
}

/* history */
.history-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.history-slots {
  display: flex;
  gap: 5px;
  flex: 1;
  justify-content: center;
  /* mirror the result column (32px + 10px gap) so dots align with the guess row center */
  padding-left: 42px;
}
.history-slot {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 9px;
  min-width: 0;
  max-width: 50px;
  max-height: 50px;
}
.history-result {
  font-size: 0.95rem;
  font-weight: 800;
  min-width: 32px;
  text-align: right;
  color: var(--accent-dark);
  flex-shrink: 0;
}
.history-result .result-total {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* active guess row */
.active-row {
  display: flex;
  gap: 6px;
  padding: 8px 0 6px;
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
  justify-content: center;
}
.guess-slot {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--slot-empty);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
  max-width: 62px;
  max-height: 62px;
}
.guess-slot.filled { border-color: transparent; }
.guess-slot:not(.revealed):active { transform: scale(0.9); }
/* Active cursor slot — where the next tapped color lands. */
.guess-slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,162,97,0.35);
}
.guess-slot.active.filled {
  border-color: var(--accent);
}
/* Revealed slot: same badge pattern as frozen — the ring alone didn't say
   WHY the cell is locked; the corner glyph names the cause. */
.guess-slot.revealed {
  border-color: #F7CE5B;
  border-width: 2.5px;
  cursor: default;
  box-shadow: 0 0 0 2px rgba(247,206,91,0.35);
  position: relative;
}
.guess-slot.revealed::after {
  content: '🔍';
  position: absolute;
  top: -7px;
  right: -7px;
  font-size: 13px;
  line-height: 1;
  z-index: 1;
}
/* Frozen slot: the kept color must stay visible — ice is a ring + badge, not
   a background override (that used to paint the cell "empty"). */
.guess-slot.frozen {
  border-color: #9ec7ff;
  cursor: not-allowed;
  box-shadow: inset 0 0 0 2px rgba(158, 199, 255, 0.75);
  position: relative;
}
.guess-slot.frozen:not(.filled) {
  background:
    linear-gradient(135deg, rgba(158,199,255,0.22), rgba(158,199,255,0.08)),
    var(--slot-empty);
}
.guess-slot.frozen::after {
  content: '❄️';
  position: absolute;
  top: -7px;
  right: -7px;
  font-size: 13px;
  line-height: 1;
  z-index: 1;
}

/* palette */
.palette-area {
  padding: 6px 0 2px;
  flex-shrink: 0;
}
.palette-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
  text-align: center;
}
.palette-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.palette-color {
  /* responsive: grows/shrinks but stays within sane range */
  width: clamp(36px, 11.5vw, 48px);
  height: clamp(36px, 11.5vw, 48px);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.1s, border-color 0.15s;
  flex-shrink: 0;
}
.palette-color:active { transform: scale(0.88); }
.palette-color.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

/* ability button */
.btn-ability {
  background: none;
  color: var(--accent-dark);
  border: 1.5px solid var(--accent);
  border-radius: 50px;
  padding: 10px 0;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}
.btn-ability:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-ability:not(:disabled):active {
  transform: scale(0.97);
  background: var(--accent-light);
}

/* confirm button */
.btn-confirm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 0;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(244,162,97,0.4);
}
.btn-confirm:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}
.btn-confirm:not(:disabled):active { transform: scale(0.97); }

.pvp-leave-btn {
  margin-top: 8px;
  width: 100%;
}

/* ---- PVP ROUND SCREEN ---- */
#pvp-round-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.pvp-round-card {
  width: 100%;
  max-width: 320px;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- RESULT SCREEN ---- */
#result-screen {
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
}
#result-screen.is-chain-result {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: calc(env(safe-area-inset-top, 16px) + 24px);
  padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 24px);
}
#result-screen.is-chain-result .result-emoji {
  font-size: 3rem;
  margin-bottom: 2px;
}
.result-emoji {
  font-size: 4rem;
  margin-bottom: 8px;
}
.result-title {
  font-size: 1.8rem;
  font-weight: 800;
}
.result-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  /* Subtitles may carry an explicit \n to split two thoughts onto two lines. */
  white-space: pre-line;
}
.result-answer {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.result-answer .dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.result-answer.is-chain {
  width: min(100%, 340px);
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}
.chain-result-round {
  display: grid;
  grid-template-columns: minmax(58px, auto) 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px 8px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  background: #fff;
}
.chain-result-round.is-won {
  border-color: color-mix(in srgb, #6CC87A 42%, var(--border));
  background: color-mix(in srgb, #6CC87A 8%, #fff);
}
.chain-result-round.is-lost {
  border-color: color-mix(in srgb, #F07070 42%, var(--border));
  background: color-mix(in srgb, #F07070 7%, #fff);
}
.chain-result-label,
.chain-result-score {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}
.chain-result-label { text-align: left; }
.chain-result-score { text-align: right; }
.chain-result-code {
  display: flex;
  justify-content: center;
  gap: 4px;
}
.chain-result-code .dot {
  width: 17px;
  height: 17px;
}
.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}
.btn-secondary {
  background: none;
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 14px 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.btn-secondary:active { transform: scale(0.96); }

.btn-delayed {
  position: relative;
  overflow: hidden;
}
.btn-delayed::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(244,162,97,0.18);
  width: 0%;
  pointer-events: none;
}
.btn-delayed.is-counting::before {
  animation: delayedFill linear forwards;
  animation-duration: var(--delay-ms, 1500ms);
}
@keyframes delayedFill {
  from { width: 0%; }
  to { width: 100%; }
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(26,26,26,0.82);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  /* Long coaching messages must wrap, not run off-screen. */
  white-space: normal;
  text-align: center;
  max-width: min(88vw, 340px);
  z-index: 100;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- ONBOARDING ---- */
.onb-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px;
}
.onb-illustration {
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.onb-illo-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.onb-illo-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.onb-illo-dot {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.10);
}
.onb-illo-empty {
  background: var(--slot-empty, #f1ece6);
  border: 2px dashed var(--border);
  color: var(--text-muted);
  box-shadow: none;
}
.onb-illo-palette .onb-illo-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.onb-illo-badge {
  margin-top: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 20px;
}
.onb-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}
.onb-text {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.45;
}
.onb-dots {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.onb-dot.active {
  background: var(--accent);
  width: 22px;
  border-radius: 4px;
}
.onb-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}

/* ---- PROFILE ---- */
.profile-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-light), #fff);
  border: 1.5px solid var(--border);
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.7rem;
  font-weight: 800;
}
.profile-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}
.profile-since {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.profile-stat {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  background: #fff;
}
.profile-stat-icon { font-size: 1.4rem; }
.profile-stat-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-dark);
  margin-top: 2px;
}
.profile-stat-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.profile-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.profile-recent {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-recent-chip {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--accent-light);
  background: #fffaf4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.profile-recent-chip svg { width: 24px; height: 24px; display: block; }
.profile-recent-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}
#btn-profile-signout { margin-top: auto; }

.daily-share-preview {
  text-align: center;
  margin: 4px auto 16px;
}
.daily-share-canvas {
  width: 62%;
  max-width: 240px;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3000;
}

/* Achievement unlock focus moment. Dedicated queue, above every screen. */
.ach-banner {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: rgba(30,25,34,.86);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility 0s linear .28s;
  pointer-events: none;
  z-index: 4000;
}
.ach-banner.visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
  pointer-events: auto;
}
.ach-banner-rays {
  position: absolute;
  width: min(135vw, 640px);
  aspect-ratio: 1;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--cat, var(--accent)) 24%, transparent) 0 8deg, transparent 8deg 19deg);
  transform: scale(.55) rotate(-18deg);
  opacity: 0;
}
.ach-banner.visible .ach-banner-rays {
  animation: ach-rays-in 1.05s cubic-bezier(.2,.9,.3,1) forwards;
}
.ach-banner-body {
  position: relative;
  z-index: 1;
  width: min(100%, 320px);
  text-align: center;
}
.ach-banner.visible .ach-banner-body {
  animation: ach-unlock-in .65s cubic-bezier(.2,1.25,.35,1) both;
}
.ach-banner-icon {
  display: grid;
  place-items: center;
  width: 126px;
  height: 126px;
  margin: 0 auto 22px;
  border: 7px solid rgba(255,255,255,.86);
  border-radius: 38px;
  background: var(--cat, var(--accent));
  color: #fff;
  box-shadow: 0 0 0 13px color-mix(in srgb, var(--cat, var(--accent)) 18%, transparent), 0 20px 50px rgba(0,0,0,.34);
  font-size: 3.4rem;
  line-height: 1;
  transform: rotate(-5deg);
}
.ach-banner-icon svg {
  width: 66px;
  height: 66px;
  display: block;
}
.ach-banner-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: color-mix(in srgb, var(--cat, var(--accent)) 45%, #fff);
}
.ach-banner-title {
  margin: 7px 0 6px;
  font-size: 1.8rem;
  font-weight: 800;
}
.ach-banner-desc { color: #d8d1dc; font-size: .88rem; line-height: 1.4; }
.ach-banner-close {
  margin-top: 22px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  padding: 10px 18px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

@keyframes ach-unlock-in {
  from { opacity: 0; transform: scale(.65) rotate(8deg); }
  to { opacity: 1; transform: none; }
}
@keyframes ach-rays-in {
  from { opacity: 0; transform: scale(.55) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(10deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ach-route-node.is-current .ach-route-token,
  .ach-banner.visible .ach-banner-body,
  .ach-banner.visible .ach-banner-rays { animation: none; }
  .ach-banner.visible .ach-banner-rays { opacity: .7; transform: none; }
}

/* ---- COLOR DEFINITIONS ---- */
.color-red    { background: #F07070; }
.color-orange { background: #F4A261; }
.color-yellow { background: #F7CE5B; }
.color-green  { background: #6CC87A; }
.color-blue   { background: #6AA4F5; }
.color-purple { background: #B48AE8; }

/* also used for history dots */
.dot { border-radius: 50%; }

/* ---- RESPONSIVE (small phones) ---- */
@media (max-height: 640px) {
  .app-subtitle { margin-bottom: 16px; }
  .color-preview { margin-bottom: 20px; }

  .game-header { padding: 8px 0 6px; }
  .palette-area { padding: 4px 0 2px; }
  .palette-label { margin-bottom: 5px; }
  .btn-confirm { margin-top: 6px; padding: 12px 0; }
  .btn-ability { margin-top: 4px; padding: 8px 0; }
  .active-row { padding: 6px 0 4px; }
  .history-area { gap: 5px; }
}

@media (hover: none) and (pointer: coarse) {
  .btn-primary, .btn-confirm, .level-btn.current {
    box-shadow: 0 2px 10px rgba(244,162,97,0.28);
  }
}

/* Community ghost opponent: clearly a replay, not a live player. */
.ghost-opp {
  color: #8E6FC9;
}

#pvp-player-meta { cursor: pointer; }

/* Funnel row evidence: the codes still possible after a guess — proof of the
   narrowing, not an assertion. The code(s) alive at the end glow gold. */
.funnel-expand {
  padding: 6px 10px 8px 46px;
  background: rgba(224, 122, 58, 0.06);
  border-radius: 10px;
  margin: -2px 0 4px;
}
.funnel-expand-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.funnel-cand-row {
  display: inline-flex;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 8px;
  margin: 2px 6px 2px 0;
}
.funnel-cand-row.is-answer {
  background: rgba(244, 206, 91, 0.35);
  box-shadow: inset 0 0 0 1px rgba(224, 122, 58, 0.45);
}
.analysis-note-code {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

/* ---- ACCOUNT DELETION ---- */
.btn-danger {
  background: #D64545;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:disabled { opacity: 0.55; }

.profile-delete-link { color: #C24040; }

#delete-account-text {
  font-size: 0.85rem;
  line-height: 1.45;
}

/* ---- OFFLINE STATE ---- */
/* A calm pill on the home screen says what still works; server-backed entry
   points dim; local modes (campaign, infinite, ghost duel) stay fully
   interactive. Buttons keep their handlers — tapping explains why via toast. */
.offline-pill {
  margin: 10px auto 0;
  width: fit-content;
  max-width: 86%;
  padding: 7px 16px;
  border-radius: 50px;
  background: rgba(224, 122, 58, 0.12);
  border: 1px solid rgba(224, 122, 58, 0.35);
  color: #B9622C;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  animation: offline-pill-in 0.35s ease;
}
@keyframes offline-pill-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .offline-pill { animation: none; }
}
body.is-offline #btn-daily,
body.is-offline #btn-leaderboard,
body.is-offline #btn-pvp-open-join,
body.is-offline #btn-pvp-open-create,
body.is-offline #btn-pvp-open-code,
body.is-offline #btn-auth-home:not(.signed) {
  opacity: 0.45;
}
