.tool-shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; padding: 44px 0 110px; }
.tool-title {
  min-height: 210px;
  display: grid;
  align-content: center;
  padding: 34px clamp(24px, 5vw, 62px);
  border-left: 12px solid var(--red);
  border-radius: 0 18px 18px 0;
  background: linear-gradient(105deg, var(--surface) 0 58%, color-mix(in srgb, var(--green) 16%, var(--surface)));
  box-shadow: var(--shadow);
}
.tool-title p { margin: 0; color: var(--green); font-size: 13px; font-weight: 600; }
html[data-theme="dark"] .tool-title p,
html[data-theme="dark"] .status-line p { color: var(--green-strong); }
.tool-title h1 { margin: 8px 0 0; font-size: clamp(38px, 6vw, 66px); letter-spacing: -.06em; line-height: 1; }
.tool-title > span,
.tool-title > div > span { max-width: 60ch; margin-top: 12px; color: var(--muted); line-height: 1.75; }
.tool-card {
  margin-top: 20px;
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.status-line h2 { margin: 0; font-size: clamp(23px, 3vw, 32px); }
.status-line p { margin: 0; color: var(--green); font-size: 12px; font-weight: 600; }
.stats-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stats-grid article { min-height: 120px; display: grid; align-content: center; padding: 20px; border-radius: 13px; color: #fff; }
.stats-grid article:nth-child(1) { background: var(--red); }
.stats-grid article:nth-child(2) { background: var(--green); }
.stats-grid article:nth-child(3) { background: var(--gold); color: #241b00; }
.stats-grid article:nth-child(4) { background: #182345; }
.stats-grid span { font-size: 11px; font-weight: 500; }
.stats-grid strong { margin-top: 12px; font: 950 30px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.table { margin-top: 18px; overflow: visible; border: 1px solid var(--line); border-radius: 14px; }
.row { min-height: 50px; display: grid; grid-template-columns: 1fr 1.2fr .8fr; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 12px; }
.row:last-child { border-bottom: 0; }
.row.head { background: linear-gradient(90deg, var(--red), var(--green)); color: #fff; font-weight: 600; }
.table > .row.head {
  position: sticky;
  top: 0;
  z-index: 6;
  border-radius: 13px 13px 0 0;
  box-shadow: 0 8px 18px rgba(25, 37, 74, .16);
}
.history-table [data-history-rows] { min-height: 2500px; background: var(--surface); }
body[data-page="today"] [data-rows] { min-height: 2000px; background: var(--surface); }
.row span:nth-child(2) { text-align: center; font-weight: 600; }
.row span:last-child { text-align: right; color: var(--muted); }
.row.head span:last-child { color: #fff; }
.safe-note { margin: 18px 0 0; padding: 16px 18px; border-left: 5px solid var(--green); background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1.7; }

.sub-tabs { margin-top: 18px; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: thin; }
.sub-tabs button { min-height: 44px; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.sub-tabs .icon { width: 18px; height: 18px; }
.sub-tabs button[aria-selected="true"] { border-color: var(--red); background: var(--red); color: #fff; }
.omission-panels { margin-top: 20px; }
.omission-panels > section > h3 { margin: 0 0 13px; font-size: 18px; }
.omission-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.omission-grid article { min-width: 0; min-height: 104px; display: grid; align-content: center; padding: 12px 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); text-align: center; }
.omission-grid article:nth-child(3n + 1) { border-top: 4px solid var(--red); }
.omission-grid article:nth-child(3n + 2) { border-top: 4px solid var(--green); }
.omission-grid article:nth-child(3n) { border-top: 4px solid var(--gold); }
.omission-grid article span,
.omission-grid article small { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.omission-grid article strong { display: block; margin: 7px 0; color: var(--red); font: 950 23px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.omission-grid-basic,
.omission-grid-combination,
.omission-grid-wave { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.omission-grid-pattern { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.omission-grid-dragon-tiger,
.omission-grid-zone { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.omission-grid-extreme { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.probability-demo { display: grid; grid-template-columns: .82fr 1.18fr; gap: 18px; }
.demo-controls { padding: 26px; border-radius: 15px; background: #182345; color: #fff; }
.demo-controls h2 { margin: 0; font-size: 28px; }
.demo-controls > p { color: #c3d4c8; line-height: 1.7; }
.digit-control { display: grid; grid-template-columns: 32px 1fr 40px; align-items: center; gap: 12px; margin-top: 18px; }
.digit-control label { color: var(--gold); font-weight: 600; }
.digit-control input { width: 100%; accent-color: var(--red); }
.digit-control output { min-height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: #fff; font: 950 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.demo-result { display: grid; align-content: center; justify-items: center; min-height: 330px; padding: 24px; border: 10px solid var(--red); border-radius: 50%; background: var(--gold); color: #201800; text-align: center; }
.demo-equation { display: flex; align-items: center; gap: 9px; font: 950 clamp(28px, 5vw, 48px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.demo-result > strong { margin-top: 16px; font-size: 18px; }
.demo-tags { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.demo-tags b { min-height: 30px; display: grid; place-items: center; padding: 0 10px; border-radius: 8px; background: #fff; }
.distribution { margin-top: 18px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.distribution article { min-height: 94px; display: grid; align-content: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.distribution article:nth-child(4n + 1) { border-bottom: 5px solid var(--red); }
.distribution article:nth-child(4n + 2) { border-bottom: 5px solid var(--green); }
.distribution article:nth-child(4n + 3) { border-bottom: 5px solid var(--gold); }
.distribution span { color: var(--muted); font-size: 10px; }
.distribution strong { margin-top: 5px; font: 950 23px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.distribution small { margin-top: 5px; color: var(--muted); }

.history-controls { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.history-controls p { margin: 0; color: var(--muted); }
.history-controls select { min-height: 42px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); }
.archive-pager { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; }
.archive-pager button { min-height: 44px; display: inline-flex; align-items: center; gap: 7px; padding: 0 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-weight: 600; cursor: pointer; }
.archive-pager button:disabled { opacity: .4; cursor: not-allowed; }
.archive-pager > span { min-width: 110px; color: var(--muted); text-align: center; font-size: 12px; }

.tool-title-art { grid-template-columns: minmax(260px, .85fr) 1.15fr; align-items: center; gap: 24px; }
.tool-title-art > div { min-width: 0; }
.tool-title-art picture,
.tool-title-art img { width: 100%; height: 250px; object-fit: cover; object-position: center right; border-radius: 14px; }
.games-catalog { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.game-card { min-width: 0; min-height: 130px; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 15px; padding: 18px; border: 1px solid var(--line); border-left: 7px solid var(--game-tone); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.game-card-art { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--game-tone) 16%, var(--surface)); color: var(--game-tone); }
.game-card-art .icon { width: 29px; height: 29px; }
.game-card-copy { min-width: 0; }
.game-card-copy h2 { margin: 0; font-size: 16px; }
.game-card-copy p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.game-card-copy small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.game-card > button { min-height: 42px; padding: 0 13px; border: 1px solid var(--game-tone); border-radius: 9px; background: transparent; color: var(--game-tone); font-size: 11px; font-weight: 600; cursor: pointer; }
.game-card > button::after { content: ""; width: 16px; height: 16px; display: inline-block; margin-left: 5px; vertical-align: -3px; background: currentColor; -webkit-mask: url("/assets/icons/play.svg?v=s05-20261017-geo-v1") center / contain no-repeat; mask: url("/assets/icons/play.svg?v=s05-20261017-geo-v1") center / contain no-repeat; }
.game-card > button:hover,
.game-card > button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; background: var(--game-tone); color: #fff; }
.tone-red, .tone-purple, .tone-pink { --game-tone: var(--red); }
.tone-green, .tone-cyan, .tone-teal { --game-tone: var(--green); }
.tone-orange, .tone-yellow { --game-tone: #b07e00; }
.tone-blue, .tone-indigo { --game-tone: #24382b; }

body.game-window-open { overflow: hidden; }
body.game-window-open .chat-launch { display: none; }
.game-window { width: min(920px, calc(100vw - 40px)); max-width: none; height: min(690px, calc(100dvh - 56px)); max-height: none; padding: 0; overflow: hidden; border: 2px solid var(--green); border-radius: 15px; background: #0f1733; box-shadow: 0 28px 90px rgba(0,0,0,.46); }
.game-window::backdrop { background: rgba(7,16,10,.68); backdrop-filter: blur(7px); }
.game-window.is-maximized { width: calc(100vw - 18px); height: calc(100dvh - 18px); }
.game-window-shell { height: 100%; display: grid; grid-template-rows: 48px minmax(0, 1fr); }
.game-window-bar { padding: 0 8px 0 15px; display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; border-bottom: 4px solid var(--gold); background: var(--red); color: #fff; }
.game-window-bar strong { overflow: hidden; font-size: 12px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.window-lights { display: flex; gap: 7px; }
.window-lights i { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.window-lights i:nth-child(2) { background: var(--gold); }
.window-lights i:nth-child(3) { background: var(--green); }
.game-window-actions { display: flex; justify-content: flex-end; gap: 4px; }
.game-window-actions button { width: 34px; height: 32px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.32); border-radius: 7px; background: transparent; color: #fff; cursor: pointer; }
.game-window-actions .icon { width: 17px; height: 17px; }
.game-window-stage { position: relative; min-height: 0; background: #0f1733; }
.game-window-stage iframe { width: 100%; height: 100%; display: block; border: 0; background: #0f1733; }
.game-loading { position: absolute; z-index: 2; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: #e2e7ff; font-size: 11px; background: #0f1733; }
.game-loading[hidden] { display: none; }
.game-loading span { width: 25px; height: 25px; border: 3px solid rgba(255,255,255,.18); border-top-color: var(--gold); border-radius: 50%; animation: game-spin .8s linear infinite; }
@keyframes game-spin { to { transform: rotate(360deg); } }

.not-found-link { min-height: 48px; width: max-content; margin-top: 22px; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; border-radius: 11px; background: var(--red); color: #fff; font-weight: 600; }

@media (max-width: 820px) {
  .tool-shell { width: min(100% - 28px, 1180px); padding-top: 30px; }
  .tool-title { min-height: 180px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .probability-demo { grid-template-columns: 1fr; }
  .demo-result { width: min(100%, 390px); justify-self: center; aspect-ratio: 1; }
  .distribution { grid-template-columns: repeat(4, 1fr); }
  .games-catalog { grid-template-columns: 1fr; }
  .omission-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .omission-grid-basic,
  .omission-grid-combination,
  .omission-grid-wave,
  .omission-grid-pattern,
  .omission-grid-dragon-tiger,
  .omission-grid-zone,
  .omission-grid-extreme { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .tool-shell { width: min(100% - 20px, 1180px); padding-bottom: 86px; }
  .tool-title { min-height: 164px; padding: 26px 20px; border-left-width: 8px; }
  .tool-title h1 { font-size: 37px; }
  .tool-card { padding: 15px; }
  .status-line { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid article { min-height: 100px; padding: 15px; }
  .row { grid-template-columns: 1fr auto; }
  .row span:nth-child(2) { grid-column: 1 / 3; grid-row: 2; text-align: left; }
  .row span:last-child { grid-column: 2; grid-row: 1; }
  .distribution { grid-template-columns: repeat(3, 1fr); }
  .history-controls { grid-template-columns: 1fr; }
  .archive-pager { flex-wrap: wrap; }
  .tool-title-art { grid-template-columns: 1fr; }
  .tool-title-art picture,
  .tool-title-art img { height: 180px; }
  .game-card { grid-template-columns: 54px minmax(0,1fr) 42px; gap: 10px; padding: 12px; }
  .game-card-art { width: 50px; height: 50px; }
  .game-card-copy small { display: none; }
  .game-card > button { width: 42px; padding: 0; overflow: hidden; color: transparent; font-size: 0; }
  .game-card > button::after { width: 20px; height: 20px; margin: 0; background: var(--game-tone); }
  .game-window,
  .game-window.is-maximized { width: calc(100vw - 10px); height: calc(100dvh - 10px); border-radius: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .game-loading span { animation: none; }
}
