* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  /* Theme palette ported from DeskDetectiveVisualTheme.cs */
  --page: #0e1113;
  --desk: #734f2e;
  --desk-hi: #b88f59;
  --panel: #1f2429;
  --text: #f0e9d7;
  --muted: #b8c7c7;
  --accent: #f7ae38;
  --hint: #73b3eb;
  --success: #52c78c;
  --warning: #f05c48;
  --evidence: #29525c;

  --panel-2: #171b1f;
  --line: rgba(184, 143, 89, 0.26);
  --line-soft: rgba(184, 199, 199, 0.16);
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(1200px 520px at 50% -8%, rgba(247, 174, 56, 0.08), transparent 60%),
    linear-gradient(180deg, #0e1113 0%, #11161a 48%, #0c0f11 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", sans-serif;
  line-height: 1.5;
  touch-action: manipulation;
}

button,
a,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(960px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand::before {
  display: grid;
  width: 28px;
  height: 28px;
  align-content: center;
  justify-items: center;
  border: 2px solid var(--accent);
  border-radius: 7px;
  background: rgba(247, 174, 56, 0.12);
  box-shadow: 0 0 18px rgba(247, 174, 56, 0.32);
  content: "\1F50E";
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.1;
}

.icon-button:hover {
  border-color: var(--accent);
  background: #262d33;
  transform: translateY(-1px);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(248px, 304px);
  gap: 18px;
  align-items: start;
}

/* ---------- The desk (left column) ---------- */

.desk-surface {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(184, 143, 89, 0.5);
  border-radius: 20px;
  padding: clamp(16px, 3vw, 26px);
  background:
    linear-gradient(180deg, rgba(20, 24, 28, 0.4), rgba(12, 15, 17, 0.62)),
    repeating-linear-gradient(
      94deg,
      #6f4b2b 0px,
      #784f2e 5px,
      #6b4729 11px,
      #774e2d 17px
    ),
    var(--desk);
  box-shadow:
    inset 0 1px 0 rgba(184, 143, 89, 0.34),
    inset 0 -28px 60px rgba(0, 0, 0, 0.42),
    0 30px 70px rgba(0, 0, 0, 0.4);
}

.desk-surface::before {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(184, 143, 89, 0.22);
  border-radius: 14px;
  content: "";
  pointer-events: none;
}

.case-head {
  position: relative;
  margin-bottom: 16px;
}

.case-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 17, 19, 0.66);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.case-tag.daily {
  border-color: rgba(247, 174, 56, 0.6);
  background: rgba(247, 174, 56, 0.14);
  color: var(--accent);
}

.case-tag.solved::after {
  content: "\2713 Closed";
  color: var(--success);
}

.case-tag.daily.solved::after {
  content: "\2713";
}

#case-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 900;
  line-height: 1.04;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

#case-intro {
  margin: 10px 0 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: clamp(14px, 2.4vw, 16px);
}

.case-question {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: rgba(14, 17, 19, 0.62);
  color: var(--text);
  font-size: clamp(15px, 2.6vw, 18px);
  font-weight: 800;
}

