:root {
  color-scheme: dark;
  --bg: #0f1116;
  --panel: #181c23;
  --panel-2: #232933;
  --line: #313846;
  --text: #edf1f7;
  --muted: #a7b0c0;
  --accent: #32c0a8;
  --warning: #ffc107;
  --bad: #f06767;
  --good: #60d394;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100vh;
  overflow: hidden;
}

.game-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.brand-logo {
  width: min(252px, 100%);
  max-height: 38px;
  object-fit: contain;
  object-position: left center;
}

h1,
p {
  margin: 0;
}

h1 {
  color: var(--muted);
  font-size: 15px;
}

.dashboard-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 4px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121820;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.dashboard-link:hover {
  border-color: var(--accent);
}

.question-panel {
  display: grid;
  gap: 12px;
  flex-shrink: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
}

.question-prompt {
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
}

.question-options {
  display: grid;
  gap: 8px;
}

.case-support-tools {
  position: absolute;
  top: 92px;
  left: 22px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 96px;
  max-width: 96px;
  padding: 8px 7px;
  border: 1px solid rgba(159, 208, 255, 0.18);
  border-radius: 12px;
  background: rgba(5, 6, 7, 0.52);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
}

.case-support-tools.hidden {
  display: none;
}

.support-button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  min-height: 82px;
  padding: 8px 6px 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
  white-space: normal;
}

