:root {
  color-scheme: light;
  --cream: #f6f0e5;
  --cream-deep: #eee3d2;
  --paper: #fffdf8;
  --charcoal: #292724;
  --muted: #706b64;
  --line: #d8cfc1;
  --coral: #c96f5d;
  --coral-dark: #9e4e40;
  --coral-soft: #f2d7cf;
  --amber: #d99b3e;
  --amber-soft: #f6e7c7;
  --green: #477b63;
  --green-soft: #dce9e1;
  --shadow: 0 14px 34px rgba(74, 56, 38, 0.1);
  --radius: 22px;
  --puzzle-text-size: 19px;
  --card-label-size: 16px;
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  background: var(--cream);
  color: var(--charcoal);
}

html.theme-ocean {
  --cream: #edf3f2;
  --cream-deep: #d9e6e5;
  --paper: #fbfaf4;
  --charcoal: #17324d;
  --muted: #5f7181;
  --line: #afc5c6;
  --coral: #397b91;
  --coral-dark: #173f5f;
  --coral-soft: #c9e5e2;
  --amber: #60788c;
  --amber-soft: #dce9e9;
  --green: #2d706e;
  --green-soft: #cee6e2;
  --shadow: 0 14px 34px rgba(23, 50, 77, 0.12);
}

html.theme-ocean body {
  background:
    radial-gradient(circle at 8% 0%, rgba(183, 222, 218, 0.42), transparent 28rem),
    radial-gradient(circle at 95% 18%, rgba(95, 113, 129, 0.16), transparent 30rem),
    var(--cream);
}

html.theme-ocean .mini-logo i:nth-child(1), html.theme-ocean .mini-logo i:nth-child(4) { background: #79bfc1; }
html.theme-ocean .mini-logo i:nth-child(2), html.theme-ocean .mini-logo i:nth-child(5) { background: #b7deda; }
html.theme-ocean .card {
  border-color: color-mix(in srgb, var(--coral) 55%, var(--line));
  background: color-mix(in srgb, var(--card-colour) 34%, var(--coral-soft) 66%);
}
html.theme-ocean .card-art { background: rgba(251, 250, 244, 0.58); }
html.theme-ocean .card-art::before { background: #5f7181; opacity: 0.32; }
html.theme-ocean .card-art::after { background: #79bfc1; opacity: 0.48; }

* { box-sizing: border-box; }

html { min-height: 100%; overflow-x: hidden; background: var(--cream); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-weight: 500;
  background:
    radial-gradient(circle at 8% 0%, rgba(217, 155, 62, 0.1), transparent 28rem),
    radial-gradient(circle at 95% 18%, rgba(201, 111, 93, 0.09), transparent 30rem),
    var(--cream);
}

button, input, select { font: inherit; }

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button { color: inherit; }

button:focus-visible, [tabindex]:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  transform: translateY(-140%);
  border-radius: 12px;
  background: var(--charcoal);
  color: white;
}

.skip-link:focus { transform: translateY(0); }

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 2.5rem) calc(7.75rem + env(safe-area-inset-bottom));
}

.app-shell > main { flex: 1 0 auto; }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0;
  padding-top: 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.footer-release-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  cursor: pointer;
}

.footer-release-button:hover { color: var(--coral-dark); text-decoration-color: currentColor; }

.release-notes {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.8rem 0.85rem 0.8rem 1rem;
  border: 1px solid color-mix(in srgb, var(--coral) 55%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--coral-soft) 66%, var(--paper));
  box-shadow: 0 10px 24px rgba(74, 56, 38, 0.13);
  animation: release-drop 280ms cubic-bezier(.2,.8,.2,1) both;
}

