:root {
  color-scheme: light;
  font-family: "Be Vietnam Pro", Inter, ui-sans-serif, system-ui, sans-serif;
  --ink: #10202b;
  --muted: #596875;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #c9d8d5;
  --accent: #14b8a6;
  --accent-dark: #0f766e;
  --yes: #16a34a;
  --no: #dc2626;
  --warn: #f59e0b;
  --surface: #f8fafc;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    radial-gradient(circle at 16% 20%, rgba(20, 184, 166, 0.25), transparent 30%),
    radial-gradient(circle at 88% 82%, rgba(244, 114, 182, 0.18), transparent 26%),
    linear-gradient(135deg, #ecfeff 0%, #f8fafc 48%, #fef9c3 100%);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

button { font: inherit; }

.app { max-width: 1220px; margin: 0 auto; padding: 18px 16px 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 92px; margin-bottom: 14px; }
.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 999px;
  padding: 10px 14px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2.15rem, 5vw, 4.4rem); line-height: 0.95; }
h2 { margin-bottom: 8px; font-size: clamp(1.2rem, 2vw, 1.75rem); line-height: 1.14; }
h3 { margin-bottom: 12px; }
p { color: var(--muted); line-height: 1.6; }
.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.layout { display: grid; gap: 14px; }
.panel {
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 0.82fr);
  align-items: end;
  gap: 18px;
  padding: 18px;
}
.intro-panel p { max-width: 760px; margin-bottom: 0; }
.game-panel { padding: 14px; overflow: hidden; }

.score-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.score-strip span {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}
.score-strip strong { color: var(--ink); font-size: 1.45rem; line-height: 1; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(210px, max-content) 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.level-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.level-button, .primary-button, .secondary-button {
  min-height: 42px;
  border: 1px solid rgba(16, 32, 43, 0.12);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.level-button, .secondary-button { background: #fff; color: var(--ink); }
.primary-button, .level-button.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(20, 184, 166, 0.22);
}
.level-button:hover, .secondary-button:hover { transform: translateY(-1px); }

.case-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid rgba(16, 32, 43, 0.08);
  border-bottom: 1px solid rgba(16, 32, 43, 0.08);
  margin-bottom: 14px;
  padding: 14px 2px 12px;
}
.case-head h2 { margin-bottom: 0; }
.play-grid { display: grid; grid-template-columns: minmax(250px, 0.72fr) minmax(0, 1.28fr); gap: 16px; align-items: start; }
.clue-panel {
  border-left: 5px solid var(--accent);
  background: transparent;
  padding: 4px 0 4px 14px;
}
.clue-panel ol { margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.58; font-weight: 750; }
.clue-panel li + li { margin-top: 8px; }

.matrix-wrap {
  overflow: auto;
  display: grid;
  justify-content: center;
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: clamp(10px, 2vw, 18px);
}
.matrix {
  display: grid;
  grid-template-columns: minmax(112px, 1.1fr) repeat(var(--size), minmax(52px, 72px));
  width: max-content;
  min-width: auto;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.matrix-cell {
  min-height: 52px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.matrix-cell.header, .matrix-cell.row-header {
  display: grid;
  place-items: center;
  padding: 8px;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
}
.matrix-cell.header { background: #ccfbf1; position: sticky; top: 0; z-index: 2; }
.matrix-cell.row-header { justify-content: start; background: #f0fdfa; text-align: left; position: sticky; left: 0; z-index: 1; }
.matrix-cell.choice {
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 900;
  transition: transform 0.12s ease, background 0.12s ease;
}
.matrix-cell.choice:hover { transform: scale(1.04); z-index: 3; }
.matrix-cell.choice.yes { color: var(--yes); background: #dcfce7; }
.matrix-cell.choice.no { color: var(--no); background: #fee2e2; }
.matrix-cell.choice.hint { outline: 3px solid var(--warn); outline-offset: -4px; }

.answer-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  margin-top: 14px;
  border-top: 1px solid rgba(16, 32, 43, 0.08);
  padding-top: 12px;
}
.answer-pill {
  border: 1px solid rgba(16, 32, 43, 0.1);
  border-radius: 999px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 900;
}
.answer-pill.done { color: var(--yes); background: #dcfce7; }

.status {
  min-height: 44px;
  margin-top: 12px;
  border-radius: 8px;
  background: #ecfeff;
  border: 1px solid rgba(20, 184, 166, 0.18);
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 920px) {
  .intro-panel, .play-grid { grid-template-columns: 1fr; }
  .score-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .case-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .app { padding-inline: 10px; }
  .intro-panel, .game-panel, .clue-panel { padding: 12px; }
  .score-strip { grid-template-columns: 1fr; }
  .level-button, .primary-button, .secondary-button { flex: 1 1 auto; padding-inline: 10px; }
  .toolbar { grid-template-columns: 1fr; }
  .level-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .matrix-wrap { justify-content: start; }
}