.support-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.human-consult-button {
  border-color: color-mix(in srgb, #65d6ff, transparent 34%);
  background: #183040;
  color: #bfefff;
}

.ai-support-button {
  border-color: color-mix(in srgb, dodgerblue, transparent 20%);
  background: #13284a;
  color: #9fd0ff;
}

.support-button-label {
  display: block;
}

.support-count {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 12px;
}

.support-button.used,
.support-button:disabled {
  opacity: 0.58;
}

.support-output {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111720;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.support-output.hidden {
  display: none;
}

.support-output strong {
  color: var(--text);
}

.support-output.human {
  border-color: color-mix(in srgb, #65d6ff, transparent 42%);
}

.support-output.ai {
  border-color: color-mix(in srgb, dodgerblue, transparent 30%);
}

.support-verdict {
  display: block;
  margin-top: 3px;
  color: #9fd0ff;
  font-weight: 800;
}

.question-option {
  width: 100%;
  height: auto;
  min-height: 42px;
  padding: 9px 10px;
  text-align: left;
  line-height: 1.25;
}

.question-option.correct {
  border-color: color-mix(in srgb, var(--good), transparent 20%);
  color: var(--good);
}

.question-option.incorrect {
  border-color: color-mix(in srgb, var(--bad), transparent 20%);
  color: var(--bad);
}

.question-explanation {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.question-explanation.hidden {
  display: none;
}

.feedback {
  flex-shrink: 0;
  min-height: 70px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
  color: var(--muted);
  line-height: 1.35;
}

.feedback.good {
  border-color: color-mix(in srgb, var(--good), transparent 35%);
  color: var(--good);
}

.feedback.bad {
  border-color: color-mix(in srgb, var(--bad), transparent 35%);
  color: var(--bad);
}

.calibration-banner {
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, dodgerblue, transparent 28%);
  border-radius: 8px;
  background: linear-gradient(135deg, rgb(30 88 170 / 0.24), rgb(50 192 168 / 0.12)), #101722;
  color: #9fd0ff;
  font-size: 12px;
  line-height: 1.25;
}

.calibration-banner.hidden {
  display: none;
}

.calibration-banner strong {
  color: var(--text);
  font-size: 13px;
}

.continue-button {
  flex-shrink: 0;
  width: 100%;
  min-height: 46px;
  border-color: #1d6cf2;
  background: #1f6fff;
  color: white;
  font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.continue-button.hidden {
  display: none;
}

.hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
}

.hud-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.hud-grid span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.hud-grid small {
  color: var(--muted);
}

.lives {
  display: flex;
  flex-shrink: 0;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
  padding-left: 2px;
}

.life {
  width: 44px;
  height: 44px;
  display: inline-block;
  background: url("../shared/assets/life-coffee-transparent.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.45));
  transition: opacity 160ms ease, filter 160ms ease, transform 160ms ease;
}

.life.lost {
  opacity: 0.28;
  filter: grayscale(1) brightness(0.55);
}

.progress-card {
  display: grid;
  align-content: start;
}

.progress-track {
  width: 100%;
  height: 7px;
  margin-top: 9px;
  border-radius: 999px;
  background: #111720;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: dodgerblue;
  transition: width 180ms ease;
}

.viewer {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  height: 100vh;
}

.toolbar,
.slice-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #141820;
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 12px;
  padding: 7px 12px;
  overflow-x: auto;
}

.toolbar-group {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #171c24;
}

.toolbar-group-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.toolbar-group-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mpr-group {
  justify-self: start;
  border-color: color-mix(in srgb, #1f6fff, transparent 28%);
  background: #111b2b;
}

.window-group {
  justify-self: center;
  max-width: 100%;
  border-color: color-mix(in srgb, var(--warning), transparent 28%);
  background: #1f1b12;
}

.window-group.tool-active {
  border-color: color-mix(in srgb, var(--accent), transparent 8%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent), transparent 42%);
}

.preset-group {
  justify-self: end;
  min-width: 410px;
  border-color: rgba(245, 247, 251, 0.58);
  background: #181b22;
}

button {
  min-width: 38px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.82;
}

button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.window-tool-button.active,
.stack-scroll-button.active,
.select-tool-button.active {
  border-color: var(--accent);
  background: #24453f;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent), transparent 45%);
}

.select-tool-button {
  width: 48px;
  min-width: 48px;
}

.select-tool-button.hidden {
  display: none;
}

.select-tool-icon {
  position: relative;
  display: block;
  width: 27px;
  height: 27px;
  border: 2px solid #dffaf6;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(50, 192, 168, 0.24), inset 0 0 0 4px rgba(50, 192, 168, 0.18);
}

.select-tool-icon::before,
.select-tool-icon::after {
  content: "";
  position: absolute;
  background: #32c0a8;
}

.select-tool-icon::before {
  left: 50%;
  top: 3px;
  width: 2px;
  height: 17px;
  transform: translateX(-50%);
}

.select-tool-icon::after {
  left: 3px;
  top: 50%;
  width: 17px;
  height: 2px;
  transform: translateY(-50%);
}

.select-tool-button.active .select-tool-icon {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(50, 192, 168, 0.25), inset 0 0 0 5px rgba(50, 192, 168, 0.28);
}

.stack-scroll-icon {
  position: relative;
  display: block;
  width: 23px;
  height: 19px;
}

.stack-scroll-icon::before,
.stack-scroll-icon::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 11px;
  border: 1px solid rgba(214, 234, 255, 0.86);
  border-radius: 2px;
  background: linear-gradient(145deg, #9fd0ff, #5a93cf);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
  transform: skewX(-18deg);
}

.stack-scroll-icon::before {
  right: 1px;
  bottom: 1px;
}

.stack-scroll-icon::after {
  left: 1px;
  top: 1px;
}

.window-tool-icon {
  display: block;
  width: 19px;
  height: 19px;
  border: 1px solid rgba(245, 247, 251, 0.8);
  border-radius: 3px;
  background: linear-gradient(135deg, #f5f7fb 0 48%, #07080a 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.toolbar input[type="range"] {
  width: 72px;
}

.window-presets {
  display: flex;
  align-items: center;
  gap: 8px;
}

.window-presets button {
  min-width: max-content;
  padding: 0 12px;
  background: #3a3f49;
  color: #f5f7fb;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.window-presets button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #04110f;
}

.image-stage {
  display: grid;
  grid-template-columns: 124px 1fr;
  min-width: 0;
  min-height: 0;
}

.series-tray {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-right: 1px solid var(--line);
  background: #11151b;
  overflow-y: auto;
}

.series-tray-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.series-tabs {
  display: grid;
  gap: 10px;
}

.series-card {
  display: grid;
  gap: 7px;
  width: 100%;
  height: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1b2028;
  color: var(--text);
  text-align: left;
}

.series-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent), transparent 35%);
}

.series-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 5px;
  object-fit: cover;
  background: #050607;
}

