:root {
  color-scheme: dark;
  --ink: #eaf4f6;
  --muted: #9bb1b8;
  --canvas: #06171e;
  --surface: #0c2530;
  --surface-raised: #113441;
  --line: #24505d;
  --accent: #11bea5;
  --accent-deep: #0d806f;
  --raise: #ee4550;
  --passive: #5fc06a;
  --fold: #4386bf;
  --danger: #ff8c80;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 25% -15%, #135064 0, transparent 34rem), var(--canvas);
  color: var(--ink);
}

button { font: inherit; }

button:focus-visible { outline: 3px solid #f5c95e; outline-offset: 3px; }

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(34px, env(safe-area-inset-bottom));
}

.topbar, .section-heading, .detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.topbar { margin: 4px 2px 18px; justify-content: flex-start; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid #2e7784;
  border-radius: 14px;
  background: linear-gradient(145deg, #155a6b, #0b2832);
  color: var(--accent);
  font-size: 28px;
  box-shadow: 0 8px 30px #0006;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 5vw, 1.7rem); letter-spacing: .02em; }
h2 { font-size: clamp(1.18rem, 4vw, 1.48rem); }
h3 { font-size: clamp(1.08rem, 3.7vw, 1.3rem); line-height: 1.4; }
.eyebrow { color: var(--accent); font-size: .73rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.mini-heading { color: var(--muted); font-size: .82rem; font-weight: 700; letter-spacing: .04em; }

.icon-button, .dialog-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-button { margin-left: auto; font-size: 1.25rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #071e27cc; }
.tab { min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 750; cursor: pointer; }
.tab.is-active { background: var(--surface-raised); color: var(--ink); box-shadow: 0 4px 12px #0005; }

.view { display: none; padding-top: 25px; }
.view.is-visible { display: block; }
.count-pill { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #2c6c77; border-radius: 999px; color: #bcecf0; background: #0c313b; font-size: .78rem; font-weight: 800; }

.filter-panel, .range-detail, .quiz-card, .quiz-note { margin-top: 18px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(160deg, #0d2934, #081e27); box-shadow: 0 15px 32px #0003; }
.filter-panel { padding: 14px; display: grid; gap: 15px; }
.filter-group { display: grid; gap: 8px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.segmented button, .scene-filter-grid button { min-height: 38px; border: 1px solid #295562; border-radius: 10px; background: #09232d; color: #b7cbd0; cursor: pointer; font-weight: 700; }
.segmented button.is-active, .scene-filter-grid button.is-active { border-color: var(--accent); background: #0f514e; color: #e1fffb; }
.scene-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.scene-filter-grid button { min-height: 51px; padding: 6px 8px; font-size: .78rem; line-height: 1.25; text-align: left; }

.range-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.range-card { min-height: 118px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.range-card:hover { transform: translateY(-2px); border-color: #4b8b98; }
.range-card.is-selected { border-color: var(--accent); background: #10404a; box-shadow: inset 0 0 0 1px #0a756e, 0 9px 20px #0004; }
.range-card-stack { display: block; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .07em; }
.range-card-label { display: block; margin: 8px 0 5px; line-height: 1.35; }
.range-card-meta { color: var(--muted); font-size: .76rem; }
.empty-state { grid-column: 1 / -1; padding: 22px; border: 1px dashed #3d6973; border-radius: 14px; color: var(--muted); text-align: center; }

.range-detail { padding: clamp(14px, 4vw, 24px); }
.detail-heading { align-items: flex-start; }
.detail-heading h2 { margin-top: 4px; line-height: 1.35; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--accent); font-weight: 800; white-space: nowrap; cursor: pointer; }

.hand-explorer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 20px 0; padding: 14px; border: 1px solid #244d59; border-radius: 14px; background: #081e27; }
.hand-grid { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 2px; margin-top: 9px; }
.hand-button { aspect-ratio: 1 / .72; min-width: 0; padding: 1px; border: 1px solid #265264; border-radius: 3px; background: #133847; color: #e7f5f7; font-size: clamp(.43rem, 1.8vw, .73rem); cursor: pointer; }
.hand-button:hover { background: #216175; }
.hand-button.is-selected { outline: 2px solid #f5ca5a; outline-offset: 1px; background: #29687a; }
.hand-decision { display: grid; align-content: center; min-height: 74px; padding: 14px; border-left: 3px solid var(--line); border-radius: 8px; background: #0a2630; }
.decision-muted { color: var(--muted); font-size: .9rem; }
.decision-name { font-size: 1.1rem; font-weight: 850; }
.decision-raise { border-color: var(--raise); }.decision-passive { border-color: var(--passive); }.decision-fold { border-color: var(--fold); }
.decision-detail { margin-top: 5px; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.range-figure { margin: 0; }
.range-image-button { display: block; width: 100%; padding: 0; overflow: hidden; border: 1px solid #2d5965; border-radius: 12px; background: #111; cursor: zoom-in; }
.range-image-button img { display: block; width: 100%; height: auto; }
.range-figure figcaption { margin-top: 9px; color: var(--muted); font-size: .76rem; line-height: 1.55; }

.quiz-card { padding: clamp(18px, 5vw, 30px); text-align: center; }
.quiz-stack { color: var(--accent); font-size: .8rem; font-weight: 800; letter-spacing: .05em; }
.quiz-card h3 { max-width: 650px; margin: 10px auto 0; }
.quiz-prompt { margin-top: 14px; color: var(--muted); }
.quiz-hand { display: block; margin: 16px 0; color: #fff6d8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(2.5rem, 14vw, 4.6rem); font-weight: 900; line-height: 1; letter-spacing: -.08em; }
.quiz-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quiz-choice { min-height: 61px; padding: 8px; border: 1px solid #365866; border-radius: 12px; background: #0b2833; color: var(--ink); font-size: clamp(.78rem, 3.1vw, .98rem); font-weight: 800; cursor: pointer; }
.quiz-choice[data-action="fold"] { border-bottom: 4px solid var(--fold); }.quiz-choice[data-action="passive"] { border-bottom: 4px solid var(--passive); }.quiz-choice[data-action="raise"] { border-bottom: 4px solid var(--raise); }
.quiz-choice:disabled { cursor: default; opacity: .65; }.quiz-choice.is-correct { background: #175637; border-color: #74e594; opacity: 1; }.quiz-choice.is-wrong { background: #5b2631; border-color: var(--danger); opacity: 1; }
.quiz-feedback { margin: 18px auto 0; padding: 12px; border-radius: 12px; font-weight: 800; line-height: 1.5; }.quiz-feedback.is-correct { background: #164c33; color: #b5f7c3; }.quiz-feedback.is-wrong { background: #562834; color: #ffd1cb; }
.quiz-answer-image { margin-top: 20px; text-align: left; }.quiz-answer-image .mini-heading { margin-bottom: 8px; }
.primary-button { margin-top: 20px; padding: 12px 22px; border: 0; border-radius: 12px; background: var(--accent); color: #06252a; font-weight: 900; cursor: pointer; }
.quiz-note { padding: 14px; color: var(--muted); font-size: .82rem; line-height: 1.6; }

.image-dialog { width: min(96vw, 1600px); max-width: none; max-height: 96vh; padding: 0; overflow: auto; border: 1px solid #43808c; border-radius: 12px; background: #07171e; }
.image-dialog::backdrop { background: #000b; backdrop-filter: blur(4px); }
.image-dialog img { display: block; width: max-content; min-width: 100%; max-width: none; max-height: 94vh; object-fit: contain; }
.dialog-close { position: fixed; top: 14px; right: 14px; z-index: 2; border-color: #84bfc8; background: #041419e8; font-size: 26px; line-height: 1; }

@media (min-width: 680px) {
  .app-shell { padding-inline: 24px; }
  .filter-panel { grid-template-columns: 220px 1fr; align-items: end; }
  .scene-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hand-explorer { grid-template-columns: minmax(0, 1.65fr) minmax(190px, .65fr); align-items: center; }
  .hand-decision { min-height: 130px; }
}

@media (max-width: 390px) {
  .app-shell { padding-inline: 11px; }
  .range-cards { grid-template-columns: 1fr 1fr; gap: 7px; }
  .range-card { min-height: 110px; padding: 10px; }
}
