:root {
  color-scheme: dark;
  --bg: #202020;
  --paper: #272727;
  --text: #e8e8e8;
  --muted: #a0a0a0;
  --faint: #7a7a7a;
  --line: #333333;
  --gutter: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

.window {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Editor area (scrolls vertically only, with the scrollbar hidden) */
.editor {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
  padding: 24px var(--gutter) 40px;
  background: var(--paper);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 15px;
  line-height: 1.5;
}

.editor::-webkit-scrollbar { display: none; }

.page-title {
  margin: 0 0 24px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
}

/* 95% of the screen width, centered; height follows the video's own aspect ratio */
.hero {
  display: block;
  width: 95vw;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 0 0 48px calc(50% - 47.5vw);
  border-radius: 12px;
  border: none;
  outline: none;
  background: var(--bg);
  object-fit: cover;
}

/* Contents list on the left, article on the right */
/* The bottom space lets the last sections scroll up far enough to become the current one */
.content {
  display: grid;
  grid-template-columns: 208px minmax(0, 680px);
  justify-content: center;
  gap: 56px;
  padding-bottom: 40vh;
}

.toc {
  position: sticky;
  top: 8px;
  align-self: start;
  font-size: 13px;
  line-height: 1.4;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: section;
}

.toc li {
  display: flex;
  gap: 1ch;
  margin-bottom: 14px;
  color: var(--faint);
  counter-increment: section;
  transition: color 0.2s;
}

/* Section number, in the same monospace font as the rest of the page */
.toc li::before {
  content: counter(section) ".";
  flex: none;
}

.toc a {
  color: inherit;
  text-decoration: none;
}

.toc li:hover,
.toc li.active { color: var(--text); }

.article h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  scroll-margin-top: 16px;
}

.article p {
  margin: 0 0 16px;
  color: #d4d4d4;
  line-height: 1.7;
}

.article p + h2 { margin-top: 40px; }

/* Looping poker clip under the Introduction (built by poker.js); sizes scale with its width */
.poker {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 16 / 9;
  margin: 4px 0 24px;
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  user-select: none;
}

/* Fades the scene out between loops (a cover layer, since opacity on cards would break their 3D flip) */
.poker::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
}

.poker.fade::after { opacity: 1; }

.poker .table {
  position: absolute;
  inset: 24% 20% 22%;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.poker .board {
  position: absolute;
  left: 50%;
  top: 55%;
  display: flex;
  gap: 1.2cqw;
  transform: translate(-50%, -50%);
}

.poker .card {
  position: relative;
  width: 7.5cqw;
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  transition: transform 0.9s ease;
}

.poker .card.up { transform: rotateY(180deg); }

/* Opacity goes on the faces, not the card, so the flip stays 3D */
.poker .face {
  position: absolute;
  inset: 0;
  border-radius: 0.8cqw;
  backface-visibility: hidden;
  transition: opacity 0.6s;
}

.poker .board .card:not(.dealt) .face { opacity: 0; }
.poker .board .card.unused .face { opacity: 0.3; }

.poker .back {
  background: #3a3a3a;
  box-shadow: inset 0 0 0 0.6cqw #333333;
}

.poker .front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotateY(180deg);
  background: #e8e8e8;
  color: #1a1a1a;
  font-size: 2.6cqw;
  font-weight: 600;
  line-height: 1.1;
}

.poker .front.red { color: #c94a4a; }

.poker .seat {
  position: absolute;
  width: 26cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqw;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--faint);
  transition: color 0.6s;
}

.poker .seat.left { left: 13%; top: 50%; }
.poker .seat.top { left: 50%; top: 22%; }
.poker .seat.right { left: 87%; top: 50%; }

.poker .name { font-size: clamp(10px, 2cqw, 14px); }
.poker .hole { display: flex; gap: 0.8cqw; }

/* Reserve two lines so revealing the hand name doesn't shift the seat */
.poker .hand {
  min-height: 2.6em;
  font-size: clamp(9px, 1.7cqw, 12px);
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.6s;
}

.poker .seat.shown .hand { opacity: 1; }

/* A player's current bet, shown in the hand-name slot before the showdown */
.poker .bet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.6em;
  font-size: clamp(9px, 1.7cqw, 12px);
  line-height: 1.3;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.6s;
}

.poker .seat.betting .bet { opacity: 1; }

.poker .pot {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: clamp(10px, 1.8cqw, 13px);
  color: var(--muted);
}
.poker .seat.active { color: var(--text); }
.poker .seat.won .name::after { content: " · wins"; }

.poker .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5%;
  margin: 0;
  text-align: center;
  font-size: clamp(10px, 2cqw, 14px);
  color: var(--muted);
}

/* Status bar */
.statusbar {
  display: flex;
  min-height: 28px;
  align-items: center;
  background: var(--bg);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.statusbar span {
  padding: 5px 14px;
}

/* Narrow screens: hide the contents list, as the reference site does */
@media (max-width: 960px) {
  .content { grid-template-columns: minmax(0, 680px); padding-bottom: 0; }
  .toc { display: none; }
}

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .editor { padding: 16px var(--gutter) 32px; }
  .hero { margin-bottom: 32px; }
}