.section-label {
  margin: 22px 0 10px;
  color: var(--desk-hi);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.desk {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.desk-object {
  display: flex;
  min-height: 80px;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid rgba(184, 143, 89, 0.38);
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background:
    linear-gradient(180deg, rgba(247, 244, 233, 0.06), rgba(0, 0, 0, 0.16)),
    #2a3036;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 6px 14px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.desk-object:hover {
  border-color: var(--desk-hi);
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 10px 20px rgba(0, 0, 0, 0.42);
}

.desk-object:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.desk-object.active {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(247, 174, 56, 0.16), rgba(0, 0, 0, 0.12)),
    #2c333a;
}

.desk-object.logged {
  border-color: rgba(82, 199, 140, 0.55);
}

.desk-object-label {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.desk-object-badge {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(14, 17, 19, 0.66);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.desk-object.logged .desk-object-badge {
  background: rgba(82, 199, 140, 0.18);
  color: var(--success);
}

.desk-object.active .desk-object-badge {
  color: var(--accent);
}

/* ---------- Detail readout ---------- */

.detail {
  margin-top: 14px;
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel-2);
}

.detail h3 {
  margin: 0 0 6px;
  color: var(--desk-hi);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.detail p {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.detail-empty {
  color: var(--muted) !important;
  font-style: italic;
}

.detail-note {
  margin-top: 8px !important;
  font-size: 13px !important;
  font-weight: 800;
}

.detail-note.is-evidence {
  color: var(--success) !important;
}

.detail-note.is-deadend {
  color: var(--muted) !important;
}

/* ---------- Status message ---------- */

.message {
  margin: 16px 0 0;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: rgba(14, 17, 19, 0.62);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.message.evidence {
  border-left-color: var(--evidence);
  color: #bfe6ee;
}

.message.hint {
  border-left-color: var(--hint);
  color: #cfe5fb;
}

.message.win {
  border-left-color: var(--success);
  color: #c7f3dd;
}

.message.warning {
  border-left-color: var(--warning);
  color: #ffd2cb;
}

.message.muted {
  border-left-color: var(--muted);
  color: var(--muted);
}

/* ---------- Action bar ---------- */

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.answer-input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #14181c;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.answer-input::placeholder {
  color: rgba(184, 199, 199, 0.55);
  font-weight: 600;
}

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

.answer-input:disabled {
  opacity: 0.6;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background-color 130ms ease, opacity 130ms ease;
}

.button:hover:not(:disabled) {
  border-color: var(--desk-hi);
  transform: translateY(-1px);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button.primary {
  border-color: rgba(247, 174, 56, 0.62);
  background: linear-gradient(180deg, #f7ae38, #d6902a);
  color: #1c1206;
}

.button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffbb4d, #e09b30);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.secondary-actions .button {
  flex: 1 1 auto;
}

.button.ghost {
  background: transparent;
}

.hint-list {
  margin: 12px 0 0;
  padding: 12px 16px 12px 32px;
  border: 1px dashed rgba(115, 179, 235, 0.4);
  border-radius: 10px;
  background: rgba(41, 82, 92, 0.16);
  color: #cfe5fb;
  font-size: 14px;
}

.hint-list li + li {
  margin-top: 6px;
}

/* ---------- Side column ---------- */

.side {
  display: grid;
  gap: 16px;
}

.card {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.card h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card h2 .count {
  color: var(--muted);
  font-size: 12px;
}

.evidence-log {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.evidence-empty {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.evidence-item {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--evidence);
  border-radius: 8px;
  background: rgba(41, 82, 92, 0.16);
}

.evidence-item.key {
  border-left-color: var(--accent);
  background: rgba(247, 174, 56, 0.1);
}

.evidence-item strong {
  color: var(--text);
  font-size: 13.5px;
}

.evidence-item span {
  color: var(--muted);
  font-size: 12.5px;
}

.case-list {
  display: grid;
  gap: 8px;
}

.case-pill {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 130ms ease, background-color 130ms ease, transform 130ms ease;
}

.case-pill:hover {
  border-color: var(--desk-hi);
  transform: translateX(2px);
}

.case-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.case-pill.active {
  border-color: var(--accent);
  background: rgba(247, 174, 56, 0.1);
}

.case-pill-mark {
  display: grid;
  width: 26px;
  height: 26px;
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(14, 17, 19, 0.6);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.case-pill.solved .case-pill-mark {
  border-color: rgba(82, 199, 140, 0.6);
  background: rgba(82, 199, 140, 0.18);
  color: var(--success);
}

.case-pill-name {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-pill-tag {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.case-pill.daily {
  border-color: rgba(247, 174, 56, 0.5);
}

.case-pill.daily .case-pill-tag {
  color: var(--accent);
}

.card p.rule {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Responsive: portrait-first single column ---------- */

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .shell {
    width: calc(100% - 20px);
    padding-top: 12px;
  }

  .desk-surface {
    border-radius: 16px;
    padding: 14px;
  }

  .desk {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
  }

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

  .progress-label {
    display: none;
  }
}
