:root {
  --bg: #131a22;
  --bg-soft: #1c2633;
  --surface: #243244;
  --surface-2: #2c3d51;
  --ink: #e8eef6;
  --ink-muted: #9cb0c5;
  --accent: #f5c73d;
  --accent-2: #84d0ff;
  --ok: #59d18e;
  --danger: #ff6e6e;
  --crime-scene-font: "Teko", "Space Grotesk", sans-serif;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body.theme-light {
  --bg: #edf4fb;
  --bg-soft: #dfeaf5;
  --surface: #f4f8fc;
  --surface-2: #e8f0f8;
  --ink: #17222f;
  --ink-muted: #56718b;
  --accent: #de9f1b;
  --accent-2: #2f87d1;
  --ok: #2d9f69;
  --danger: #c74646;
  --shadow: 0 10px 26px rgba(14, 38, 62, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  color-scheme: dark;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #2c4c66 0%, transparent 26%),
    radial-gradient(circle at 90% 95%, #3b2b44 0%, transparent 30%),
    linear-gradient(175deg, #0f141a 0%, #162332 55%, #0f141a 100%);
  display: grid;
  place-items: center;
  transition: background 0.2s ease, color 0.2s ease;
}

body.theme-light {
  background:
    radial-gradient(circle at 15% 10%, #cbe3f9 0%, transparent 26%),
    radial-gradient(circle at 90% 95%, #d7e8f7 0%, transparent 30%),
    linear-gradient(175deg, #f6fbff 0%, #e9f3fb 55%, #f6fbff 100%);
}

.app-shell {
  width: min(100%, 440px);
  max-width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100svh);
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-inline: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(24, 32, 44, 0.9), rgba(13, 18, 26, 0.96));
  backdrop-filter: blur(6px);
}

body.theme-light .app-shell {
  border-inline: 1px solid rgba(26, 49, 73, 0.16);
  background: linear-gradient(180deg, rgba(240, 247, 254, 0.92), rgba(227, 239, 250, 0.96));
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(20, 28, 39, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.hud-strip {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-width: 0;
  align-items: center;
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hud-strip::-webkit-scrollbar {
  display: none;
}

body.theme-light .hud {
  background: rgba(233, 243, 251, 0.88);
  border-bottom: 1px solid rgba(26, 49, 73, 0.12);
}

.resource-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #1d2b3a;
  border: 1px solid #36495d;
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  flex-shrink: 1;
}

.hud-energy-pill {
  flex: 0 1 auto;
  max-width: 112px;
}

.hud-xp-pill {
  flex: 0.8 1 64px;
}

.hud-settings-btn {
  flex-shrink: 0;
}

.hud-regen-label {
  letter-spacing: 0;
  text-transform: uppercase;
}

body.theme-light .resource-pill {
  background: #f0f7ff;
  border: 1px solid #b7cfe7;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 400;
  font-size: 20px;
}

.screen-root {
  padding: 12px;
  overflow: hidden;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.screen-root > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.main-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.main-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.screen-root.scrollable-content {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.screen-root.scrollable-content::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.screen-root.board-content {
  overflow: hidden;
  padding: 5px;
}

.login-card {
  display: flex;
  flex-direction: column;
  max-height: calc(var(--app-height, 100dvh) - 18px);
  min-height: 0;
}

.login-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.login-body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.auth-status {
  display: none;
  text-align: left;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid rgba(245, 199, 61, 0.32);
  background: rgba(245, 199, 61, 0.1);
  color: #ffe08a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.auth-status[data-status="ok"] {
  border-color: rgba(143, 213, 171, 0.42);
  background: rgba(143, 213, 171, 0.1);
  color: #b9f2d0;
}

.password-toggle {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #b9ae91;
  background: transparent;
  cursor: pointer;
  flex: 0 0 28px;
}

.password-toggle:active {
  background: rgba(245, 199, 61, 0.13);
}

.btn.is-busy,
.btn:disabled {
  opacity: 0.72;
  cursor: wait !important;
}

.motion-comic-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(2, 5, 9, 0.78), rgba(5, 9, 14, 0.94)),
    radial-gradient(circle at 50% 8%, rgba(132, 208, 255, 0.14), transparent 34%);
  color: #f5f0e7;
}

.motion-comic-stage {
  width: min(100%, 430px);
  min-width: 0;
  display: grid;
  gap: 10px;
}

.motion-comic-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  font-family: var(--crime-scene-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 20px;
  line-height: 1;
  color: #f7d36d;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.motion-comic-photo-skip {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(10, 16, 23, 0.74);
  color: #f4f8ff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 800 11px/1 "Space Grotesk", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.motion-comic-photo-skip span {
  color: #f7d36d;
}

.motion-comic-photo-skip strong {
  font: inherit;
  color: #f4f8ff;
}

.motion-comic-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  padding: 0;
  border: 3px solid #05070a;
  border-radius: 0;
  background:
    linear-gradient(145deg, rgba(18, 27, 34, 0.94), rgba(5, 8, 12, 0.98)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 8px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.54);
  cursor: pointer;
}

.motion-comic-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.32)),
    radial-gradient(circle at 50% 50%, transparent 48%, rgba(0, 0, 0, 0.32) 100%);
  mix-blend-mode: screen;
}

.motion-comic-image,
.motion-comic-fallback {
  position: absolute;
  inset: 0;
}

.motion-comic-image {
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
}

.motion-comic-image.is-missing {
  display: none;
}

.motion-comic-fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  color: #dfe9f4;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(8, 13, 18, 0.95), rgba(25, 35, 45, 0.92)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 12px);
}

.motion-comic-fallback span {
  font-family: var(--crime-scene-font);
  font-size: 42px;
  line-height: 1;
  color: rgba(245, 199, 61, 0.86);
}

.motion-comic-fallback strong {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.motion-comic-fallback small {
  max-width: 100%;
  color: #9fb4c8;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.motion-comic-caption {
  border: 2px solid #05070a;
  background: #f6f2e8;
  color: #0c1015;
  padding: 10px 12px 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.42);
}

.motion-comic-caption p {
  margin: 8px 0 0;
  font-family: var(--crime-scene-font);
  font-size: clamp(20px, 6vw, 28px);
  line-height: 0.98;
  letter-spacing: 0;
  text-transform: uppercase;
}

.motion-comic-progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.motion-comic-progress span {
  height: 4px;
  background: rgba(12, 16, 21, 0.18);
}

.motion-comic-progress span.is-active {
  background: #0c1015;
}

.motion-comic-panel-zoom {
  animation: motionComicZoom 5s ease-out both;
}

.motion-comic-panel-pan-right {
  animation: motionComicPanRight 5s ease-out both;
}

.motion-comic-panel-shake {
  animation: motionComicShake 5s ease-in-out both;
}

body.reduce-motion .motion-comic-image {
  animation: none !important;
  transform: none !important;
}

.case-stage-reveal-overlay {
  position: absolute;
  inset: 0;
  z-index: 34;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgba(246, 211, 129, 0.22), transparent 34%),
    rgba(5, 10, 17, 0.72);
  backdrop-filter: blur(4px);
}

.case-stage-reveal-card {
  width: min(92vw, 380px);
  border: 1px solid rgba(246, 211, 129, 0.48);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(170deg, rgba(24, 39, 54, 0.98), rgba(10, 18, 28, 0.98));
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.54);
  animation: caseStageRevealIn 420ms cubic-bezier(.18, .86, .24, 1) both;
}

.case-stage-reveal-image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #090f17;
}

.case-stage-reveal-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: caseStagePhotoZoom 2800ms ease-out both;
}

.case-stage-reveal-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(126, 211, 252, 0.34) 48%, transparent 58%);
  mix-blend-mode: screen;
  transform: translateY(-100%);
  animation: caseStageScan 1500ms ease-in-out 180ms both;
}

.case-stage-reveal-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 239, 190, 0.82);
  color: #241704;
  background: linear-gradient(180deg, #ffe59a, #d8a33c);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.42);
  animation: caseStageBadgePop 520ms cubic-bezier(.2, .9, .2, 1.25) 260ms both;
}

.case-stage-reveal-badge i {
  font-size: 22px;
}

.case-stage-reveal-copy {
  padding: 16px 16px 12px;
  text-align: center;
}

.case-stage-reveal-copy span {
  display: block;
  margin-bottom: 5px;
  color: #8fd0ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.case-stage-reveal-copy h3 {
  margin: 0;
  color: #fff7df;
  font-size: 22px;
  line-height: 1.12;
}

.case-stage-reveal-copy p {
  margin: 8px 0 0;
  color: #c9d8e7;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
}

.case-stage-reveal-card .btn {
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  border-radius: 14px;
  font-weight: 800;
}

body.reduce-motion .case-stage-reveal-card,
body.reduce-motion .case-stage-reveal-image,
body.reduce-motion .case-stage-reveal-scan,
body.reduce-motion .case-stage-reveal-badge {
  animation: none !important;
}

