:root {
  --night: #0f1620;
  --panel: #172230;
  --edge: #263445;
  --felt: #1d5fa8;
  --felt-deep: #134a86;
  --gold: #e8b546;
  --gold-soft: #f3d28a;
  --wood: #5a3a22;
  --wood-dark: #3b2414;
  --ink: #edf1f6;
  --dim: #9fb0c3;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); font: 17px/1.7 var(--sans); overflow-x: hidden;
  background: radial-gradient(1200px 500px at 50% -120px, rgba(29,95,168,.35), transparent 70%), var(--night);
}
a { color: var(--gold-soft); text-underline-offset: 3px; }
a:hover { color: #fff; }
img { display: block; max-width: 100%; height: auto; }
.skip { position: absolute; left: -999px; top: 0; padding: 8px 12px; background: var(--gold); color: #000; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* header */
.top { max-width: 1140px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: .5px; }
.logo.small { margin: 0 0 10px; font-size: 19px; justify-content: center; }
.logo-ball {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #111;
  background: radial-gradient(circle at 50% 50%, #fff 0 34%, transparent 35%), radial-gradient(circle at 35% 30%, #4b4b4b, #000 70%);
}
.top-nav { display: flex; gap: 16px; }
.top-nav a { color: var(--dim); text-decoration: none; font-size: 15px; font-weight: 600; }
.top-nav a:hover { color: #fff; }

/* play area */
.hall { max-width: 1060px; margin: 0 auto; padding: 0 16px 6px; }
h1 { margin: 0 0 12px; font-size: clamp(26px, 3.4vw, 36px); line-height: 1.15; font-weight: 900; letter-spacing: .5px; }
.rail {
  position: relative; padding: 14px; border-radius: 22px;
  background: linear-gradient(180deg, #6b4529, var(--wood) 40%, var(--wood-dark));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.12), inset 0 -3px 0 rgba(0,0,0,.35), 0 24px 48px -20px rgba(0,0,0,.8);
}
.rail::before, .rail::after { /* diamond sights on the rail */
  content: ""; position: absolute; left: 12%; right: 12%; height: 6px; pointer-events: none;
  background: radial-gradient(circle, #e9dcc0 0 2.5px, transparent 3px) 0 0 / 12.5% 6px repeat-x;
}
.rail::before { top: 4px; }
.rail::after { bottom: 4px; }
.game { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; box-shadow: 0 0 0 2px var(--felt-deep); }
.game > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.game iframe { border: 0; }
.start { padding: 0; border: 0; margin: 0; cursor: pointer; background: #000; font: inherit; color: #fff; }
.start img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); transition: filter .2s; }
.start:hover img, .start:focus-visible img { filter: brightness(.7); }
.start-btn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 16px 38px 16px 64px; border-radius: 999px; font-size: clamp(18px, 2.4vw, 26px); font-weight: 900; color: #1b1406;
  background: linear-gradient(180deg, #f8d77e, var(--gold)); box-shadow: 0 6px 0 #a87b1e, 0 14px 30px rgba(0,0,0,.55);
}
.start-btn::before { content: ""; position: absolute; left: 30px; top: 50%; transform: translateY(-50%); border-left: 16px solid #1b1406; border-top: 10px solid transparent; border-bottom: 10px solid transparent; }
.start-note { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 13px; color: #dfe6ee; text-shadow: 0 1px 2px #000; }

.racking {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 16px;
  background: radial-gradient(circle at 50% 45%, var(--felt) 0, var(--felt-deep) 55%, #0b2b52 100%);
}
.racking[hidden] { display: none; }
.rack { position: relative; width: 84px; height: 74px; }
.rack i { position: absolute; width: 26px; height: 26px; border-radius: 50%; box-shadow: inset -3px -4px 6px rgba(0,0,0,.35); animation: pop 1.2s ease-in-out infinite; }
.rack i:nth-child(1) { left: 29px; top: 0; background: #f2c21b; }
.rack i:nth-child(2) { left: 15px; top: 24px; background: #1f4fd1; animation-delay: .1s; }
.rack i:nth-child(3) { left: 43px; top: 24px; background: #111; animation-delay: .2s; }
.rack i:nth-child(4) { left: 1px; top: 48px; background: #d82424; animation-delay: .3s; }
.rack i:nth-child(5) { left: 29px; top: 48px; background: #6b2fb0; animation-delay: .4s; }
.rack i:nth-child(6) { left: 57px; top: 48px; background: #f07b16; animation-delay: .5s; }
@keyframes pop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }
.racking-title { margin: 0; font-weight: 800; font-size: clamp(17px, 2vw, 22px); }
.racking-sub { margin: 0; color: #cfe0f5; font-size: 14px; }

.under { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 2px 0; }
.hint { margin: 0; color: var(--dim); font-size: 14px; }
.buttons { display: flex; gap: 8px; }
.b { min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--edge); background: var(--panel); color: #fff; font: 700 15px var(--sans); cursor: pointer; }
.b:hover { border-color: var(--gold); }
.b-gold { background: var(--gold); border-color: var(--gold); color: #1b1406; }
.b-gold:hover { background: #f8d77e; }
.toast { margin: 6px 2px 0; color: var(--gold-soft); font-size: 14px; }
kbd { display: inline-block; min-width: 22px; padding: 0 5px; margin: 0 1px; border-radius: 5px; border: 1px solid #3a4b60; border-bottom-width: 3px; background: #1c2a3b; color: #fff; font: 700 13px/1.6 var(--sans); text-align: center; }

/* text */
.text { max-width: 780px; margin: 0 auto; padding: 10px 16px 48px; }
.text section { padding-top: 30px; }
h2 { margin: 0 0 14px; font-size: clamp(23px, 3vw, 30px); line-height: 1.25; font-weight: 900; }
h2::after { content: ""; display: block; width: 56px; height: 4px; margin-top: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--gold), transparent); }
h3 { margin: 0 0 8px; font-size: 18px; color: var(--gold-soft); }
p, ul, ol { margin: 0 0 14px; }
li { margin-bottom: 8px; }
b, strong { color: #fff; }
.pic { margin: 20px 0 8px; }
.pic img { border-radius: 10px; border: 1px solid var(--edge); }
.pic figcaption { margin-top: 8px; color: var(--dim); font-size: 14px; }

.ctl { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ctl-col { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 16px; }
.ctl-col ul { list-style: none; padding: 0; margin: 0; font-size: 15px; }

.modes { margin: 0 0 14px; display: grid; gap: 10px; }
.modes div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--panel); border-left: 4px solid var(--felt); }
.modes dt { font-weight: 800; color: #fff; }
.modes dd { margin: 0; color: #d3dce7; }

.rules { list-style: none; counter-reset: r; padding: 0; }
.rules li { counter-increment: r; position: relative; padding-left: 48px; min-height: 34px; }
.rules li::before {
  content: counter(r); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #111;
  background: radial-gradient(circle, #fff 0 42%, var(--gold) 44%);
}

.qa { padding: 14px 0; border-bottom: 1px solid var(--edge); }
.qa h3 { color: #fff; font-size: 17px; margin-bottom: 4px; }
.qa p { margin: 0; color: #d3dce7; }

/* footer */
.foot { text-align: center; padding: 28px 16px 36px; border-top: 1px solid var(--edge); background: #0b1118; }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin-bottom: 10px; }
.foot nav a { color: var(--dim); text-decoration: none; font-size: 14px; }
.foot nav a:hover { color: #fff; }
.fine { margin: 0; color: #6f8197; font-size: 13px; }

/* sub pages */
.doc { max-width: 760px; margin: 0 auto; padding: 8px 16px 48px; }
.trail { margin: 4px 0 0; font-size: 14px; color: var(--dim); }
.trail a { color: var(--dim); }

/* fullscreen */
.game:fullscreen { border-radius: 0; aspect-ratio: auto; box-shadow: none; }
.game.fake-full { position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100vh; height: 100dvh; aspect-ratio: auto; border-radius: 0; }
body.locked { overflow: hidden; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .top-nav { gap: 12px; }
  .top-nav a { font-size: 14px; }
  .hall { padding: 0 10px 6px; }
  h1 { padding: 0 6px; }
  .rail { padding: 8px; border-radius: 14px; }
  .rail::before, .rail::after { display: none; }
  .game { border-radius: 6px; }
  .start-btn { padding: 12px 24px 12px 48px; }
  .start-btn::before { left: 22px; border-left-width: 13px; border-top-width: 8px; border-bottom-width: 8px; }
  .start-note { font-size: 12px; bottom: 6px; }
  .hint { display: none; }
  .under { justify-content: flex-end; }
  .modes div { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .rack i { animation: none; } }