.release-notes-copy { display: grid; min-width: 0; gap: 0.15rem; line-height: 1.3; }
.release-notes-copy strong { font-size: 0.92rem; font-weight: 900; }
.release-notes-copy span { color: #514c46; font-size: 0.82rem; font-weight: 700; }
.release-notes-ok { min-width: 62px; min-height: 44px; flex: 0 0 auto; border-color: var(--coral-dark); background: var(--paper); }

@keyframes release-drop {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.topbar-start {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.9rem;
}

.header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 0.5rem; }

.topbar-puzzle-meta {
  color: var(--coral-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  cursor: pointer;
}

.mini-logo {
  display: grid;
  grid-template-columns: repeat(5, 7px);
  align-items: end;
  gap: 2px;
  width: 43px;
  height: 32px;
  padding: 6px;
  border-radius: 11px;
  background: var(--charcoal);
}

.mini-logo i { display: block; height: 13px; border-radius: 3px; background: var(--coral); }
.mini-logo i:nth-child(2) { height: 18px; background: var(--amber); }
.mini-logo i:nth-child(3) { height: 10px; background: var(--paper); }
.mini-logo i:nth-child(4) { height: 16px; background: #da9b8d; }
.mini-logo i:nth-child(5) { height: 12px; background: #e8bd75; }

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: 0 3px 9px rgba(54, 42, 30, 0.07);
  font-size: 1.58rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover { border-color: var(--coral); color: var(--coral-dark); transform: translateY(-1px); }

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin: clamp(1.5rem, 5vw, 3.5rem) 0 1.5rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--coral-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 720px;
  margin-bottom: 0.45rem;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.hero-copy { max-width: 600px; margin: 0; color: var(--muted); font-size: 1.05rem; }

.attempt-pill {
  flex: 0 0 auto;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.85rem; align-items: start; }

.clue-panel, .surface {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.clue-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.clue-toggle strong { display: block; font-size: 1.05rem; }
.clue-toggle span { color: #5a554f; font-size: 0.86rem; font-weight: 700; }
.chevron { transition: transform 180ms ease; }
.clue-panel.collapsed .chevron { transform: rotate(-90deg); }

.clue-content { min-width: 0; padding: 0 1.2rem 1.15rem; overflow: hidden; border-top: 1px solid var(--line); }
.clue-panel.collapsed .clue-content { display: none; }

.clue-list { display: grid; gap: 0.72rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.clue-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0.7rem; align-items: start; font-size: var(--puzzle-text-size); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.clue-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: var(--cream-deep);
  color: var(--coral-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.hint-box { margin-top: 1rem; padding: 0.9rem 1rem; border-radius: 14px; background: var(--amber-soft); }
.hint-box strong { display: block; margin-bottom: 0.2rem; }
.hint-action { margin-top: 1rem; }
.clue-reveal { width: 100%; margin-top: 0.85rem; border-color: var(--green); color: var(--green); }
.clue-note { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 700; line-height: 1.35; }

.board { padding: clamp(0.8rem, 2vw, 1.25rem); }

.position-markers, .card-list {
  display: grid;
  grid-template-columns: repeat(var(--card-count), minmax(0, 1fr));
  gap: clamp(0.4rem, 1.5vw, 0.8rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.position-markers { margin-bottom: 0.45rem; }
.position-marker { text-align: center; color: var(--muted); font-size: 0.78rem; font-weight: 800; }

.card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 178px;
  grid-template-rows: 1fr auto;
  padding: 0.7rem;
  border: 2px solid color-mix(in srgb, var(--art-a) 42%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--card-colour, var(--cream-deep)) 80%, var(--art-a) 20%);
  box-shadow: 0 6px 14px rgba(54, 42, 30, 0.14);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(54, 42, 30, 0.13); }
.card.selected {
  border-color: var(--coral-dark);
  background: color-mix(in srgb, var(--card-colour) 68%, var(--coral) 32%);
  box-shadow: 0 0 0 4px var(--amber), 0 13px 25px rgba(105, 55, 44, 0.22);
  filter: saturate(1.38) contrast(1.05);
  transform: translateY(-2px) scale(1.012);
}
.card.selected .card-art { background: rgba(255,255,255,0.7); }
.card.dragging { z-index: 3; opacity: 0.82; transform: scale(1.045) rotate(-1deg); box-shadow: 0 18px 34px rgba(54, 42, 30, 0.24); cursor: grabbing; }
.card.dragging {
  z-index: 30;
  opacity: 0.96;
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 20px 38px rgba(54, 42, 30, 0.28);
}
.drag-placeholder {
  min-width: 0;
  min-height: 178px;
  border: 2px dashed var(--coral);
  border-radius: 18px;
  background: color-mix(in srgb, var(--coral-soft) 55%, transparent);
}
.card.drop-target::after {
  content: "";
  position: absolute;
  z-index: 5;
  top: 5%;
  bottom: 5%;
  left: -0.48rem;
  width: 5px;
  border-radius: 999px;
  background: var(--coral-dark);
  box-shadow: 0 0 0 3px var(--coral-soft);
}
.card-list { position: relative; }
.card-list.drop-at-end::after {
  content: "";
  position: absolute;
  z-index: 5;
  top: 5%;
  right: -0.48rem;
  bottom: 5%;
  width: 5px;
  border-radius: 999px;
  background: var(--coral-dark);
  box-shadow: 0 0 0 3px var(--coral-soft);
}
.card.move-landed { border-color: var(--green); }

.card-art {
  position: relative;
  display: grid;
  min-height: 100px;
  place-items: center;
  overflow: hidden;
  border-radius: 13px;
  background: rgba(255,255,255,0.36);
}

.card-art::before, .card-art::after { content: ""; position: absolute; border-radius: 50%; }
.card-art::before { width: 74px; height: 74px; background: var(--art-a, var(--coral)); opacity: 0.36; }
.card-art::after { width: 38px; height: 38px; margin: 35px 0 0 35px; background: var(--art-b, var(--amber)); opacity: 0.46; }
.art-glyph { position: relative; z-index: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: clamp(2.25rem, 5.5vw, 3.45rem); filter: saturate(1.15) contrast(1.05); }
.card-label { padding-top: 0.65rem; overflow-wrap: anywhere; text-align: center; font-size: var(--card-label-size); font-weight: 900; line-height: 1.15; }
.grabber { position: absolute; top: 0.45rem; right: 0.5rem; z-index: 2; color: rgba(41,39,36,0.5); font-size: 0.85rem; letter-spacing: -2px; }
.selected-badge { position: absolute; z-index: 4; top: 0.45rem; left: 0.45rem; padding: 0.28rem 0.45rem; border-radius: 8px; background: var(--coral-dark); color: white; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }

.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.action-group { display: flex; align-items: center; gap: 0.7rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) { border-color: var(--coral); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border-color: var(--coral-dark); background: var(--coral); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--coral-dark); }
.btn.subtle { background: transparent; }
.btn.success { border-color: var(--green); background: var(--green); color: white; }
.btn.danger { border-color: #9a3939; color: #8d2e2e; }
.btn.wide { width: 100%; }

.feedback {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--amber);
  border-radius: 9px;
  background: var(--amber-soft);
  line-height: 1.4;
}

.feedback strong { display: block; }
.feedback span { display: block; margin-top: 0.25rem; color: #5a554f; font-size: 0.86rem; font-weight: 700; }

.bottom-dock {
  position: fixed;
  z-index: 10;
  right: max(1rem, calc((100vw - 1180px) / 2 + 2.5rem));
  bottom: max(0.45rem, env(safe-area-inset-bottom));
  left: max(1rem, calc((100vw - 1180px) / 2 + 2.5rem));
  max-width: 650px;
  margin: 0 auto;
  padding: 0.38rem 0.42rem 0.3rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(58, 43, 29, 0.18);
  isolation: isolate;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
  padding: 0.4rem;
  border: 0;
  border-radius: 17px;
  background: var(--paper);
}

.nav-item {
  min-height: 48px;
  padding: 0.55rem 0.5rem;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}
.nav-item.active { background: var(--charcoal); color: white; }
.nav-item:disabled { opacity: 0.38; cursor: not-allowed; }

.view { padding-top: 1.5rem; }
.view-header { margin: 2rem 0 1.5rem; }
.view-header h1 { font-size: clamp(2rem, 6vw, 3.6rem); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
.stat-card { padding: 1.15rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,248,0.82); }
.stat-value { display: block; font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 900; letter-spacing: -0.05em; }
.stat-label { color: var(--muted); font-size: 0.84rem; font-weight: 700; }
.stats-section { margin-top: 1.5rem; }
.protection-title { display: flex; gap: 0.7rem; align-items: center; }
.protection-shield {
  flex: 0 0 auto;
  width: 34px;
  height: 38px;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgba(58, 43, 29, 0.22));
}
.shield-body {
  fill: #a8602f;
  stroke: #50585c;
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.shield-check {
  fill: none;
  stroke: #fffdf8;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.distribution { display: grid; gap: 0.55rem; }
.distribution-row { display: grid; grid-template-columns: 28px 1fr 30px; gap: 0.6rem; align-items: center; }
.bar-track { height: 12px; overflow: hidden; border-radius: 999px; background: var(--cream-deep); }
.bar-fill { height: 100%; border-radius: inherit; background: var(--coral); }

.overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(41, 39, 36, 0.54);
  backdrop-filter: blur(7px);
}

.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  padding: clamp(1.2rem, 5vw, 2rem);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 26px 70px rgba(22, 18, 13, 0.25);
}

.modal h2 { margin-bottom: 0.55rem; font-size: clamp(1.7rem, 5vw, 2.5rem); letter-spacing: -0.045em; }
.modal-copy { color: #5a554f; font-weight: 600; line-height: 1.55; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.35rem; }
.modal-actions .btn { flex: 1 1 160px; }
.result-mark { display: grid; width: 70px; height: 70px; place-items: center; margin-bottom: 1rem; border-radius: 22px; background: var(--green-soft); color: var(--green); font-size: 2rem; }
.result-mark.failed { background: var(--amber-soft); color: #8d621c; }
.stars { margin: 0.5rem 0 1rem; color: var(--amber); font-size: 2rem; letter-spacing: 0.08em; }
.score-summary { margin: -0.35rem 0 1rem; color: var(--muted); font-size: 0.9rem; font-weight: 800; }
.return-reminder {
  position: relative;
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1.2rem;
  padding: clamp(1rem, 3vw, 1.35rem);
  border: 2px solid color-mix(in srgb, var(--green) 58%, var(--line));
  border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--green-soft) 88%, var(--paper)), var(--paper));
  color: var(--charcoal);
  line-height: 1.35;
  box-shadow: 0 14px 34px rgba(40, 86, 61, 0.16);
}
.return-reminder::before {
  content: "";
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--green-soft) 70%, transparent);
}
.return-reminder .return-kicker {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.return-reminder strong { max-width: calc(100% - 2rem); color: var(--charcoal); font-size: clamp(1.25rem, 4vw, 1.7rem); font-weight: 900; }
.return-reminder span:last-child { color: #3f5349; font-size: 1rem; font-weight: 750; }
.result-facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; margin: 1.25rem 0; }
.result-fact { padding: 0.8rem 0.4rem; border-radius: 14px; background: var(--cream); text-align: center; }
.result-fact strong { display: block; font-size: 1.15rem; }
.result-fact span { color: var(--muted); font-size: 0.72rem; }
.solution-order { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0; padding: 0; list-style: none; }
.solution-order li { padding: 0.5rem 0.65rem; border-radius: 10px; background: var(--cream-deep); font-size: 0.83rem; font-weight: 800; }
.solution-order.card-list {
  display: grid;
  grid-template-columns: repeat(var(--card-count), minmax(0, 1fr));
  gap: clamp(0.35rem, 1.2vw, 0.6rem);
}
.solution-order.card-list li { padding: 0.45rem; border-radius: 14px; background: color-mix(in srgb, var(--card-colour) 78%, var(--paper)); }
.solution-card {
  min-height: 126px;
  cursor: default;
  pointer-events: none;
  touch-action: auto;
}
.solution-card:hover { transform: none; }
.solution-card .card-art { min-height: 64px; }
.solution-card .art-glyph { font-size: clamp(1.75rem, 4vw, 2.35rem); }
.solution-position {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 2;
  display: grid;
  min-width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  border-radius: 9px;
  background: var(--charcoal);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 900;
}
.card-answer { display: block; margin-top: 0.25rem; color: var(--muted); text-align: center; font-size: 0.72rem; font-weight: 900; }
.explanation-list { padding-left: 1.25rem; color: var(--muted); line-height: 1.5; }

.settings-list { display: grid; gap: 0.5rem; margin-top: 1rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.setting-row label strong { display: block; }
.setting-row label span { color: var(--muted); font-size: 0.82rem; }
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: 160ms ease; }
.switch-ui::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: 160ms ease; }
.switch input:checked + .switch-ui { background: var(--green); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--amber); outline-offset: 3px; }
.text-size-options { display: flex; gap: 0.35rem; }
.text-size-options button { min-width: 42px; min-height: 40px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.text-size-options button.active { border-color: var(--charcoal); background: var(--charcoal); color: white; }
.theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.theme-options button { display: flex; min-width: 78px; min-height: 42px; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.4rem 0.55rem; border: 1px solid var(--line); border-radius: 11px; background: white; font-size: 0.78rem; font-weight: 800; cursor: pointer; }
.theme-options button.active { border-color: var(--charcoal); box-shadow: 0 0 0 2px color-mix(in srgb, var(--charcoal) 22%, transparent); }
.theme-swatch { width: 18px; height: 18px; flex: 0 0 auto; border: 1px solid rgba(23,50,77,0.18); border-radius: 50%; }
.theme-swatch.warm { background: linear-gradient(135deg, #c96f5d 0 50%, #f6e7c7 50%); }
.theme-swatch.ocean { background: linear-gradient(135deg, #173f5f 0 50%, #b7deda 50%); }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.danger-zone.confirming { padding: 1rem; border: 2px solid var(--coral); border-radius: 16px; background: var(--paper); box-shadow: 0 10px 26px rgba(74,56,38,0.14); }
.confirm-input { width: 100%; min-height: 48px; margin: 0.75rem 0; padding: 0.75rem; border: 1px solid var(--line); border-radius: 12px; background: white; text-transform: uppercase; }

.rating-fieldset { margin: 1.25rem 0; padding: 0; border: 0; }
.rating-fieldset legend { margin-bottom: 0.6rem; font-weight: 800; }
.rating-fieldset legend span { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.rating-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rating-options label { position: relative; display: grid; width: 52px; height: 48px; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: white; cursor: pointer; }
.rating-options input { position: absolute; opacity: 0; }
.rating-options label:has(input:checked) { border-color: var(--charcoal); background: var(--cream-deep); box-shadow: 0 0 0 2px var(--charcoal); }
.rating-options label:has(input:focus-visible) { outline: 3px solid var(--amber); outline-offset: 3px; }
.rating-options label > span[aria-hidden] { font-size: 1.55rem; }
.feedback-field { display: grid; gap: 0.5rem; }
.feedback-field textarea { width: 100%; min-height: 140px; resize: vertical; padding: 0.85rem; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--charcoal); font: inherit; line-height: 1.45; }
.feedback-field textarea:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.welcome-logo { display: flex; align-items: end; gap: 5px; width: 112px; height: 82px; margin-bottom: 1.3rem; }
.welcome-logo span { flex: 1; border-radius: 9px; background: var(--coral); }
.welcome-logo span:nth-child(1) { height: 46px; }
.welcome-logo span:nth-child(2) { height: 71px; background: var(--amber); }
.welcome-logo span:nth-child(3) { height: 34px; background: var(--charcoal); }
.welcome-logo span:nth-child(4) { height: 58px; background: #dd9a8c; }
.welcome-logo span:nth-child(5) { height: 42px; background: #e6b761; }

.welcome-modal { width: min(560px, 100%); max-width: 100%; min-width: 0; }
.welcome-modal h2, .welcome-modal .modal-copy { max-width: 100%; overflow-wrap: anywhere; }

.toast {
  position: fixed;
  z-index: 80;
  right: 1rem;
  bottom: 6.5rem;
  max-width: 340px;
  padding: 0.85rem 1rem;
  transform: translateY(20px);
  border-radius: 14px;
  background: var(--charcoal);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}
.toast.show { transform: translateY(0); opacity: 1; }

.empty-state { padding: 2rem; border: 1px dashed var(--line); border-radius: 18px; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

html.high-contrast {
  --cream: #fff;
  --cream-deep: #ececec;
  --paper: #fff;
  --charcoal: #111;
  --muted: #3a3a3a;
  --line: #575757;
  --coral: #a33d2e;
  --coral-dark: #6d1e14;
  --amber: #936000;
  --green: #165a38;
}

html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after {
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
  animation-duration: 0.001ms !important;
}

@media (max-width: 720px) {
  .app-shell { padding-top: 0.35rem; padding-right: 0.75rem; padding-bottom: calc(7.25rem + env(safe-area-inset-bottom)); padding-left: 0.75rem; }
  .app-footer { padding-top: 0.35rem; font-size: 0.68rem; }
  .topbar { min-height: 52px; }
  .topbar-start { gap: clamp(0.45rem, 2.3vw, 0.75rem); }
  .brand { font-size: 1.08rem; }
  .topbar-puzzle-meta { font-size: clamp(0.55rem, 2.2vw, 0.66rem); letter-spacing: 0.07em; }
  .mini-logo { width: 38px; height: 29px; }
  .header-actions { gap: 0.35rem; }
  .icon-button { width: 44px; height: 44px; font-size: 1.35rem; }
  .hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; margin: 0.3rem 0 0.7rem; }
  .hero .eyebrow { margin-bottom: 0.25rem; font-size: 0.67rem; }
  .hero h1 { margin-bottom: 0; font-size: clamp(1.55rem, 7vw, 2rem); line-height: 1.02; letter-spacing: -0.045em; }
  .hero-copy { display: none; }
  .attempt-pill { margin: 0; padding: 0.55rem 0.65rem; font-size: 0.74rem; }
  .game-layout { gap: 0.65rem; }
  .clue-panel { position: relative; border-radius: 17px; box-shadow: 0 7px 18px rgba(74,56,38,0.07); }
  .clue-toggle { padding: 0.65rem 0.8rem; }
  .clue-toggle strong { display: inline; margin-right: 0.4rem; font-size: 0.92rem; }
  .clue-toggle span span { display: none; }
  .clue-content { padding: 0.5rem 0.55rem 0.55rem; overflow: visible; }
  .clue-list { display: grid; width: 100%; max-width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0; overflow: visible; cursor: default; touch-action: auto; user-select: text; }
  .clue-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 0.42rem; align-items: start; padding: 0.55rem 0.5rem; overflow-wrap: anywhere; border-radius: 11px; background: var(--cream); font-size: var(--puzzle-text-size); line-height: 1.4; }
  .clue-number { position: static; width: 26px; height: 26px; border-radius: 8px; background: var(--paper); font-size: 0.75rem; }
  .clue-reveal { min-height: 40px; margin-top: 0.55rem; padding: 0.45rem 0.65rem; font-size: 0.78rem; }
  .clue-note { font-size: 0.72rem; }
  .hint-box { margin-top: 0.55rem; padding: 0.6rem 0.7rem; font-size: 0.82rem; }
  .hint-action { position: absolute; top: 0.34rem; right: 2.3rem; min-height: 34px; margin: 0; padding: 0.35rem 0.62rem; font-size: 0.7rem; }
  .board { padding: 0.5rem; border-radius: 17px; }
  .board { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 0.45rem; }
  .position-markers, .card-list { grid-template-columns: repeat(var(--card-count), minmax(0, 1fr)); gap: clamp(0.22rem, 1.25vw, 0.42rem); }
  .position-markers { display: grid; grid-column: 1 / -1; grid-row: 1; margin: 0 0 0.25rem; }
  .card-list { display: grid; grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .position-marker { font-size: 0.68rem; }
  .card, .drag-placeholder { min-height: clamp(104px, 29vw, 126px); border-radius: 12px; }
  .card { grid-template-rows: 1fr auto; padding: 0.25rem 0.08rem; }
  .card-art { min-height: 58px; border-radius: 8px; }
  .card-art::before { width: 38px; height: 38px; }
  .card-art::after { width: 19px; height: 19px; margin: 18px 0 0 18px; }
  .art-glyph { font-size: clamp(1.5rem, 7vw, 1.9rem); }
  .card-label { padding: 0.35rem 0 0.1rem; overflow-wrap: anywhere; white-space: normal; font-size: var(--card-label-size); line-height: 1.15; letter-spacing: -0.06em; }
  .grabber { top: 0.25rem; right: 0.35rem; font-size: 0.7rem; }
  .selected-badge { top: 0.25rem; left: 0.25rem; max-width: calc(100% - 0.5rem); overflow: hidden; padding: 0.2rem 0.25rem; font-size: 0.48rem; }
  .feedback { grid-column: 1 / -1; grid-row: 3; margin-top: 0.5rem; }
  .game-actions { position: relative; z-index: 2; grid-column: 1 / -1; grid-row: 4; align-items: stretch; flex-direction: row; gap: 0.55rem; margin: 0.65rem 0 0; }
  .game-actions > .btn { flex: 1 1 55%; min-width: 0; min-height: 48px; padding: 0.65rem 0.8rem; font-size: 0.86rem; }
  .action-group { display: flex; flex: 1 1 45%; }
  .action-group [data-action="shuffle-help"] { display: none; }
  .action-group .btn { width: 100%; min-height: 48px; padding: 0.55rem; font-size: 0.78rem; }
  .result-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .solution-order.card-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .solution-card { min-height: 112px; padding: 0.25rem 0.1rem; }
  .solution-card .card-art { min-height: 52px; }
  .solution-card .card-label { letter-spacing: 0; }
  .release-notes { align-items: stretch; margin-top: 0; padding: 0.7rem; }
  .release-notes-copy span { font-size: 0.76rem; }
  .release-notes-ok { align-self: center; }
  .welcome-modal { max-height: calc(100dvh - 1rem); padding: clamp(1rem, 5vw, 1.5rem); }
  .welcome-modal .welcome-logo { width: clamp(76px, 24vw, 104px); height: clamp(54px, 18vw, 76px); margin-bottom: 0.8rem; }
  .welcome-modal h2 { font-size: clamp(1.6rem, 8vw, 2.2rem); }
  .welcome-modal .modal-actions { display: grid; grid-template-columns: 1fr; }
  .welcome-modal .modal-actions .btn { width: 100%; }
}

@media (max-width: 380px) {
  .brand { gap: 0.45rem; font-size: 0.98rem; }
  .mini-logo { width: 34px; }
  .topbar-puzzle-meta { font-size: 0.52rem; letter-spacing: 0.035em; }
  .header-actions { gap: 0.25rem; }
  .icon-button { width: 44px; }
  .release-notes { display: grid; grid-template-columns: 1fr auto; }
}

@media (max-width: 720px) and (max-height: 740px) {
  .hero { margin-top: 0.3rem; }
  .clue-toggle { padding-block: 0.52rem; }
  .clue-content { padding-block: 0.35rem 0.4rem; }
  .card, .drag-placeholder { min-height: clamp(94px, 25vw, 108px); }
  .card-art { min-height: 50px; }
  .feedback { padding-block: 0.6rem; font-size: 0.88rem; }
}

@media (min-width: 721px) and (max-width: 940px) {
  .hero { margin: 1rem 0; }
  .hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
  .clue-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clue-list li { padding: 0.4rem; }
  .card { min-height: 145px; }
}

@media (min-width: 941px) {
  .hero { margin: 1.15rem 0 1rem; }
  .hero h1 { font-size: clamp(2.25rem, 4.2vw, 3.4rem); }
  .hero-copy { font-size: 0.95rem; }
  .game-layout { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); gap: 1rem; }
  .clue-panel { position: sticky; top: 0.75rem; grid-column: 1; grid-row: 1; }
  .board { grid-column: 2; grid-row: 1; }
  .clue-toggle { padding: 0.85rem 1rem; }
  .clue-content { padding-right: 1rem; padding-left: 1rem; }
  .clue-list { gap: 0.58rem; }
  .clue-list li { grid-template-columns: 27px minmax(0, 1fr); gap: 0.55rem; font-size: var(--puzzle-text-size); }
  .clue-number { width: 26px; height: 26px; }
  .card { min-height: 154px; }
  .card-art { min-height: 86px; }
}

@media (min-width: 760px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