@keyframes caseStageRevealIn {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes caseStagePhotoZoom {
  from { transform: scale(1.08); filter: saturate(0.9) brightness(0.78); }
  to { transform: scale(1); filter: saturate(1.06) brightness(1); }
}

@keyframes caseStageScan {
  0% { transform: translateY(-100%); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(100%); opacity: 0; }
}

@keyframes caseStageBadgePop {
  from { opacity: 0; transform: scale(0.5) rotate(-12deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes motionComicZoom {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@keyframes motionComicPanRight {
  from { transform: scale(1.08) translateX(-2.5%); }
  to { transform: scale(1.08) translateX(2.5%); }
}

@keyframes motionComicShake {
  0%, 100% { transform: scale(1.04) translateX(0); }
  18% { transform: scale(1.04) translateX(-5px); }
  36% { transform: scale(1.04) translateX(5px); }
  54% { transform: scale(1.04) translateX(-3px); }
  72% { transform: scale(1.04) translateX(3px); }
}

.card {
  background: linear-gradient(180deg, rgba(41, 57, 76, 0.9), rgba(26, 37, 50, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease;
}

body.theme-light .card {
  background: linear-gradient(180deg, rgba(247, 252, 255, 0.95), rgba(236, 246, 255, 0.98));
  border: 1px solid rgba(74, 110, 146, 0.2);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #1b1d24;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

input,
textarea,
select,
button {
  font: inherit;
}

input {
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  color: inherit;
  caret-color: var(--accent);
}

input::-ms-reveal,
input::-ms-clear {
  display: none;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: #f8f6ef;
  caret-color: #f5c73d;
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px transparent inset;
}

.bottom-nav {
  display: block;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 21, 30, 0.95);
  min-width: 0;
  max-width: 100%;
  min-height: 52px;
  flex: 0 0 auto;
  overflow: hidden;
  position: relative;
  z-index: 20;
}

body.theme-light .bottom-nav {
  border-top: 1px solid rgba(26, 49, 73, 0.15);
  background: rgba(236, 246, 255, 0.96);
}

body.theme-light .board-grid {
  background: #dfeaf6;
  border-color: #aac1d8;
  box-shadow: inset 0 4px 10px rgba(30, 52, 76, 0.12), 0 3px 7px rgba(17, 34, 52, 0.1);
}

body.theme-light .board-cell {
  background: #c9dbec;
  border-color: #9eb8d2;
  box-shadow: 0 2px 4px rgba(40, 62, 85, 0.14), inset 0 1px 2px rgba(255,255,255,0.45);
}

body.theme-light .orders-container .request-panel {
  background: #f3f8fd !important;
  border-color: rgba(53, 88, 124, 0.22) !important;
}

body.theme-light .req-chip {
  background: rgba(208, 224, 240, 0.88) !important;
  color: #1b2f44;
}

body.theme-light .nav-btn {
  color: #23445f;
}

.nav-btn {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #d6e6f7;
  padding: 6px 2px;
  font-family: inherit;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  line-height: 1.1;
}

.nav-icon {
  display: block;
  width: 21px;
  height: 21px;
  min-width: 21px;
  min-height: 21px;
  margin-bottom: 2px;
  color: currentColor;
  fill: currentColor;
  stroke: none;
  flex: 0 0 auto;
  opacity: 1;
  filter: none;
}

.nav-btn span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn.active {
  color: var(--accent);
}

.tab-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
  margin-bottom: 4px;
}

.tab-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px 3px 4px;
  background: rgba(18, 43, 64, 0.9);
  border: 1px solid rgba(124, 194, 255, 0.28);
  color: #ecf4ff;
  font-size: 11px;
  font-weight: 700;
  max-width: 56%;
}

.tab-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #173249;
  background: #9fd2ff;
}

.tab-profile-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-xp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(18, 43, 64, 0.9);
  border: 1px solid rgba(124, 194, 255, 0.35);
  color: #ecf4ff;
  font-size: 11px;
  font-weight: 700;
}

.tab-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  min-width: 0;
}

body.theme-light .tab-profile-chip,
body.theme-light .tab-xp-chip {
  background: rgba(219, 236, 251, 0.95);
  border-color: rgba(76, 126, 172, 0.35);
  color: #1a3852;
}

body.theme-light .tab-avatar {
  color: #f8fbff;
  background: #2f87d1;
}

.nav-btn.active {
  color: var(--accent);
  background: rgba(245, 199, 61, 0.1);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  align-items: center;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-track::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f2f6fb;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch-input:checked + .switch-track {
  background: rgba(245, 199, 61, 0.4);
  border-color: rgba(245, 199, 61, 0.7);
}

.switch-input:checked + .switch-track::after {
  transform: translateX(20px);
  background: #ffe08a;
}

body.theme-light .switch-track {
  background: rgba(26, 49, 73, 0.2);
  border-color: rgba(26, 49, 73, 0.2);
}

body.theme-light .switch-input:checked + .switch-track {
  background: rgba(222, 159, 27, 0.35);
  border-color: rgba(222, 159, 27, 0.7);
}

.section-title {
  margin: 0 0 10px;
  font-size: 18px;
}

.intro-wrap {
  min-height: var(--app-height, 100svh);
  display: grid;
  place-items: center;
  padding: 9px;
  overflow: hidden;
}

.intro-card {
  width: min(96vw, 430px);
  height: min(calc(var(--app-height, 100svh) - 18px), 820px);
  max-height: calc(var(--app-height, 100svh) - 18px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 16px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(3, 8, 15, 0.36), rgba(4, 12, 23, 0.86)),
    url("./assets/backgrounds/loading.webp") center center/cover no-repeat;
  border: 1px solid rgba(138, 177, 212, 0.42);
  box-shadow: inset 0 0 0 1px rgba(34, 71, 106, 0.34), 0 20px 54px rgba(0, 0, 0, 0.58);
  position: relative;
  overflow: hidden;
}

.intro-card::before {
  content: none;
}

.intro-identity {
  min-height: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px 8px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.intro-title {
  margin: 0;
  text-align: center;
  font-size: clamp(38px, 11vw, 54px);
  letter-spacing: 1px;
  font-weight: 900;
  line-height: 0.86;
  color: #f0d38f;
  text-transform: uppercase;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 1;
}

.intro-title::after {
  content: none;
}

.intro-identity span {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1.6px;
  color: #e6f0fb;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.58);
}

.intro-identity small {
  font-size: 15px;
  font-weight: 900;
  color: #9ce8ff;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.68);
}

.loader-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 18px 8px;
  position: relative;
  z-index: 1;
}

.loader-compass {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f0d38f;
  background:
    radial-gradient(circle at 50% 50%, rgba(240, 211, 143, 0.14), transparent 36%),
    rgba(5, 15, 27, 0.78);
  border: 1px solid rgba(240, 211, 143, 0.58);
  box-shadow: inset 0 0 0 1px rgba(132, 208, 255, 0.12), 0 10px 22px rgba(0, 0, 0, 0.42);
  animation: compassSpin 1.45s linear infinite;
}

.loader-compass i {
  font-size: 36px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.loader-copy {
  display: grid;
  gap: 4px;
  text-align: center;
}

.loader-copy span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.4px;
  color: #e6f0fb;
}

.loader-copy small {
  font-size: 10px;
  font-weight: 800;
  color: #9ce8ff;
}

.route-loader-card {
  width: min(88vw, 260px);
  border-radius: 22px;
  border: 1px solid rgba(132, 208, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(7, 17, 29, 0.92), rgba(7, 13, 22, 0.96)),
    radial-gradient(circle at 50% 0%, rgba(240, 211, 143, 0.16), transparent 44%);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
  padding: 24px 18px 18px;
}

.intro-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 10px;
  font-size: 10px;
  color: #e6f0fb;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 800;
  line-height: 1;
  font-family: "Space Grotesk", sans-serif;
}

.progress-wrapper.intro-progress {
  margin-top: auto;
  background: rgba(4, 14, 26, 0.84);
  border: 1px solid rgba(108, 145, 182, 0.65);
  border-radius: 18px;
  padding: 11px 13px 12px;
  box-shadow: 0 -1px 0 rgba(234, 192, 111, 0.7), 0 12px 20px rgba(0, 0, 0, 0.44);
  position: relative;
  z-index: 1;
}

.intro-progress .progress-rail {
  height: 14px;
  background: rgba(3, 9, 17, 0.98);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(151, 194, 228, 0.56);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(8, 33, 53, 0.7);
}

.intro-progress .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #56baf2, #9ce8ff 52%, #daf7ff);
  box-shadow: 0 0 12px rgba(154, 232, 255, 0.86);
  transition: width 0.18s linear;
  position: relative;
}

.intro-progress .progress-fill::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -3px;
  width: 24px;
  height: 18px;
  background: radial-gradient(circle, rgba(188, 240, 255, 0.88), rgba(188, 240, 255, 0));
  filter: blur(1px);
}

.progress-rail {
  height: 10px;
  background: #17222f;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e8ba3a, #ffe7a5);
  box-shadow: 0 0 10px rgba(245, 199, 61, 0.45);
}

@media (max-width: 420px) {
  .intro-card {
    height: min(calc(var(--app-height, 100svh) - 16px), 800px);
    border-radius: 22px;
    padding: 14px;
  }

  .intro-title {
    font-size: clamp(36px, 12vw, 50px);
  }

  .intro-progress .progress-rail {
    height: 13px;
  }
}

body.board-grid-off .board-grid {
  background: #0f1b29;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 4px 8px rgba(0,0,0,0.45);
}

body.board-grid-off .board-cell {
  box-shadow: none;
}

body.reduce-motion * {
  animation: none !important;
  transition: none !important;
}

@keyframes compassSpin {
  to {
    transform: rotate(360deg);
  }
}

body.low-performance .hud,
body.low-performance .card,
body.low-performance .board-case-panel-wrap .card,
body.low-performance .crime-icon-balloon .balloon-body {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.low-performance .board-grid,
body.low-performance .board-cell,
body.low-performance .item-chip,
body.low-performance .request-panel,
body.low-performance .case-stage-reveal-card {
  box-shadow: none !important;
}

body.low-performance .item-art,
body.low-performance .item-art-fallback,
body.low-performance .req-chip .item-art,
body.low-performance .request-character img,
body.low-performance .crime-icon-balloon,
body.low-performance .marker-icon,
body.low-performance .wp-letter-tile {
  filter: none !important;
}

/* Keep the 8x8 board cheap to repaint on entry-level phones. Its many small
   gradients and cell transitions look subtle, but repaint together while a
   finger drags across the grid. The board layout and colors stay the same. */
body.low-performance .board-grid {
  background-image: none !important;
  background-color: #172832 !important;
}
body.low-performance .board-cell,
body.low-performance .board-grid .board-cell.covered-item {
  background-image: none !important;
  background-color: #283f48 !important;
  transition: none !important;
}
body.low-performance .board-cell.selected {
  transform: none !important;
}

body.low-performance .screen-enter,
body.low-performance .motion-comic-image,
body.low-performance .case-stage-reveal-card,
body.low-performance .case-stage-reveal-image,
body.low-performance .case-stage-reveal-scan,
body.low-performance .case-stage-reveal-badge {
  animation: none !important;
  transition: none !important;
}

@media (max-width: 640px) {
  .board-grid,
  .board-cell,
  .item-chip {
    box-shadow: none;
  }

  .item-art,
  .req-chip .item-art {
    filter: none;
  }
}

.info-grid {
  display: grid;
  gap: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.map-zones {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.zone {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  background: rgba(28, 42, 56, 0.88);
}

.zone.locked {
  opacity: 0.58;
  filter: grayscale(0.3);
}

.map-scene {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #0f1b27;
}

.map-bg-base,
.map-bg-vignette,
.map-bg-grid,
.map-bg-highlight {
  position: absolute;
  inset: 0;
}

.map-bg-base {
  background: url("./assets/backgrounds/map.webp") center / cover no-repeat;
}

.map-bg-vignette {
  background: radial-gradient(circle at 24% 10%, rgba(97, 157, 215, 0.12) 0%, rgba(12, 20, 30, 0.34) 55%, rgba(7, 12, 18, 0.5) 100%);
}

.map-bg-grid {
  background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.12;
}

.map-bg-highlight {
  background: radial-gradient(circle at 82% 28%, rgba(255, 210, 122, 0.18) 0%, transparent 45%);
}

.map-crime-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.crime-icon-balloon {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 70px;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  animation: marker-fade-in 0.3s ease-out;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.crime-icon-balloon.size-sm {
  width: 62px;
}

.crime-icon-balloon.size-md {
  width: 70px;
}

.crime-icon-balloon.size-lg {
  width: 80px;
}

.balloon-body {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 100%;
  padding: 5px 5px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(20, 30, 45, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.18), inset 0 0 5px rgba(255, 255, 255, 0.08);
}

.balloon-body::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(255, 255, 255, 0.16);
  filter: drop-shadow(0 2px 5px rgba(255, 255, 255, 0.22));
}

.marker-title {
  font-family: var(--crime-scene-font);
  font-size: 9px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.marker-subtitle {
  margin-top: -2px;
  font-size: 7px;
  line-height: 1.1;
  color: rgba(234, 245, 255, 0.76);
  letter-spacing: 0.25px;
}

.marker-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.marker-icon i {
  font-size: 13px;
  color: #fff;
  text-shadow: 0 0 9px rgba(255, 255, 255, 0.72);
}

.crime-lock-note {
  margin-top: 1px;
  font-family: var(--crime-scene-font);
  font-size: 8px;
  color: rgba(255, 214, 153, 0.92);
  letter-spacing: 0.25px;
  font-weight: 700;
}

.crime-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(10, 17, 27, 0.55);
  color: #d5e7fa;
  font-family: var(--crime-scene-font);
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.25px;
}

.crime-police-tape {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  z-index: 2;
  display: inline-flex;
  width: 122%;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid rgba(32, 21, 0, 0.6);
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 212, 84, 0.94) 0 10px,
      rgba(22, 22, 22, 0.9) 10px 15px
    );
  color: #170e00;
  text-shadow: none;
  font-family: var(--crime-scene-font);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  pointer-events: none;
}

.crime-police-tape i {
  font-size: 9px;
}

.crime-icon-balloon.tone-fire .balloon-body {
  border-color: rgba(255, 122, 122, 0.48);
  box-shadow: 0 0 18px rgba(255, 118, 118, 0.32), inset 0 0 5px rgba(255, 163, 163, 0.11);
}

.crime-icon-balloon.tone-fire .marker-icon i {
  color: #ff7e7e;
  text-shadow: 0 0 12px rgba(255, 98, 98, 0.92);
}

.crime-icon-balloon.tone-diamond .marker-icon i {
  color: #d6ecff;
}

.crime-icon-balloon.tone-theft .marker-icon i,
.crime-icon-balloon.tone-assault .marker-icon i {
  color: #f8fbff;
}

.crime-icon-balloon:hover,
.crime-icon-balloon:focus-visible {
  transform: translate(-50%, -50%) scale(1.05);
  outline: none;
}

.crime-icon-balloon.is-locked,
.crime-icon-balloon:disabled {
  cursor: not-allowed;
  opacity: 0.68;
  filter: grayscale(0.58);
}

/* Word Puzzle: image assets are raw frames only; content is HTML/CSS. */
.word-puzzle-screen {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  background: #101923;
  color: #f7ead1;
}

.wp-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(118px, 31%) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "label label"
    "left answer"
    "left board"
    "actions actions";
  gap: 10px;
  width: 100%;
  max-width: 760px;
  min-height: auto;
  margin: 0 auto;
  padding: 0 0 84px;
  overflow: visible;
  background:
    radial-gradient(circle at 50% 12%, rgba(26, 51, 65, 0.5), transparent 38%),
    linear-gradient(180deg, #111d27 0%, #0a1118 100%);
  box-sizing: border-box;
}

.wp-stage.is-clue-collapsed {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "label"
    "left"
    "answer"
    "board"
    "actions";
}

.wp-back,
.wp-title-bar,
.wp-center-label,
.wp-left-panel,
.wp-answer-panel,
.wp-letter-board,
.wp-actions {
  position: relative;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  width: auto;
  height: auto;
}

.wp-back {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 46px;
  height: 46px;
  z-index: 8;
  border: 1px solid rgba(221, 199, 157, 0.42);
  border-radius: 8px;
  background: linear-gradient(180deg, #20272d, #0b0f14);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.45), 0 6px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.wp-back::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 13px;
  width: 16px;
  height: 16px;
  border-left: 5px solid #f3d99b;
  border-bottom: 5px solid #f3d99b;
  transform: rotate(45deg);
}

.wp-title-bar {
  grid-area: top;
  min-height: 52px;
  margin-left: 58px;
  display: grid;
  place-items: center;
  padding: 8px 16px;
  border: 1px solid rgba(176, 119, 53, 0.7);
  border-radius: 6px;
  background: linear-gradient(180deg, #d9b87d 0%, #9b6c38 56%, #3b2312 100%);
  color: #261607;
  box-shadow: inset 0 0 0 2px rgba(255, 233, 177, 0.18), 0 8px 18px rgba(0, 0, 0, 0.45);
}

.wp-title-bar span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 950;
  text-transform: uppercase;
}

.wp-title-plaque { display: none; }

.wp-center-label {
  grid-area: label;
  justify-self: center;
  min-width: min(78%, 360px);
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 7px 18px;
  border: 1px solid rgba(156, 97, 41, 0.75);
  border-radius: 5px;
  background: linear-gradient(180deg, #e4c78b, #aa7434 55%, #4f2b16);
  color: #6e190e;
  box-shadow: 0 7px 14px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.18);
}

.wp-center-label span,
.wp-panel-title {
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 2px 3px rgba(0,0,0,0.75);
}

.wp-answer-panel,
.wp-letter-board {
  border-style: solid;
  border-color: transparent;
  background: linear-gradient(180deg, rgba(11, 24, 34, 0.96), rgba(5, 10, 15, 0.98)) padding-box;
  box-shadow: 0 10px 18px rgba(0,0,0,0.5);
}

.wp-answer-panel {
  grid-area: answer;
  min-height: 126px;
  padding: 30px 24px 22px;
  border-width: 28px 34px;
  border-image: url("./assets/word-puzzle/minimal/answer-panel.webp") 62 92 fill / 28px 34px stretch;
}

.wp-panel-title {
  display: block;
  margin: -14px 0 14px;
  color: #d9ad54;
  font-size: 12px;
}

.wp-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.7vw, 12px);
  min-height: 48px;
}