.series-thumb-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 5px;
  background: #050607;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.series-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #050607;
  touch-action: none;
  user-select: none;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-wrap.window-tool-active canvas {
  cursor: ew-resize;
}

.canvas-wrap.scroll-tool-active canvas {
  cursor: ns-resize;
}

.orientation-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.orientation-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(245, 247, 251, 0.28);
  border-radius: 50%;
  background: rgba(5, 6, 7, 0.58);
  color: rgba(245, 247, 251, 0.92);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
}

.orientation-top {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.orientation-right {
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}

.orientation-bottom {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.orientation-left {
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 7, 0.72);
  color: var(--muted);
}

.loading.hidden {
  display: none;
}

.challenge-clock {
  position: absolute;
  top: 18px;
  left: 22px;
  z-index: 3;
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 8px 11px;
  border: 1px solid rgba(30, 144, 255, 0.7);
  border-radius: 8px;
  background: rgba(5, 6, 7, 0.62);
  box-shadow: 0 0 0 1px rgba(30, 144, 255, 0.16);
  pointer-events: none;
}

.challenge-clock.hidden {
  display: none;
}

.challenge-clock-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.challenge-clock strong {
  color: #8ec5ff;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.challenge-clock.warning {
  border-color: color-mix(in srgb, var(--warning), transparent 18%);
}

.challenge-clock.warning strong {
  color: var(--warning);
}

.challenge-clock.danger {
  border-color: color-mix(in srgb, var(--bad), transparent 18%);
}

.challenge-clock.danger strong {
  color: var(--bad);
}

.mouse-help {
  position: absolute;
  top: 18px;
  right: 22px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(5, 6, 7, 0.4);
  pointer-events: none;
}

.mouse-help-item {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 54px;
  color: rgba(245, 247, 251, 0.9);
  font-size: 14px;
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 1px 2px #000;
}

.mouse-icon {
  position: relative;
  display: block;
  width: 25px;
  height: 38px;
  border-radius: 14px 14px 16px 16px;
  background: linear-gradient(#2d3037, #424650);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.mouse-icon::before,
.mouse-icon::after {
  content: "";
  position: absolute;
}

.mouse-right::before {
  top: 1px;
  right: 1px;
  width: 11px;
  height: 14px;
  border-radius: 0 13px 0 3px;
  background: #d81436;
}

.mouse-left::before {
  top: 1px;
  left: 1px;
  width: 11px;
  height: 14px;
  border-radius: 13px 0 3px 0;
  background: #d81436;
}

.mouse-wheel::before {
  top: 2px;
  left: 50%;
  width: 4px;
  height: 14px;
  border-radius: 999px;
  background: #d81436;
  transform: translateX(-50%);
}

.mouse-icon::after {
  top: 0;
  left: 50%;
  width: 1px;
  height: 16px;
  background: rgba(0, 0, 0, 0.7);
  transform: translateX(-50%);
}

.slice-status {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

#sliceSlider {
  display: none;
}

output {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .game-panel {
    max-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar,
  .slice-status {
    flex-wrap: wrap;
  }

  .toolbar {
    display: flex;
    overflow-x: visible;
  }

  .toolbar-group {
    flex: 1 1 auto;
  }

  .window-group {
    flex-basis: 100%;
  }

  .toolbar-group-controls {
    flex-wrap: wrap;
  }

  .image-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .series-tray {
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .series-tabs {
    display: flex;
    min-width: max-content;
  }

  .series-card {
    width: 88px;
  }

  .window-presets {
    width: 100%;
    overflow-x: auto;
  }

  .preset-group {
    min-width: 0;
    justify-self: auto;
  }
}