.wp-answer-slot {
  width: clamp(24px, 6.8vw, 54px);
  aspect-ratio: 1;
  border: 1px solid rgba(183, 223, 255, 0.95);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(13, 28, 39, 0.98), rgba(2, 8, 13, 0.98));
  color: #f8df9d;
  box-shadow: inset 0 0 12px rgba(95, 166, 218, 0.22), 0 0 12px rgba(111, 193, 255, 0.48);
  display: grid;
  place-items: center;
  font-size: clamp(16px, 4.6vw, 32px);
  font-weight: 950;
}

.wp-letter-board {
  grid-area: board;
  min-height: 390px;
  padding: 34px 18px 24px;
  border-width: 32px 24px;
  border-image: url("./assets/word-puzzle/minimal/letter-board.webp") 74 58 fill / 32px 24px stretch;
}

.wp-letter-board .wp-panel-title {
  margin-top: -22px;
}

.wp-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(7px, 1.8vw, 16px);
  align-items: center;
  justify-items: center;
}

.wp-letter-tile {
  width: min(100%, 66px);
  aspect-ratio: 80 / 87;
  border: 0;
  background: url("./assets/word-puzzle/minimal/letter-tile.webp") center/100% 100% no-repeat;
  color: #21160c;
  display: grid;
  place-items: center;
  font-size: clamp(17px, 4.8vw, 32px);
  font-weight: 950;
  filter: drop-shadow(0 6px 5px rgba(0,0,0,0.45));
  cursor: pointer;
}

.wp-letter-tile:disabled { opacity: 0.32; cursor: default; }

.wp-left-panel {
  grid-area: left;
  align-self: stretch;
  min-height: 230px;
  padding: 24px 14px 18px;
  border: 26px solid transparent;
  border-image: url("./assets/word-puzzle/minimal/left-notebook.webp") 58 42 62 56 fill / 26px 22px 28px 30px stretch;
  background: linear-gradient(180deg, #d8bf91, #c59e68) padding-box;
  color: #21170e;
  box-shadow: inset 0 0 26px rgba(70, 41, 21, 0.45), 0 8px 18px rgba(0,0,0,0.42);
}

.wp-left-header {
  margin: 0 0 18px;
  background: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wp-left-panel h2 {
  flex: 1;
  margin: 0;
  padding: 8px 10px;
  background: #11161a;
  color: #e3d5bd;
  font-size: 18px;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
}
.wp-left-panel h2::after { content: none; }

.wp-clue-toggle {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(43, 29, 16, 0.48);
  border-radius: 6px;
  background: linear-gradient(180deg, #f0d59e, #9d6b31);
  box-shadow: inset 0 0 0 1px rgba(255, 242, 190, 0.32), 0 4px 8px rgba(0,0,0,0.28);
  cursor: pointer;
}

.wp-clue-toggle span {
  display: block;
  width: 10px;
  height: 10px;
  margin: 7px auto 0;
  border-right: 3px solid #24170e;
  border-bottom: 3px solid #24170e;
  transform: rotate(45deg);
}

.wp-left-panel.is-collapsed {
  min-height: 78px;
  padding-bottom: 18px;
}

.wp-stage.is-clue-collapsed .wp-left-panel {
  min-height: 64px;
  padding: 16px 18px;
}

.wp-left-panel.is-collapsed .wp-left-header {
  margin-bottom: 0;
}

.wp-left-panel.is-collapsed .wp-left-content {
  display: none;
}

.wp-stage.is-clue-collapsed .wp-left-header {
  justify-content: space-between;
}

.wp-stage.is-clue-collapsed .wp-left-panel h2 {
  max-width: 260px;
}

.wp-stage.is-clue-collapsed .wp-answer-panel,
.wp-stage.is-clue-collapsed .wp-letter-board {
  width: 100%;
}

.wp-stage.is-clue-collapsed .wp-letter-tile {
  width: min(100%, 78px);
  font-size: clamp(20px, 5.8vw, 36px);
}

.wp-left-panel.is-collapsed .wp-clue-toggle span {
  margin-top: 10px;
  transform: rotate(-135deg);
}

.wp-left-content {
  min-height: 154px;
  display: flex;
  flex-direction: column;
}

.wp-left-content p {
  margin: 0;
  color: #120e0b;
  font-size: clamp(12px, 3.2vw, 15px);
  line-height: 1.35;
  font-weight: 800;
}

.wp-left-content strong {
  margin-top: auto;
  color: #24170e;
  font-size: 14px;
  font-weight: 950;
}

.wp-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 58px;
}

.wp-action-btn {
  min-width: 0;
  border: 12px solid transparent;
  border-image: linear-gradient(180deg, rgba(255,255,255,0.3), rgba(0,0,0,0.55)) 12 stretch;
  border-radius: 5px;
  color: #fff8dd;
  font-size: clamp(11px, 3.3vw, 16px);
  font-weight: 950;
  line-height: 1.05;
  text-shadow: 0 2px 3px rgba(0,0,0,0.85);
  box-shadow: 0 7px 14px rgba(0,0,0,0.42), inset 0 0 0 2px rgba(0,0,0,0.35);
  cursor: pointer;
}
.wp-red { background: linear-gradient(180deg, #6e1e18, #310b08); }
.wp-yellow { background: linear-gradient(180deg, #6e4714, #2f1b06); }
.wp-green { background: linear-gradient(180deg, #155b20, #06270d); }
.wp-blue { background: linear-gradient(180deg, #123756, #061622); }

@media (min-width: 860px) {
  .wp-stage {
    max-width: 1180px;
    grid-template-columns: 26% minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "label label"
      "left answer"
      "left board"
      "actions actions";
    align-items: start;
    gap: 14px;
  }

  .wp-back { top: 8px; left: 8px; }
  .wp-title-bar { grid-area: top; margin-left: 58px; max-width: 390px; }
  .wp-center-label { grid-area: label; }
  .wp-left-panel { grid-area: left; min-height: 610px; }
  .wp-left-panel.is-collapsed { min-height: 96px; }
  .wp-answer-panel { grid-area: answer; min-height: 170px; }
  .wp-letter-board { grid-area: board; min-height: 430px; }
  .wp-actions { grid-area: actions; width: min(760px, 100%); justify-self: center; }

  .wp-stage.is-clue-collapsed {
    grid-template-columns: minmax(0, 1fr);
    max-width: 880px;
  }
}

/* Final compact wide Word Puzzle layout: drawer clue, full-width board. */
.word-puzzle-screen {
  height: 100%;
  overflow: hidden;
  padding: 8px;
}

.wp-stage,
.wp-stage.is-clue-collapsed {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* Four rows only: the clue drawer is an overlay and reserves no space of its
     own, which is what used to leave a large empty gold bar under the answer. */
  grid-template-rows: 38px clamp(88px, 12.4dvh, 104px) minmax(0, 1fr) clamp(56px, 7.6%, 64px);
  grid-template-areas:
    "label"
    "answer"
    "board"
    "actions";
  gap: clamp(8px, 1dvh, 11px);
  width: 100%;
  max-width: 760px;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

.wp-title-bar {
  display: none;
}

.wp-back {
  left: 4px;
  top: 0;
  width: 40px;
  height: 38px;
}

.wp-back::before {
  left: 15px;
  top: 11px;
  width: 14px;
  height: 14px;
  border-left-width: 4px;
  border-bottom-width: 4px;
}

.wp-center-label {
  grid-area: label;
  justify-self: center;
  align-self: center;
  min-width: min(62%, 310px);
  min-height: 32px;
  padding: 4px 14px;
}

.wp-center-label span {
  font-size: clamp(12px, 3.2vw, 18px);
}

.wp-answer-panel {
  grid-area: answer;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  min-height: 0;
  padding: clamp(18px, 2.8dvh, 24px) clamp(16px, 4vw, 28px) clamp(12px, 1.7dvh, 18px);
  border-width: 24px 30px;
  border-image: url("./assets/word-puzzle/minimal/answer-panel.webp") 62 92 fill / 24px 30px stretch;
}

.wp-panel-title {
  margin: -12px 0 clamp(8px, 1.2dvh, 12px);
  font-size: clamp(10px, 2.7vw, 13px);
}

.wp-slots {
  --wp-slot-count: 5;
  /* Slot size is derived from the PANEL's inner width (the stage is capped at
     760px and the answer panel carries a 30px border each side), divided by the
     actual letter count, and clamped so every word from 3 to 10 letters fits the
     row without ever cropping. The height cap keeps the row inside the panel on
     short screens. */
  --wp-slot-size: clamp(
    26px,
    min(calc((min(100vw, 760px) - 104px - (var(--wp-slot-count) - 1) * 6px) / var(--wp-slot-count)), calc((100dvh - 430px) * 0.5)),
    52px
  );
  display: flex;
  flex-wrap: nowrap;
  min-height: 0;
  height: 100%;
  gap: clamp(3px, 1vw, 6px);
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
}

.wp-answer-slot {
  flex: 0 0 var(--wp-slot-size);
  width: var(--wp-slot-size);
  height: var(--wp-slot-size);
  aspect-ratio: 1;
  max-height: none;
  line-height: 1;
  font-size: clamp(14px, calc(var(--wp-slot-size) * 0.62), 30px);
}

.wp-answer-slot span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  line-height: 1;
}

.wp-letter-board {
  grid-area: board;
  min-height: 0;
  height: 100%;
  padding: clamp(16px, 2.1dvh, 22px) clamp(18px, 4vw, 28px) clamp(16px, 2.2dvh, 22px);
  border-width: 30px 24px;
  border-image: url("./assets/word-puzzle/minimal/letter-board.webp") 74 58 fill / 30px 24px stretch;
  box-shadow: none;
  align-self: start;
  overflow: hidden;
  z-index: 1;
}

.wp-stage.is-clue-collapsed .wp-letter-board {
  min-height: 0;
  height: 100%;
}

.wp-letter-board .wp-panel-title {
  margin-top: -10px;
  margin-bottom: clamp(7px, 1dvh, 10px);
}

.wp-tiles {
  height: calc(100% - 22px);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(3px, 0.7dvh, 6px) clamp(5px, 1.7vw, 11px);
  align-content: space-evenly;
  padding-top: 0;
}

.wp-letter-tile,
.wp-stage.is-clue-collapsed .wp-letter-tile {
  width: min(100%, clamp(46px, 10.2vw, 54px));
  font-size: clamp(17px, 4.8vw, 28px);
}

.wp-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  position: relative;
  min-height: 0;
  height: 100%;
  margin-top: 0;
  align-self: start;
  gap: clamp(5px, 1.8vw, 9px);
  z-index: 2;
}

.wp-action-btn {
  position: relative;
  /* Icon over label: four buttons across a 360px phone get ~78px each, which
     never fits "KONTROL ET" beside an icon on one line. Stacking the icon above
     the label keeps every label on ONE line at a readable size, and matches the
     button assets in the pack, which are composed as tall plates. */
  flex-direction: column;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 0;
  border-width: 4px;
  border-image: none;
  border-radius: 10px;
  padding: clamp(4px, 0.7dvh, 7px) clamp(4px, 1.2vw, 8px);
  font-size: clamp(9.5px, 2.6vw, 12.5px);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.02em;
  box-shadow: none;
}

.wp-action-btn i { font-size: clamp(13px, 3.4vw, 17px); }

.wp-action-btn span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-hint-badge {
  position: absolute;
  left: -5px;
  top: -7px;
  z-index: 3;
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border: 2px solid rgba(255, 230, 205, 0.86);
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4f42, #9c1510);
  color: #fff7e6;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0,0,0,0.45);
  text-shadow: none;
}

.wp-action-btn i {
  flex: 0 0 auto;
  font-size: 1.08em;
  line-height: 1;
}

.wp-action-btn span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.08;
}

.wp-hint-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-left: 3px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #ffe8a8;
  font-size: 0.78em;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  vertical-align: baseline;
}

.wp-hint-cost i {
  color: #ffd34f;
  font-size: 0.88em;
}

.wp-clue-tab {
  position: absolute;
  left: 0;
  top: clamp(82px, 15dvh, 122px);
  z-index: 18;
  width: 34px;
  height: 128px;
  border: 1px solid rgba(43, 29, 16, 0.5);
  border-radius: 0 8px 8px 0;
  background: linear-gradient(180deg, #f0d59e, #9d6b31);
  color: #24170e;
  font-weight: 950;
  font-size: 11px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 12px rgba(0,0,0,0.38);
  cursor: pointer;
}

.wp-stage:not(.is-clue-collapsed) .wp-clue-tab {
  display: none;
}

.wp-left-panel,
.wp-stage.is-clue-collapsed .wp-left-panel {
  position: absolute;
  left: 8px;
  top: 48px;
  z-index: 20;
  width: min(310px, calc(100% - 20px));
  height: calc(100% - 116px);
  min-height: 0;
  padding: 14px 22px 18px;
  transform: translateX(0);
  /* The clue drawer wears the notebook asset from the pack, as designed, instead
     of a bare gradient: it is a file on the detective's desk, not a dialog. */
  background: url("./assets/word-puzzle/minimal/left-notebook.webp") center / 100% 100% no-repeat,
    linear-gradient(180deg, #233041, #16222e);
  border: 1px solid rgba(225, 191, 127, 0.4);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
}

.wp-stage .wp-left-panel.is-collapsed,
.wp-stage.is-clue-collapsed .wp-left-panel.is-collapsed {
  pointer-events: none;
  transform: translateX(calc(-100% - 16px));
}

.wp-left-panel.is-collapsed .wp-left-content {
  display: none;
}

.wp-left-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 58px;
  gap: 6px;
  margin: 0 0 18px;
}

.wp-left-panel h2 {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 3px 8px 0;
  border-radius: 2px;
  background: transparent;
  color: #eadcc5;
}

.wp-left-panel h2 span {
  line-height: 1;
}

.wp-left-panel h2 small {
  display: block;
  max-width: 100%;
  color: #f2dfbf;
  font-size: clamp(12px, 3.15vw, 15px);
  font-weight: 900;
  line-height: 1.22;
  text-transform: none;
  text-align: center;
  text-shadow: none;
}

.wp-clue-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(225, 191, 127, 0.48);
  border-radius: 8px;
  background: linear-gradient(180deg, #d8b66f, #9a6a31);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
}

.wp-clue-toggle span {
  display: block;
  width: 10px;
  height: 10px;
  margin: 0;
  border-top: 3px solid #21150d;
  border-right: 3px solid #21150d;
  border-bottom: 0;
  border-left: 0;
  transform: rotate(45deg) translate(-1px, 1px);
}

.wp-left-content {
  min-height: 0;
  height: calc(100% - 76px);
}

.wp-left-content p {
  display: none;
}

@media (min-width: 860px) {
  .wp-stage,
  .wp-stage.is-clue-collapsed {
    max-width: 920px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "label"
      "answer"
      "board"
      "actions";
  }
}
.case-solved-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-16deg);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 236px;
  padding: 7px 14px;
  border: 2px solid rgba(161, 86, 72, 0.72);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(238, 209, 183, 0.9), rgba(228, 193, 164, 0.88));
  color: rgba(126, 36, 36, 0.92);
  font-family: var(--crime-scene-font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 243, 230, 0.72),
    inset 0 -1px 0 rgba(153, 87, 74, 0.24);
  text-shadow: 0 1px 0 rgba(255, 230, 218, 0.58);
  opacity: 0.95;
  pointer-events: none;
}

@keyframes marker-fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: min(100%, var(--board-grid-width, var(--board-grid-size, calc(100dvh - 278px))));
  height: min(100%, var(--board-grid-height, var(--board-grid-size, calc(100dvh - 278px))));
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  min-height: 0;
  align-self: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: #112031;
  border: 1px solid #2f4458;
  box-shadow: inset 0 6px 12px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
  touch-action: none;
  transform: scaleX(var(--board-grid-scale-x, 1));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-origin: center center;
}

.board-section {
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.board-root {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.board-playfield {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}

.board-field-ops-slot {
  flex: 0 0 auto;
  padding-bottom: 2px;
}

.board-case-panel-wrap {
  min-height: 0;
  max-width: min(190px, 44vw);
}

.orders-container {
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  touch-action: pan-x;
  max-width: 100%;
  min-width: 0;
}

.orders-container .request-panel,
.orders-container .request-panel button {
  pointer-events: auto;
}

.orders-container::-webkit-scrollbar {
  display: none;
}

.orders-container.dragging-rail {
  cursor: grabbing;
}

.board-case-backdrop {
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 0;
  padding: 0;
  background: rgba(4, 10, 18, 0.42);
}

.board-cell {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  border: 1px solid #1a2a40;
  background: #243b55;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.05);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

@media (max-height: 820px) {
  .board-grid {
    gap: 2px;
    padding: 3px;
  }

  .board-cell {
    border-radius: 6px;
  }
}

@media (max-height: 760px) {
  .board-grid {
    gap: 2px;
    padding: 2px;
  }

  .board-cell {
    border-radius: 5px;
  }
}

.board-cell.selected {
  border-color: #5cd6ff;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.4), 0 0 0 2px rgba(92, 214, 255, 0.4) inset;
}

.item-chip {
  width: 92%;
  height: 92%;
  min-width: 0;
  min-height: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  color: #0d131a;
  padding: 2px;
  box-shadow: 0 5px 10px rgba(0,0,0,0.48), inset 0 2px 3px rgba(255,255,255,0.38), inset 0 -4px 8px rgba(0,0,0,0.16);
  text-shadow: 1px 1px 2px rgba(255,255,255,0.6);
  overflow: hidden;
  position: relative;
}

.item-chip.item-generator {
  overflow: visible;
  box-shadow: 0 5px 10px rgba(0,0,0,0.48), inset 0 0 0 1px rgba(255,255,255,0.14);
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
}

.item-chip.board-action-pulse,
.item-chip.board-merge-pulse {
  animation: boardActionPulse 220ms ease-out;
}

.item-chip.board-merge-pulse {
  animation-name: boardMergePulse;
}

@keyframes boardActionPulse {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes boardMergePulse {
  0% { transform: scale(0.9) rotate(0deg); }
  60% { transform: scale(1.05) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.board-cell.touch-drag-source .item-chip {
  opacity: 0.38;
}

.item-art {
  width: min(54px, 90%);
  height: min(54px, 84%);
  max-width: 88%;
  max-height: 82%;
  object-fit: contain;
  filter: saturate(1.45) contrast(1.12) drop-shadow(0 3px 3px rgba(0, 0, 0, 0.48));
  transform: translateY(1px);
}

.item-lvl {
  align-self: end;
  margin-bottom: 1px;
  line-height: 1;
}

.generator-energy-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #071321;
  background: linear-gradient(180deg, #ffe16a, #ffc329);
  border: 1px solid rgba(255,255,255,0.74);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  font-size: 9px;
}

.generator-spawn-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  margin: 0;
  transform-origin: center;
  will-change: opacity, transform;
}

.board-merge-ring,
.board-merge-spark {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  will-change: transform, opacity;
}

.board-merge-ring {
  border: 2px solid #ffe19b;
  border-radius: 50%;
}

.board-merge-spark {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #ffdf87;
}

/* ---------------------------------------------------------------------------
   Reward, rejection and celebration feedback.

   Everything moves with transform/opacity only so the board grid never
   reflows, and every rule is neutralised for reduced motion and low-end
   devices. Information is never carried by the animation alone: the same
   message also renders as text.
   --------------------------------------------------------------------------- */

.reward-flight {
  position: fixed;
  z-index: 9997;
  pointer-events: none;
  margin: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 14px;
  will-change: transform, opacity;
  background: radial-gradient(circle at 34% 28%, rgba(255, 240, 190, .96), rgba(214, 158, 60, .92));
  border: 1px solid rgba(255, 244, 208, .9);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .42);
  color: #3a2506;
}

.reward-flight[data-tone="gem"], .reward-flight-gem {
  background: radial-gradient(circle at 34% 28%, rgba(226, 244, 255, .96), rgba(94, 180, 226, .92));
  border-color: rgba(226, 246, 255, .92);
  color: #08263a;
}

.board-reason-badge {
  position: fixed;
  z-index: 9997;
  pointer-events: none;
  margin: 0;
  max-width: 46vw;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2px;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  color: #fff3e2;
  background: linear-gradient(180deg, rgba(150, 52, 40, .96), rgba(104, 30, 24, .96));
  border: 1px solid rgba(255, 186, 150, .72);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .48);
  will-change: transform, opacity;
}

.case-complete-stamp {
  position: fixed;
  z-index: 9997;
  pointer-events: none;
  margin: 0;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  font-size: 46px;
  color: #fff6df;
  background: radial-gradient(circle at 40% 32%, rgba(255, 214, 122, .30), rgba(180, 92, 24, .28));
  border: 4px solid rgba(255, 214, 122, .82);
  box-shadow: 0 0 0 6px rgba(255, 214, 122, .16), 0 14px 34px rgba(0, 0, 0, .5);
  will-change: transform, opacity;
}

.energy-return-hint {
  display: block;
  margin: 4px 0 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: #ffe9c2;
  background: rgba(20, 40, 62, .9);
  border: 1px solid rgba(255, 205, 120, .38);
}

body.board-order-awarded .request-panel {
  transition: opacity .3s ease;
}

/* The counters react only while they are gaining, then settle. */
.hud-pulse-coin,
.hud-pulse-gem {
  will-change: transform;
}

body.reduce-motion .reward-flight,
body.reduce-motion .board-reason-badge,
body.reduce-motion .case-complete-stamp,
body.low-performance .case-complete-stamp {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .reward-flight,
  .board-reason-badge,
  .case-complete-stamp {
    display: none;
  }
}

/* Archived targets are visible matching items, with no key, fog or blur. */
.board-grid .board-cell.covered-item {
  border: 1px solid #71808a;
  border-radius: 5px;
  background: linear-gradient(145deg, #3b464b, #26373d);
  box-shadow: inset 0 0 0 2px rgba(184, 195, 194, .08);
  cursor: help;
}
.board-cell.covered-item .item-art {
  filter: saturate(.35) brightness(.85) drop-shadow(0 2px 2px rgba(0,0,0,.3));
  opacity: .85;
}
.board-cell.covered-item .covered-match-mark {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #253743;
  border: 1px solid #8499a5;
  color: #d1e2eb;
  font-size: 9px;
  pointer-events: none;
}
.board-grid .board-cell.covered-item.is-match-ready,
.board-grid .board-cell.covered-item.merge-target {
  border-color: #a9dbc1;
  background: #30483f;
  box-shadow: inset 0 0 0 1px rgba(169,219,193,.4);
}
.board-cell.covered-item.is-match-ready .covered-match-mark { background: #47715d; color: #e7fff0; border-color: #a9dbc1; }
.board-opening-status {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 2px 5px;
  border: 1px solid #567483;
  border-radius: 6px;
  background: #243a44;
  color: #cce1e8;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

/* A cleared region keeps a faint scorch of its old state so progress is legible. */
.board-cell.was-cleared {
  animation: clearedToast 520ms ease-out;
}

@keyframes clearedToast {
  0% { box-shadow: inset 0 0 0 2px rgba(255, 224, 150, .8); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 224, 150, 0); }
}

body.reduce-motion .board-cell.was-cleared {
  animation: none;
}

.board-cell.merge-candidate {
  border-color: #e8bc60;
  box-shadow: inset 0 0 0 1px rgba(255, 217, 133, .65);
}

.board-cell.merge-target {
  border-color: #ffe6a9;
  background: #496046;
  box-shadow: inset 0 0 0 2px #ffe6a9;
}

.board-cell:active .item-generator {
  transform: scale(.95);
}

body.board-submitting .board-root,
body.board-submitting .bottom-nav,
body.board-submitting .hud {
  pointer-events: none;
}

body.board-submitting [data-action="submit_order"][aria-busy="true"] {
  opacity: .65;
  cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .board-cell:active .item-generator { transform: none; }
}

body.reduce-motion .board-cell:active .item-generator { transform: none; }

.touch-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  margin: 0;
  opacity: 0.96;
  transform-origin: center;
  will-change: transform;
  box-shadow: 0 12px 24px rgba(0,0,0,0.38), 0 0 0 2px rgba(255,255,255,0.18) inset !important;
}

.item-art-fallback {
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.req-chip .item-art {
  width: 26px;
  height: 26px;
  max-width: none;
  max-height: none;
  flex: 0 0 auto;
  filter: saturate(1.45) contrast(1.1) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.req-chip .item-art-fallback {
  flex: 0 0 auto;
}


body.intro-screen .app-shell {
  width: min(100%, 440px);
  height: var(--app-height, 100svh);
  border-inline: 0;
  background: radial-gradient(circle at 50% -10%, rgba(33, 68, 106, 0.36), rgba(5, 12, 20, 1) 58%);
  display: block;
  padding: 0;
  backdrop-filter: none;
}

body.intro-screen .screen-root {
  height: var(--app-height, 100svh);
  padding: 0;
}

.item-evidence { background: #ffd570; }
.item-doc { background: #9ed0ff; }
.item-coffee { background: #f8b89d; }
.item-forensic { background: #b8efff; }
.item-interrogation { background: #ead889; }
.item-radio { background: #c7d2ff; }
.item-informant { background: #b7efc5; }
.item-van { background: #efc9ff; }

.generator-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.field-ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.field-ops-grid .btn {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.generator-btn {
  border: 1px solid #38516a;
  background: #1e2e41;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 6px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.mini {
  font-size: 12px;
  color: var(--ink-muted);
}

@media (max-width: 768px) {
  .app-shell {
    width: 100%;
    max-width: none;
    border-inline: 0;
  }

  .hud {
    padding: 10px 8px;
    gap: 6px;
  }

  .screen-root {
    padding: 10px;
  }

  .tab-nav-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-btn {
    font-size: 10px;
    padding: 6px 1px;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin-bottom: 2px;
  }

  .map-zones {
    grid-template-columns: 1fr;
  }

  .crime-icon-balloon {
    width: 70px;
  }

  .crime-icon-balloon.size-sm {
    width: 62px;
  }

  .crime-icon-balloon.size-md {
    width: 70px;
  }

  .crime-icon-balloon.size-lg {
    width: 80px;
  }

  .generator-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .board-grid {
    gap: 2px;
    padding: 3px;
    width: min(100%, var(--board-grid-width, var(--board-grid-size, calc(100dvh - 290px))));
    height: min(100%, var(--board-grid-height, var(--board-grid-size, calc(100dvh - 290px))));
  }
}

/* Keep the phone-first game readable on desktop without stretching it across
   ultrawide monitors. Narrow devices continue to use the full viewport. */
@media (min-width: 769px) {
  .app-shell {
    width: min(100%, 68dvh, 760px);
    min-width: min(100%, 440px);
  }

  /* Keep the HUD and navigation in proportion as the game shell widens. */
  .hud {
    padding: clamp(10px, 1.3dvh, 16px) clamp(12px, 1.8vw, 20px);
  }

  .hud-strip {
    gap: clamp(6px, .8vw, 12px);
  }

  .resource-pill {
    padding: clamp(6px, .8dvh, 10px) clamp(9px, 1vw, 15px);
    font-size: clamp(12px, .9vw, 15px);
  }

  .screen-root {
    padding: clamp(10px, 1.2vw, 16px);
  }

  .bottom-nav {
    padding: clamp(8px, 1dvh, 14px) 12px max(8px, env(safe-area-inset-bottom));
    min-height: clamp(62px, 8dvh, 82px);
  }

  .nav-btn {
    padding: 8px 4px;
    gap: 4px;
    font-size: clamp(11px, .8vw, 14px);
  }

  .nav-icon {
    width: clamp(22px, 2.8dvh, 28px);
    height: clamp(22px, 2.8dvh, 28px);
    min-width: clamp(22px, 2.8dvh, 28px);
    min-height: clamp(22px, 2.8dvh, 28px);
  }

  body.intro-screen .app-shell {
    width: min(100%, 440px);
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .resource-pill {
    padding: 4px 6px;
    font-size: 11px;
    min-width: 0;
    flex-shrink: 1;
  }

  .hud-strip {
    gap: 4px;
  }

  .bottom-nav {
    padding-inline: 7px;
    min-height: 50px;
  }

  .screen-root.board-content {
    padding: 1px 4px 4px;
  }

  .nav-btn {
    border-radius: 9px;
  }

  .field-ops-grid {
    gap: 4px;
  }

  .tab-profile-chip {
    max-width: 52%;
  }

  .board-case-panel-wrap {
    max-width: 42vw;
  }

  .board-panel-fab {
    height: 84px !important;
  }

  .board-case-panel-wrap.mobile-open {
    width: min(250px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px);
  }

}

@media (max-width: 370px) {
  .resource-pill {
    padding: 3px 5px;
    font-size: 10px;
  }

  .hud {
    padding-inline: 5px;
  }

  .hud-regen-label {
    max-width: 24px !important;
  }

  .hud-xp-pill {
    max-width: 66px !important;
  }

  .board-grid {
    width: min(100%, var(--board-grid-width, var(--board-grid-size, calc(100dvh - 304px))));
    height: min(100%, var(--board-grid-height, var(--board-grid-size, calc(100dvh - 304px))));
  }

  .field-ops-grid .btn {
    font-size: 10px !important;
    border-radius: 8px !important;
  }
}

@media (max-width: 430px) {
  .board-case-panel-wrap {
    max-width: 42vw;
  }
}

.jigsaw-screen {
  min-height: 100%;
  padding: 10px;
  background:
    radial-gradient(circle at 78% 18%, rgba(198, 138, 71, 0.2), transparent 28%),
    linear-gradient(180deg, #15100d 0%, #0b1218 100%);
}

.jg-stage {
  position: relative;
  min-height: calc(100dvh - 118px);
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "title title"
    "file board"
    "file tray"
    "actions actions";
  gap: 10px;
  overflow: hidden;
  border: 1px solid rgba(225, 184, 112, 0.22);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(20, 12, 8, 0.55), rgba(11, 16, 20, 0.72)),
    url("./assets/backgrounds/office.webp") center/cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 18px 40px rgba(0,0,0,0.35);
}

.jg-back,
.jg-hint-top {
  position: absolute;
  z-index: 3;
  top: 14px;
  min-width: 48px;
  height: 44px;
  border: 1px solid rgba(236, 207, 151, 0.36);
  border-radius: 8px;
  color: #f5e4c2;
  background: linear-gradient(180deg, rgba(36, 45, 56, 0.94), rgba(13, 19, 26, 0.96));
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.jg-back { left: 14px; }
.jg-hint-top {
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 900;
}
.jg-hint-top i { color: #ffd05c; }

.jg-title-plaque {
  grid-area: title;
  width: min(360px, calc(100% - 126px));
  min-height: 74px;
  margin: 0 auto;
  padding: 8px 16px;
  display: grid;
  align-content: center;
  text-align: center;
  color: #25170f;
  background: linear-gradient(180deg, #e7d2a7, #b98a55);
  border: 1px solid rgba(61, 33, 13, 0.42);
  border-radius: 7px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.45);
}

.jg-title-plaque span {
  font-size: 23px;
  font-weight: 1000;
  line-height: 1;
}
.jg-title-plaque strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.jg-title-plaque small {
  color: #8d2219;
  font-size: 13px;
  font-weight: 1000;
}

.jg-case-file {
  grid-area: file;
  position: relative;
  min-height: 0;
  padding: 54px 14px 12px;
  display: grid;
  align-content: start;
  gap: 12px;
  color: #1e1712;
  background: linear-gradient(180deg, #d8c29a, #a68458);
  border: 1px solid rgba(53, 33, 18, 0.55);
  border-radius: 7px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.32);
}

.jg-clip {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 92px;
  height: 44px;
  transform: translateX(-50%);
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #303a40, #151b20);
  border: 1px solid rgba(255,255,255,0.18);
}

.jg-case-file h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1.15;
}

.jg-case-file p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 800;
}

.jg-progress-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  color: #f3e6cb;
  background: rgba(8, 12, 16, 0.86);
  border-radius: 7px;
}
.jg-progress-card span {
  color: #d6b981;
  font-size: 11px;
  font-weight: 900;
}
.jg-progress-card strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
}
.jg-progress-rail {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.jg-progress-rail div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63b1ce, #e6c45f);
}

.jg-polaroid {
  aspect-ratio: 1 / 0.82;
  border: 8px solid #e7ddcc;
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 16px rgba(0,0,0,0.32);
  transform: rotate(-3deg);
}

.jg-note {
  padding: 10px;
  min-height: 72px;
  color: #3a2615;
  font-size: 12px;
  line-height: 1.35;
  background: #d9bf75;
  border: 1px solid rgba(69, 45, 19, 0.24);
  transform: rotate(-3deg);
}

.jg-board-wrap {
  grid-area: board;
  min-height: 0;
  display: grid;
  place-items: center;
}

.jg-board {
  width: min(100%, calc(100dvh - 310px));
  max-width: 680px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--jg-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--jg-rows), minmax(0, 1fr));
  gap: 2px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(32, 24, 17, 0.95), rgba(8, 13, 17, 0.95));
  border: 2px solid rgba(217, 166, 91, 0.46);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.45), 0 14px 28px rgba(0,0,0,0.36);
}

.jg-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(230, 199, 143, 0.24);
  border-radius: 4px;
  background: rgba(6, 8, 10, 0.45);
  overflow: hidden;
}
.jg-slot:not(.is-filled):hover {
  border-color: rgba(104, 190, 145, 0.78);
}
.jg-slot-mark {
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(255,255,255,0.13);
  border-radius: 4px;
}

.jg-tray {
  grid-area: tray;
  min-height: 116px;
  display: grid;
  grid-template-columns: repeat(var(--jg-tray-count), minmax(64px, 1fr));
  gap: 9px;
  align-items: center;
  padding: 12px;
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(24, 34, 41, 0.96), rgba(9, 15, 20, 0.98));
  border: 1px solid rgba(223, 181, 102, 0.28);
  border-radius: 8px;
}

.jg-piece-btn {
  aspect-ratio: 1;
  min-width: 64px;
  max-height: 96px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(0,0,0,0.26);
}
.jg-piece-btn.is-selected {
  border-color: #f0ce65;
  box-shadow: 0 0 0 3px rgba(240, 206, 101, 0.22), 0 10px 18px rgba(0,0,0,0.32);
}
.jg-piece-btn .jg-piece {
  transform: rotate(var(--jg-rotation, 0deg));
}

.jg-piece {
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
}
.jg-piece.is-locked {
  border-radius: 2px;
}

.jg-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.jg-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  color: #f5ead3;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 8px 16px rgba(0,0,0,0.28);
}
.jg-action i { font-size: 18px; }
.jg-blue { background: linear-gradient(180deg, #214b68, #10283d); }
.jg-gold { background: linear-gradient(180deg, #82551d, #41280d); }
.jg-green { background: linear-gradient(180deg, #287742, #123c25); }
.jg-amber { background: linear-gradient(180deg, #ad7d28, #5a370e); }

.jg-loading {
  padding: 18px 28px;
  color: #f5ead3;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(8, 12, 16, 0.78);
}

.jg-preview {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 18px;
  background: rgba(5, 8, 10, 0.78);
  backdrop-filter: blur(8px);
}
.jg-preview-image {
  width: min(86vw, 520px);
  aspect-ratio: 1;
  border: 8px solid #dac08d;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 20px 44px rgba(0,0,0,0.48);
}
.jg-preview-close {
  min-width: 140px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 8px;
  color: #281906;
  font-weight: 1000;
  background: linear-gradient(180deg, #f1d077, #c88c2f);
}

@media (max-width: 760px) {
  .jigsaw-screen { padding: 6px; }
  .jg-stage {
    min-height: calc(100dvh - 106px);
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "title"
      "file"
      "board"
      "tray"
      "actions";
    padding: 8px;
    gap: 8px;
  }
  .jg-title-plaque {
    width: min(250px, calc(100% - 112px));
    min-height: 58px;
    padding: 6px 10px;
  }
  .jg-title-plaque span { font-size: 18px; }
  .jg-case-file {
    min-height: unset;
    grid-template-columns: 1fr 94px;
    padding: 10px;
    gap: 8px;
  }
  .jg-clip,
  .jg-polaroid,
  .jg-note {
    display: none;
  }
  .jg-case-file h2,
  .jg-case-file p {
    grid-column: 1 / 2;
  }
  .jg-progress-card {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    align-content: center;
  }
  .jg-progress-card strong { font-size: 17px; }
  .jg-board {
    width: min(100%, calc(100dvh - 360px));
    min-width: min(100%, 280px);
    padding: 7px;
  }
  .jg-tray {
    min-height: 92px;
    grid-auto-flow: column;
    grid-auto-columns: minmax(62px, 76px);
    grid-template-columns: none;
  }
  .jg-actions {
    gap: 6px;
  }
  .jg-action {
    min-height: 44px;
    gap: 4px;
    font-size: 10px;
  }
}

@media (max-width: 390px) {
  .jg-hint-top span,
  .jg-action span {
    font-size: 9px;
  }
  .jg-case-file {
    grid-template-columns: 1fr 82px;
  }
  .jg-progress-card {
    padding: 8px;
  }
  .jg-board {
    width: min(100%, calc(100dvh - 382px));
  }
}

/* Jigsaw v2: focused puzzle board, no evidence file panel or decorative room backdrop. */
.jigsaw-screen {
  min-height: 100%;
  padding: 8px;
  background: #071018;
}

.jg-stage {
  min-height: calc(100dvh - 112px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "title"
    "progress"
    "board"
    "tray"
    "actions";
  gap: 9px;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(7, 13, 18, 0.98), rgba(9, 16, 21, 0.98));
  border-color: rgba(212, 165, 87, 0.32);
}

.jg-title-plaque {
  min-height: 60px;
  width: min(310px, calc(100% - 116px));
  padding: 6px 14px;
  background: linear-gradient(180deg, #e5c184, #bc7f35);
}

.jg-title-plaque span {
  font-size: 22px;
}

.jg-title-plaque strong {
  display: none;
}

.jg-back,
.jg-hint-top {
  top: 12px;
  height: 48px;
  background: linear-gradient(180deg, rgba(28, 41, 51, 0.98), rgba(11, 19, 26, 0.98));
}

.jg-back {
  left: 12px;
}

.jg-hint-top {
  right: 12px;
}

.jg-progress-card {
  grid-area: progress;
  width: min(430px, 100%);
  justify-self: center;
  grid-template-columns: auto auto minmax(80px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: #f1dfbc;
  background: rgba(8, 14, 18, 0.78);
  border: 1px solid rgba(225, 186, 105, 0.24);
  border-radius: 8px;
}

.jg-progress-card span {
  font-size: 10px;
}

.jg-progress-card strong {
  font-size: 18px;
  line-height: 1;
}

.jg-progress-rail {
  min-width: 80px;
}

.jg-board-wrap {
  align-items: stretch;
  justify-items: center;
}

.jg-board {
  width: min(100%, 72dvh, 720px);
  max-width: none;
  align-self: center;
  padding: clamp(8px, 2vw, 14px);
  gap: clamp(4px, 1vw, 8px);
  background:
    linear-gradient(180deg, rgba(15, 19, 22, 0.98), rgba(5, 8, 10, 0.98));
  border: 3px solid #d8b06a;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.05),
    inset 0 0 34px rgba(0,0,0,0.58),
    0 16px 30px rgba(0,0,0,0.38);
}

.jg-slot {
  border: 1px solid rgba(216, 176, 106, 0.34);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05), transparent 45%),
    rgba(0, 0, 0, 0.32);
}

.jg-slot-mark {
  inset: 18%;
  border-color: rgba(216, 176, 106, 0.22);
}

.jg-slot.is-filled {
  overflow: visible;
  background: transparent;
  border-color: rgba(255, 228, 174, 0.22);
}

.jg-tray {
  width: 100%;
  min-height: clamp(104px, 17dvh, 146px);
  grid-auto-flow: column;
  grid-auto-columns: clamp(76px, 18vw, 116px);
  grid-template-columns: none;
  gap: 10px;
  padding: 10px 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  background: linear-gradient(180deg, rgba(24, 35, 43, 0.96), rgba(7, 13, 18, 0.98));
  border: 1px solid rgba(216, 176, 106, 0.32);
  border-radius: 8px;
}

.jg-tray::-webkit-scrollbar {
  height: 10px;
}

.jg-tray::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
}

.jg-tray::-webkit-scrollbar-thumb {
  background: #c5c2bd;
  border-radius: 999px;
}

.jg-piece-btn {
  min-width: clamp(76px, 18vw, 116px);
  max-height: none;
  overflow: visible;
  scroll-snap-align: center;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.jg-piece-btn.is-selected {
  box-shadow: none;
}

.jg-piece-btn.is-selected .jg-piece {
  filter: drop-shadow(0 0 0.45rem rgba(241, 208, 119, 0.85)) brightness(1.08);
}

.jg-piece-btn .jg-piece {
  transform: rotate(var(--jg-rotation, 0deg));
}

.jg-piece {
  border: 2px solid rgba(226, 199, 142, 0.62);
  background-repeat: no-repeat;
  box-shadow: 0 9px 14px rgba(0,0,0,0.42);
}

.jg-piece-shape {
  clip-path: polygon(
    0 0, 38% 0, 38% 9%, 62% 9%, 62% 0, 100% 0,
    100% 38%, 91% 38%, 91% 62%, 100% 62%,
    100% 100%, 62% 100%, 62% 91%, 38% 91%, 38% 100%,
    0 100%, 0 62%, 9% 62%, 9% 38%, 0 38%
  );
}

.jg-piece-shape.piece-r1 {
  clip-path: polygon(
    0 0, 35% 0, 35% 10%, 65% 10%, 65% 0, 100% 0,
    100% 35%, 90% 35%, 90% 65%, 100% 65%,
    100% 100%, 65% 100%, 65% 90%, 35% 90%, 35% 100%,
    0 100%, 0 65%, 10% 65%, 10% 35%, 0 35%
  );
}

.jg-piece-shape.piece-c1 {
  clip-path: polygon(
    0 0, 42% 0, 42% 8%, 58% 8%, 58% 0, 100% 0,
    100% 42%, 92% 42%, 92% 58%, 100% 58%,
    100% 100%, 58% 100%, 58% 92%, 42% 92%, 42% 100%,
    0 100%, 0 58%, 8% 58%, 8% 42%, 0 42%
  );
}

.jg-piece.is-locked {
  width: 108%;
  height: 108%;
  margin: -4%;
  border-width: 1px;
  box-shadow: none;
}

.jg-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.jg-action {
  min-height: 46px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.05;
}

.jg-preview {
  background: rgba(4, 8, 10, 0.84);
}

.jg-preview-image {
  width: min(90vw, 560px);
  max-height: min(72dvh, 660px);
  aspect-ratio: 3 / 4;
  border-width: 8px;
  background-size: cover;
}

@media (max-width: 760px) {
  .jigsaw-screen {
    padding: 4px;
  }

  .jg-stage {
    min-height: calc(100dvh - 102px);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "title"
      "progress"
      "board"
      "tray"
      "actions";
    gap: 7px;
    padding: 7px;
  }

  .jg-title-plaque {
    width: min(236px, calc(100% - 112px));
    min-height: 54px;
  }

  .jg-board {
    width: min(100%, calc(100dvh - 300px));
    min-width: min(100%, 330px);
    gap: 5px;
  }

  .jg-tray {
    min-height: clamp(104px, 18dvh, 132px);
    grid-auto-columns: clamp(78px, 22vw, 96px);
  }

  .jg-piece-btn {
    min-width: clamp(78px, 22vw, 96px);
  }
}

@media (max-width: 390px) {
  .jg-title-plaque span {
    font-size: 18px;
  }

  .jg-progress-card {
    grid-template-columns: auto auto 1fr;
    padding: 6px 8px;
  }

  .jg-board {
    min-width: min(100%, 318px);
    width: min(100%, calc(100dvh - 306px));
  }

  .jg-action {
    min-height: 42px;
    font-size: 9px;
  }
}

/* Jigsaw v3: board-first puzzle flow with automatic image reveal. */
.jigsaw-screen {
  min-height: 100%;
  padding: 6px;
  background: #071018;
}

.jg-stage {
  position: relative;
  min-height: calc(100dvh - 108px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "title"
    "progress"
    "board"
    "tray"
    "actions";
  gap: 8px;
  overflow: hidden;
  padding: 8px;
  border: 1px solid rgba(216, 176, 106, 0.34);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(5, 10, 14, 0.99), rgba(9, 16, 21, 0.99));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 14px 30px rgba(0,0,0,0.35);
}

.jg-hint-top,
.jg-preview-close {
  display: none !important;
}

.jg-back {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  width: 48px;
  min-width: 48px;
  height: 48px;
  border: 1px solid rgba(236, 207, 151, 0.36);
  border-radius: 8px;
  color: #f5e4c2;
  background: linear-gradient(180deg, rgba(28, 41, 51, 0.98), rgba(11, 19, 26, 0.98));
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.jg-title-plaque {
  grid-area: title;
  width: min(284px, calc(100% - 70px));
  min-height: 56px;
  margin: 0 auto;
  padding: 6px 12px;
  display: grid;
  align-content: center;
  text-align: center;
  color: #24170e;
  background: linear-gradient(180deg, #e5c184, #bc7f35);
  border: 1px solid rgba(61, 33, 13, 0.42);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.45);
}

.jg-title-plaque span {
  font-size: 22px;
  font-weight: 1000;
  line-height: 1;
}

.jg-title-plaque strong {
  display: none;
}

.jg-title-plaque small {
  color: #8d2219;
  font-size: 12px;
  font-weight: 1000;
}

.jg-progress-card {
  grid-area: progress;
  width: min(420px, 100%);
  justify-self: center;
  display: grid;
  grid-template-columns: auto auto minmax(70px, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  color: #f1dfbc;
  background: rgba(8, 14, 18, 0.78);
  border: 1px solid rgba(225, 186, 105, 0.24);
  border-radius: 8px;
}

.jg-progress-card span {
  color: #d6b981;
  font-size: 10px;
  font-weight: 900;
}

.jg-progress-card strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  line-height: 1;
}

.jg-progress-rail {
  min-width: 70px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}

.jg-progress-rail div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63b1ce, #e6c45f);
}

.jg-board-wrap {
  grid-area: board;
  min-height: 0;
  display: grid;
  place-items: center;
}

.jg-board-shell {
  position: relative;
  width: min(100%, 76dvh, 760px);
  max-height: 100%;
  aspect-ratio: var(--jg-board-aspect, 1);
  display: grid;
  place-items: stretch;
}

.jg-board {
  width: 100%;
  height: 100%;
  aspect-ratio: var(--jg-board-aspect, 1);
  display: grid;
  grid-template-columns: repeat(var(--jg-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--jg-rows), minmax(0, 1fr));
  gap: clamp(4px, 1vw, 8px);
  padding: clamp(8px, 2vw, 14px);
  background: linear-gradient(180deg, rgba(15, 19, 22, 0.98), rgba(5, 8, 10, 0.98));
  border: 3px solid #d8b06a;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.05),
    inset 0 0 34px rgba(0,0,0,0.58),
    0 16px 30px rgba(0,0,0,0.38);
}

.jg-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  border: 1px solid rgba(216, 176, 106, 0.34);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05), transparent 45%),
    rgba(0, 0, 0, 0.32);
}

.jg-slot:not(.is-filled):hover {
  border-color: rgba(104, 190, 145, 0.78);
}

.jg-slot-mark {
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(216, 176, 106, 0.22);
  border-radius: 6px;
}

.jg-slot.is-filled {
  background: transparent;
  border-color: rgba(255, 228, 174, 0.2);
}

.jg-tray {
  grid-area: tray;
  width: 100%;
  min-height: clamp(96px, 16dvh, 140px);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(76px, 18vw, 114px);
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  background: linear-gradient(180deg, rgba(24, 35, 43, 0.96), rgba(7, 13, 18, 0.98));
  border: 1px solid rgba(216, 176, 106, 0.32);
  border-radius: 8px;
}

.jg-tray::-webkit-scrollbar {
  height: 10px;
}

.jg-tray::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
}

.jg-tray::-webkit-scrollbar-thumb {
  background: #c5c2bd;
  border-radius: 999px;
}

.jg-piece-btn {
  aspect-ratio: 1;
  min-width: clamp(76px, 18vw, 114px);
  max-height: none;
  padding: 0;
  overflow: visible;
  scroll-snap-align: center;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.jg-piece-btn.is-selected {
  border: none;
  box-shadow: none;
}

.jg-piece-btn.is-selected .jg-piece {
  filter: drop-shadow(0 0 0.45rem rgba(241, 208, 119, 0.85)) brightness(1.08);
}

.jg-piece-btn .jg-piece {
  transform: rotate(var(--jg-rotation, 0deg));
}

.jg-piece {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(226, 199, 142, 0.62);
  background-repeat: no-repeat;
  box-shadow: 0 9px 14px rgba(0,0,0,0.42);
}

.jg-piece-shape {
  clip-path: polygon(
    0 0, 38% 0, 38% 9%, 62% 9%, 62% 0, 100% 0,
    100% 38%, 91% 38%, 91% 62%, 100% 62%,
    100% 100%, 62% 100%, 62% 91%, 38% 91%, 38% 100%,
    0 100%, 0 62%, 9% 62%, 9% 38%, 0 38%
  );
}

.jg-piece-shape.piece-r1 {
  clip-path: polygon(
    0 0, 35% 0, 35% 10%, 65% 10%, 65% 0, 100% 0,
    100% 35%, 90% 35%, 90% 65%, 100% 65%,
    100% 100%, 65% 100%, 65% 90%, 35% 90%, 35% 100%,
    0 100%, 0 65%, 10% 65%, 10% 35%, 0 35%
  );
}

.jg-piece-shape.piece-c1 {
  clip-path: polygon(
    0 0, 42% 0, 42% 8%, 58% 8%, 58% 0, 100% 0,
    100% 42%, 92% 42%, 92% 58%, 100% 58%,
    100% 100%, 58% 100%, 58% 92%, 42% 92%, 42% 100%,
    0 100%, 0 58%, 8% 58%, 8% 42%, 0 42%
  );
}

.jg-piece.is-locked {
  width: 108%;
  height: 108%;
  margin: -4%;
  border-width: 1px;
  box-shadow: none;
}

.jg-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.jg-action {
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  color: #f5ead3;
  font-size: 12px;
  font-weight: 1000;
  line-height: 1.05;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 8px 16px rgba(0,0,0,0.28);
}

.jg-action i {
  flex: 0 0 auto;
  font-size: 17px;
}

.jg-blue { background: linear-gradient(180deg, #214b68, #10283d); }
.jg-gold { background: linear-gradient(180deg, #82551d, #41280d); }
.jg-green { background: linear-gradient(180deg, #287742, #123c25); }

.jg-loading {
  padding: 18px 28px;
  color: #f5ead3;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(8, 12, 16, 0.78);
}

.jg-preview {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 14px);
  border-radius: 8px;
  background: rgba(4, 8, 10, 0.72);
  animation: jg-preview-reveal 2s ease both;
  pointer-events: none;
}

.jg-preview-image {
  width: 100%;
  height: 100%;
  border: clamp(6px, 1.6vw, 10px) solid #dac08d;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 20px 44px rgba(0,0,0,0.48);
}

@keyframes jg-preview-reveal {
  0% { opacity: 0; transform: scale(0.96); }
  16% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.035); }
}

@media (max-width: 760px) {
  .jigsaw-screen {
    padding: 4px;
  }

  .jg-stage {
    min-height: calc(100dvh - 102px);
    gap: 7px;
    padding: 7px;
  }

  .jg-title-plaque {
    width: min(236px, calc(100% - 70px));
    min-height: 52px;
  }

  .jg-title-plaque span {
    font-size: 19px;
  }

  .jg-board-shell {
    width: min(100%, calc(100dvh - 286px));
  }

  .jg-board {
    gap: 5px;
    padding: 8px;
  }

  .jg-tray {
    min-height: clamp(96px, 17dvh, 126px);
    grid-auto-columns: clamp(78px, 22vw, 96px);
  }

  .jg-piece-btn {
    min-width: clamp(78px, 22vw, 96px);
  }

  .jg-action {
    min-height: 44px;
    gap: 5px;
    font-size: 10px;
  }
}

@media (max-width: 390px) {
  .jg-back {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .jg-title-plaque {
    min-height: 48px;
  }

  .jg-title-plaque span {
    font-size: 18px;
  }

  .jg-progress-card {
    padding: 6px 8px;
  }

  .jg-board-shell {
    width: min(100%, calc(100dvh - 294px));
  }

  .jg-actions {
    gap: 6px;
  }

  .jg-action {
    min-height: 42px;
    padding-inline: 5px;
    font-size: 9px;
  }
}

/* Jigsaw v4: full-board drag-only puzzle layout. */
.jigsaw-screen {
  min-height: 100%;
  padding: 4px;
  background: #071018 !important;
}

.jg-stage {
  min-height: calc(100dvh - 100px);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(6px, 1.5dvh, 10px);
  padding: clamp(6px, 1.8vw, 10px);
  overflow: hidden;
  background: #050c11;
}

.jg-case-file,
.jg-clip,
.jg-polaroid,
.jg-note,
.jg-hint-top,
.jg-preview-close {
  display: none !important;
}

.jg-title-plaque {
  width: min(320px, calc(100% - 68px));
  min-height: 54px;
  padding: 6px 12px;
}

.jg-title-plaque span {
  font-size: clamp(18px, 5.4vw, 24px);
  letter-spacing: 0;
}

.jg-progress-card {
  width: 100%;
  max-width: 540px;
  min-height: 40px;
  grid-template-columns: auto auto minmax(80px, 1fr);
  gap: 8px;
}

.jg-board-wrap {
  min-height: 0;
  width: 100%;
  height: 100%;
  align-items: stretch;
  justify-items: center;
}

.jg-board-shell {
  --jg-frame-pad: clamp(6px, calc(18px / var(--jg-grid-size, 3)), 12px);
  --jg-board-gap: clamp(1px, calc(14px / var(--jg-grid-size, 3)), 5px);
  width: min(100%, max(220px, calc((100dvh - 276px) * var(--jg-board-aspect, 1))), 760px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: var(--jg-board-aspect, 1);
  align-self: center;
  justify-self: center;
}

.jg-board,
.jg-preview {
  padding: var(--jg-frame-pad);
  border: 3px solid #d8b06a;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 18, 18, 0.98), rgba(4, 7, 9, 0.98));
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.05),
    inset 0 0 30px rgba(0,0,0,0.55),
    0 15px 26px rgba(0,0,0,0.36);
}

.jg-board {
  gap: var(--jg-board-gap);
}

.jg-preview {
  inset: 0;
  display: block;
  background: rgba(4, 8, 10, 0.94);
}

.jg-preview-image {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 5px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.3);
}

.jg-slot {
  cursor: default;
  touch-action: none;
  border: 1px solid rgba(216, 176, 106, 0.46);
  border-radius: 4px;
  overflow: visible;
  position: relative;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.055), transparent 44%),
    radial-gradient(circle at 50% 50%, rgba(216,176,106,0.075), transparent 52%),
    rgba(0, 0, 0, 0.34);
  clip-path: none;
}

.jg-slot:not(.is-filled):hover {
  border-color: rgba(216, 176, 106, 0.5);
}

.jg-slot-mark {
  inset: 10%;
  border: 1px dashed rgba(216, 176, 106, 0.3);
  border-radius: 3px;
  clip-path: none;
}

.jg-slot-mark.has-slot-asset {
  inset: auto;
  left: var(--jg-piece-offset, 0%);
  top: var(--jg-piece-offset, 0%);
  width: var(--jg-piece-size, 100%);
  height: var(--jg-piece-size, 100%);
  border: 0;
  border-radius: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0.82;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.38));
}

.jg-slot.is-filled {
  overflow: visible;
  clip-path: none;
  border-color: rgba(245, 222, 176, 0.32);
  background: transparent;
}

.jg-piece {
  border: 1px solid rgba(226, 199, 142, 0.7);
  border-radius: 0;
  background-repeat: no-repeat;
  box-shadow: 0 8px 14px rgba(0,0,0,0.42);
}

.jg-piece-asset {
  clip-path: none;
  border: 0;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,0.38));
}

.jg-piece-shape {
  clip-path: polygon(
    0 0, 36% 0, 36% 10%, 64% 10%, 64% 0, 100% 0,
    100% 36%, 90% 36%, 90% 64%, 100% 64%,
    100% 100%, 64% 100%, 64% 90%, 36% 90%, 36% 100%,
    0 100%, 0 64%, 10% 64%, 10% 36%, 0 36%
  );
}

.jg-piece-shape.piece-r1,
.jg-piece-shape.piece-c1 {
  clip-path: polygon(
    0 0, 40% 0, 40% 9%, 60% 9%, 60% 0, 100% 0,
    100% 40%, 91% 40%, 91% 60%, 100% 60%,
    100% 100%, 60% 100%, 60% 91%, 40% 91%, 40% 100%,
    0 100%, 0 60%, 9% 60%, 9% 40%, 0 40%
  );
}

.jg-piece.is-locked {
  position: absolute;
  left: var(--jg-piece-offset, 0%);
  top: var(--jg-piece-offset, 0%);
  width: var(--jg-piece-size, 100%);
  height: var(--jg-piece-size, 100%);
  margin: 0;
  border-width: 1px;
  box-shadow: none;
  filter: none;
  z-index: 2;
}

.jg-piece-btn {
  cursor: grab;
  touch-action: none;
}

.jg-piece-btn:active {
  cursor: grabbing;
}

.jg-tray {
  min-height: clamp(92px, 16dvh, 132px);
  grid-auto-columns: clamp(68px, 19vw, 116px);
  padding: 9px 12px 13px;
  align-items: center;
}

.jg-piece-btn {
  min-width: clamp(68px, 19vw, 116px);
}

.jg-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.jg-action {
  min-width: 0;
  min-height: 46px;
  padding: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.jg-action span {
  min-width: 0;
}

@media (max-width: 760px) {
  .jg-stage {
    min-height: calc(100dvh - 98px);
  }

  .jg-board-shell {
    width: min(100%, max(220px, calc((100dvh - 282px) * var(--jg-board-aspect, 1))));
  }
}

@media (max-width: 390px) {
  .jg-board-shell {
    width: min(100%, max(210px, calc((100dvh - 286px) * var(--jg-board-aspect, 1))));
  }

  .jg-tray {
    min-height: 90px;
    grid-auto-columns: 72px;
  }

  .jg-piece-btn {
    min-width: 72px;
  }
}

/* Jigsaw v5: tight joins, compact controls, stay-on-board completion. */
.jigsaw-screen {
  padding: 3px;
}

.jg-stage {
  min-height: calc(100dvh - 104px);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(4px, 1dvh, 7px);
  padding: 6px;
}

.jg-back {
  top: 8px;
  left: 8px;
  width: 46px;
  min-width: 46px;
  height: 46px;
}

.jg-title-plaque {
  width: min(272px, calc(100% - 72px));
  min-height: 50px;
  margin-left: max(58px, calc((100% - min(272px, calc(100% - 72px))) / 2));
  margin-right: auto;
  padding: 5px 10px;
}

.jg-title-plaque span {
  font-size: clamp(18px, 5vw, 22px);
}

.jg-title-plaque small {
  font-size: 11px;
}

.jg-progress-card {
  min-height: 34px;
  padding: 5px 9px;
}

.jg-board-shell {
  --jg-frame-pad: clamp(5px, calc(14px / var(--jg-grid-size, 3)), 9px);
  --jg-board-gap: clamp(0px, calc(2px / var(--jg-grid-size, 3)), 1px);
  width: min(100%, max(218px, calc((100dvh - 246px) * var(--jg-board-aspect, 1))), 760px);
}

.jg-board {
  gap: var(--jg-board-gap);
  padding: var(--jg-frame-pad);
}

.jg-slot {
  border-radius: 2px;
  border-width: 1px;
}

.jg-slot-mark.has-slot-asset {
  opacity: 0.9;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}

.jg-piece.is-locked {
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.26));
}

.jg-tray {
  min-height: clamp(74px, 12dvh, 104px);
  grid-auto-columns: clamp(58px, 16vw, 96px);
  gap: 8px;
  padding: 7px 10px 10px;
}

.jg-piece-btn {
  min-width: clamp(58px, 16vw, 96px);
}

.jg-actions {
  gap: 6px;
}

.jg-action {
  min-height: 40px;
  padding: 5px 6px;
  gap: 5px;
  font-size: 10px;
  line-height: 1;
}

.jg-action i {
  font-size: 15px;
}

.jg-complete-overlay {
  position: absolute;
  inset: var(--jg-frame-pad);
  z-index: 6;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 236, 171, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.08));
  animation: jg-complete-glow 900ms ease-out both;
}

.jg-complete-shine {
  position: absolute;
  inset: -35% -70%;
  transform: translateX(-55%) rotate(18deg);
  background: linear-gradient(90deg, transparent 34%, rgba(255, 244, 195, 0.44) 50%, transparent 66%);
  animation: jg-complete-sweep 1450ms ease-out 160ms both;
}

.jg-complete-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 9px 13px;
  border: 1px solid rgba(255, 231, 166, 0.82);
  border-radius: 8px;
  color: #241707;
  background: linear-gradient(180deg, #ffe59c, #d19a37);
  box-shadow: 0 12px 26px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.58);
  font-size: clamp(11px, 3.2vw, 15px);
  font-weight: 1000;
  text-align: center;
}

.jg-stage.is-completed .jg-actions {
  opacity: 0.82;
}

@keyframes jg-complete-glow {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes jg-complete-sweep {
  from { transform: translateX(-55%) rotate(18deg); }
  to { transform: translateX(55%) rotate(18deg); }
}

@media (max-width: 760px) {
  .jg-stage {
    min-height: calc(100dvh - 92px);
    padding: 5px;
  }

  .jg-board-shell {
    width: min(100%, max(214px, calc((100dvh - 238px) * var(--jg-board-aspect, 1))));
  }

  .jg-title-plaque {
    width: min(250px, calc(100% - 70px));
    min-height: 48px;
    margin-left: 58px;
  }

  .jg-tray {
    min-height: clamp(70px, 11dvh, 94px);
    grid-auto-columns: clamp(56px, 16vw, 82px);
  }

  .jg-piece-btn {
    min-width: clamp(56px, 16vw, 82px);
  }
}

@media (max-width: 390px) {
  .jg-back {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .jg-title-plaque {
    width: min(226px, calc(100% - 58px));
    min-height: 44px;
    margin-left: 50px;
  }

  .jg-board-shell {
    width: min(100%, max(208px, calc((100dvh - 232px) * var(--jg-board-aspect, 1))));
  }

  .jg-tray {
    min-height: 68px;
    grid-auto-columns: 58px;
    padding: 6px 8px 8px;
  }

  .jg-piece-btn {
    min-width: 58px;
  }

  .jg-action {
    min-height: 38px;
    font-size: 8.5px;
  }
}

/* ---------------------------------------------------------------------------
   Producer info: description strip + (i) production list.

   The researched reference keeps the generator sprite clean and shows "what does
   this make" in a description bar with an (i) that opens the full list. A corner
   preview icon inside the cell was tried and removed: it overlapped the artwork
   and the border.
   --------------------------------------------------------------------------- */

.producer-strip-host:empty {
  display: none;
}

.producer-info-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16, 26, 38, .95), rgba(24, 38, 54, .95));
  border: 1px solid rgba(255, 214, 122, .38);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
}

.producer-info-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffe9c2;
}

.producer-info-text b { color: #fff; font-weight: 800; }

.producer-info-bolt {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: #2a1c04;
  background: linear-gradient(180deg, #ffe16a, #ffc329);
  border: 1px solid rgba(255, 244, 208, .8);
}

/* Cost-coded bolt, matching the researched colour language (1 / 2 / 4+). */
.generator-energy-badge.energy-cost-2 {
  background: linear-gradient(180deg, #d9b6ff, #a56ee8);
  color: #1d0f33;
}

.generator-energy-badge.energy-cost-4 {
  background: linear-gradient(180deg, #ffb0d8, #e86bb4);
  color: #38081f;
}

.producer-info-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 244, 208, .55);
  background: #5d1f1a;
  color: #fff3e2;
  font-size: 12px;
  cursor: pointer;
}

.producer-info-overlay {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 14, .72);
  backdrop-filter: blur(3px);
}

.producer-info-card {
  width: min(340px, 92vw);
  max-height: 78vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, #20303f, #16222e);
  border: 2px solid rgba(255, 214, 122, .5);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
}

.producer-info-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.producer-info-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffe9c2;
}

.producer-info-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 122, .5);
  background: #5d1f1a;
  color: #fff3e2;
  cursor: pointer;
}

.producer-info-hint {
  margin: 0 0 10px;
  font-size: 11px;
  line-height: 1.35;
  color: #b9c8d6;
}

.producer-info-list {
  display: grid;
  gap: 6px;
}

.producer-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
}

.producer-info-row .item-art { width: 40px !important; height: 40px !important; }

.producer-info-name {
  font-size: 12px;
  font-weight: 700;
  color: #e9f2fb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.producer-info-name b { color: #ffd98a; }

body.reduce-motion .producer-info-overlay { backdrop-filter: none; }

/* Puzzle layout and responsive sizing are maintained in screens.css. */

/* ---------------------------------------------------------------------------
   Word puzzle QA overrides: answer slots and actions in the noir palette.

   The earlier cyan neon slot read as a foreign element on the gold/noir board
   (screenshot-confirmed). Slots are now parchment-on-wood like the rest of the
   pack, and the size formula is the panel-based one, so a 10-letter word still
   fits the row: size = (panel inner width - gaps) / letters, clamped.
   --------------------------------------------------------------------------- */

.wp-slots {
  --wp-slot-count: 5;
  --wp-slot-size: clamp(
    24px,
    min(calc((min(100vw, 760px) - 108px - (var(--wp-slot-count) - 1) * 5px) / var(--wp-slot-count)), calc((100dvh - 420px) * 0.52)),
    52px
  );
}

.wp-answer-slot {
  width: var(--wp-slot-size);
  height: var(--wp-slot-size);
  flex: 0 0 var(--wp-slot-size);
  border: 2px solid rgba(214, 178, 110, 0.85);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(38, 30, 20, 0.96), rgba(20, 16, 11, 0.97));
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.6),
    inset 0 -1px 0 rgba(255, 226, 170, 0.14),
    0 2px 5px rgba(0, 0, 0, 0.4);
  color: #f4dfae;
}

.wp-answer-slot:disabled { opacity: 0.9; }

/* Filled slots read as stamped letters on the parchment. */
.wp-answer-slot:not(:empty) {
  border-color: rgba(255, 214, 122, 0.95);
  background:
    linear-gradient(180deg, rgba(64, 48, 26, 0.98), rgba(34, 26, 16, 0.98));
}

/* Buttons: already icon-over-label; here they gain the pack's plate look so
   they stop reading as flat modern bars on a noir board. */
.wp-action-btn {
  border: 2px solid rgba(0, 0, 0, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 210, 0.22),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 3px 8px rgba(0, 0, 0, 0.38);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.wp-red    { background: linear-gradient(180deg, #8c3327, #43150f) !important; border-color: rgba(255, 190, 160, 0.35) !important; }
.wp-yellow { background: linear-gradient(180deg, #8a6120, #3a2708) !important; border-color: rgba(255, 226, 160, 0.4) !important; }
.wp-green  { background: linear-gradient(180deg, #1d6b2c, #0a2c12) !important; border-color: rgba(180, 255, 190, 0.32) !important; }
.wp-blue   { background: linear-gradient(180deg, #1a4a72, #082030) !important; border-color: rgba(170, 215, 255, 0.32) !important; }


/* ---------------------------------------------------------------------------
   Word puzzle header: smaller title, clue as a BUTTON beside it.

   The clue used to be a full-width strip that reserved a whole grid row and read
   as a large empty bar. It is now a button in the title row that opens the
   notebook drawer over the board, so the freed height belongs to the tiles.
   --------------------------------------------------------------------------- */

.wp-label-row {
  grid-area: label;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding-left: 46px;   /* clears the back button */
  padding-right: 6px;
}

.wp-label-row .wp-center-label {
  grid-area: auto;
  min-width: 0;
  flex: 0 1 auto;
  min-height: 30px;
  padding: 3px 12px;
}

.wp-label-row .wp-center-label span {
  /* One notch smaller than before, as requested, to free room for the button. */
  font-size: clamp(11px, 2.9vw, 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-clue-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(225, 191, 127, 0.5);
  border-radius: 9px;
  background: linear-gradient(180deg, #3a2c1a, #241708);
  color: #f4dfae;
  font-size: clamp(10px, 2.7vw, 12px);
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 226, 170, 0.18);
}

.wp-clue-button i { font-size: 12px; color: #ffd98a; }

/* Open state so the player can see the drawer is showing because they tapped it. */
.wp-clue-button.is-open {
  border-color: rgba(255, 214, 122, 0.9);
  background: linear-gradient(180deg, #6a4d21, #3a2708);
}

/* The old always-visible tab is gone: the button replaces it. */
.wp-clue-tab { display: none !important; }

/* The drawer is an overlay: it must not participate in the grid at all. */
.wp-left-panel.wp-overlay-panel {
  grid-area: auto;
}


/* ---------------------------------------------------------------------------
   Producer strip as a floating overlay.

   It used to sit in the board's flex column, so every selection squeezed the board
   and every dismissal grew it back -- the layout visibly jumped. It is now
   position:fixed above the action row, out of flow, and dismisses on tap-outside
   or Escape.

   Class marker: producer-strip-overlay
   --------------------------------------------------------------------------- */

.producer-strip-host {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* Sits directly above the bottom action row + nav, clear of the board. */
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  width: min(100% - 20px, 420px);
  z-index: 60;
  pointer-events: none;
  display: block;
}

.producer-strip-host:empty,
.producer-strip-host[data-strip-active="0"] {
  display: none;
}

.producer-strip-host .producer-info-strip {
  pointer-events: auto;
  /* A compact floating pill rather than a full-width bar. */
  border-radius: 14px;
  padding: 6px 8px 6px 10px;
  background: linear-gradient(180deg, rgba(14, 24, 36, .96), rgba(24, 38, 54, .97));
  border: 1px solid rgba(255, 214, 122, .45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
  animation: producerStripIn 140ms ease-out;
}

@keyframes producerStripIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

body.reduce-motion .producer-strip-host .producer-info-strip {
  animation: none;
}

/* The strip replaces the old always-open info row: the board never changes size. */
.board-section .producer-strip-host + .card,
.board-section [data-producer-strip-host] {
  position: fixed;
}


/* Clue backdrop; drawer geometry lives in screens.css. */
@keyframes wpClueIn {
  from { opacity: 0; transform: translateY(-6px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wp-clue-scrim {
  position: fixed;
  inset: 0;
  z-index: 58;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: rgba(4, 8, 14, .34);
}

/* ---------------------------------------------------------------------------
   Producer strip as a floating overlay.

   It used to sit in the board's flex column, so every selection squeezed the board
   and every dismissal grew it back -- the layout visibly jumped. It is now
   position:fixed above the action row, out of flow, and dismisses on tap-outside
   or Escape.

   Class marker: producer-strip-overlay
   --------------------------------------------------------------------------- */

.producer-strip-host {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* Sits directly above the bottom action row + nav, clear of the board. */
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  width: min(100% - 20px, 420px);
  z-index: 60;
  pointer-events: none;
  display: block;
}

.producer-strip-host:empty,
.producer-strip-host[data-strip-active="0"] {
  display: none;
}

.producer-strip-host .producer-info-strip {
  pointer-events: auto;
  /* A compact floating pill rather than a full-width bar. */
  border-radius: 14px;
  padding: 6px 8px 6px 10px;
  background: linear-gradient(180deg, rgba(14, 24, 36, .96), rgba(24, 38, 54, .97));
  border: 1px solid rgba(255, 214, 122, .45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
  animation: producerStripIn 140ms ease-out;
}

@keyframes producerStripIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

body.reduce-motion .producer-strip-host .producer-info-strip {
  animation: none;
}

/* The strip replaces the old always-open info row: the board never changes size. */
.board-section .producer-strip-host + .card,
.board-section [data-producer-strip-host] {
  position: fixed;
}


/* Notebook typography and grip; geometry lives in screens.css. */



@keyframes wpScrimIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* A visible grip so the drawer reads as something you pull. */
.wp-left-panel.wp-clue-drawer::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 3px;
  height: 46px;
  margin-top: -23px;
  border-radius: 999px;
  background: rgba(240, 218, 170, .3);
}

/* Inside the drawer: a header with the label and level progress. */
.wp-left-panel.wp-clue-drawer .wp-left-header {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0 0 14px;
  min-height: 0;
}

.wp-left-panel.wp-clue-drawer .wp-left-header h2 {
  align-items: flex-start;
  text-align: left;
  padding: 0;
  min-height: 0;
}

.wp-left-panel.wp-clue-drawer .wp-left-header h2 span {
  font-size: 13px;
  letter-spacing: .12em;
  color: #f0d9a6;
}

.wp-left-panel.wp-clue-drawer .wp-left-header h2 small {
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  color: #efe0c4;
}

.wp-left-panel.wp-clue-drawer .wp-left-content {
  height: auto;
  font-size: 12px;
  color: #cdbd9c;
}

body.reduce-motion /* ---------------------------------------------------------------------------
   Covered-space status: how many areas remain and what opens the next one.

   Kept to a single compact line on purpose. The previous info element was a
   full-width bar that changed the board's height, which is what made the screen
   jump; this one is a status row that never wraps and never resizes anything.
   --------------------------------------------------------------------------- */

.cover-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
  padding: 0 2px;
  font-size: 10.5px;
  font-weight: 700;
  color: #cbb894;
  white-space: nowrap;
  overflow: hidden;
}

.cover-status-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(60, 48, 32, .78);
  border: 1px solid rgba(206, 172, 108, .34);
  color: #e9d7ab;
  flex: 0 0 auto;
}

.cover-status-count i { font-size: 10px; color: #d8c194; }
.cover-status-count b { color: #fff; }

.cover-status-next {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b9c8d6;
}


/* The clue button sits at the right end of the header row, directly above the panel
   it opens, so the panel reads as attached to its control rather than floating. */
.wp-label-row {
  justify-content: space-between;
  gap: 6px;
  padding-right: 4px;
}

.wp-label-row .wp-center-label {
  flex: 1 1 auto;
  min-width: 0;
}

.wp-clue-button {
  flex: 0 0 auto;
  align-self: center;
}


/* ---------------------------------------------------------------------------
   Generator info screen: what this producer makes.

   Layout copied from the reference screenshots: a parchment card, a title plaque,
   a "Level N" subtitle, item tiles on pale blue, a "Generates:" row and a "Next
   level also generates:" row with red "New" ribbons, and a "?" tile for outputs not
   discovered yet. Tap cost and cooldown are deliberately absent.
   --------------------------------------------------------------------------- */

.producer-info-overlay {
  background: rgba(4, 8, 14, .7);
}

.producer-info-card.gi-card {
  position: relative;
  width: min(360px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  padding: 30px 16px 14px;
  border-radius: 20px;
  border: 3px solid #a8672f;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, .55), transparent 55%),
    linear-gradient(180deg, #f6e3c0, #e8cfa6 62%, #dfc094);
  box-shadow: 0 20px 46px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(255, 244, 220, .6);
}

.gi-header {
  display: block;
  margin: 0 0 12px;
  text-align: center;
}

.gi-plaque {
  display: inline-block;
  margin-top: -44px;
  padding: 7px 18px;
  border-radius: 10px;
  border: 2px solid #8d4f1f;
  background: linear-gradient(180deg, #7fb2e8, #3f74bd);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .02em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}

.gi-level {
  display: block;
  margin: 6px 0 0;
  color: #7a4d16;
  font-size: 13px;
  font-weight: 800;
}

.producer-info-close {
  position: absolute;
  right: 10px;
  top: 12px;
  z-index: 2;
  background: #b4573a;
  border-color: rgba(255, 236, 210, .7);
}

.gi-body { display: grid; gap: 12px; }

.gi-section { display: grid; gap: 6px; }

.gi-label {
  color: #8a5a1c;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
}

.gi-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.gi-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  background: linear-gradient(180deg, #cfe6f7, #a9cbe6);
  border: 2px solid #7fa8c9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}

.gi-tile .item-art { width: 44px !important; height: 44px !important; }

.gi-tile-lvl {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 9px;
  font-weight: 900;
  color: #2f4a63;
}

.gi-tile.is-unknown {
  background: linear-gradient(180deg, #e0d2b2, #c8b696);
  border-color: #a89473;
  color: #6d5a3c;
  font-size: 22px;
  font-weight: 900;
}

.gi-new {
  position: absolute;
  right: -6px;
  top: -7px;
  padding: 2px 5px;
  border-radius: 4px;
  background: linear-gradient(180deg, #e8483a, #a3140c);
  border: 1px solid rgba(255, 220, 210, .8);
  color: #fff;
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: .04em;
  transform: rotate(8deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}

.gi-empty {
  color: #7a5c33;
  font-size: 11.5px;
  font-weight: 700;
  padding: 10px 0;
}

.gi-hint {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(138, 90, 28, .45);
  color: #7a4d16;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

