:root {
  --snooker-pink: #ff2da9;
  --snooker-hot: #ff86d2;
  --snooker-violet: #7837ff;
  --snooker-cyan: #85f8ff;
  --snooker-ink: #050106;
}

body.is-snooker-open { overflow: hidden; }

.neon-snooker {
  position: fixed;
  z-index: 140;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 20%, rgba(143, 30, 207, .24), transparent 46%),
    linear-gradient(180deg, rgba(3, 0, 5, .94), rgba(2, 0, 4, .985));
  transition: opacity .32s ease, visibility .32s ease;
}

.neon-snooker.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.neon-snooker::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .16;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 4px 4px;
}

.neon-snooker__frame {
  position: relative;
  width: min(1420px, calc(100vw - 20px));
  height: min(900px, calc(100svh - 20px));
  min-height: 520px;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 90px;
  overflow: hidden;
  border: 1px solid rgba(255, 96, 193, .68);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  background: #060108;
  box-shadow:
    0 34px 100px rgba(0, 0, 0, .85),
    0 0 48px rgba(255, 34, 164, .22),
    inset 0 0 0 1px rgba(135, 245, 255, .06);
}

.neon-snooker__frame::before,
.neon-snooker__frame::after {
  content: "";
  position: absolute;
  z-index: 6;
  width: 92px;
  height: 2px;
  pointer-events: none;
  background: var(--snooker-cyan);
  box-shadow: 0 0 12px var(--snooker-cyan);
}

.neon-snooker__frame::before { top: 8px; left: 22px; }
.neon-snooker__frame::after { right: 22px; bottom: 8px; background: var(--snooker-pink); box-shadow: 0 0 12px var(--snooker-pink); }

.neon-snooker__header {
  position: relative;
  z-index: 7;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto 46px;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 60, 174, .34);
  background:
    linear-gradient(90deg, rgba(120, 21, 124, .2), transparent 30%),
    rgba(12, 1, 15, .96);
}

.neon-snooker__sigil { position: relative; width: 78px; height: 34px; }
.neon-snooker__sigil i { position: absolute; left: 4px; right: 4px; height: 1px; background: var(--snooker-pink); box-shadow: 0 0 9px var(--snooker-pink); transform-origin: center; }
.neon-snooker__sigil i:nth-child(1) { top: 8px; transform: skewX(-38deg); }
.neon-snooker__sigil i:nth-child(2) { top: 17px; left: 16px; right: 16px; background: var(--snooker-cyan); box-shadow: 0 0 9px var(--snooker-cyan); }
.neon-snooker__sigil i:nth-child(3) { top: 26px; transform: skewX(38deg); }

.neon-snooker__title { min-width: 0; }
.neon-snooker__title small,
.neon-snooker__match small,
.neon-snooker__score small,
.neon-snooker__target small,
.neon-snooker__turn small,
.snooker-readout small,
.snooker-power small {
  display: block;
  color: rgba(255, 188, 226, .56);
  font: 700 7px/1 "Courier New", monospace;
  letter-spacing: .2em;
}

.neon-snooker__title strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: #fff2fb;
  font: 400 clamp(15px, 1.7vw, 24px)/1 Georgia, "Times New Roman", serif;
  letter-spacing: .17em;
  text-overflow: ellipsis;
  text-shadow: 0 0 9px var(--snooker-pink), 0 0 24px rgba(255, 45, 169, .52);
  white-space: nowrap;
}

.neon-snooker__match { min-width: 116px; text-align: right; }
.neon-snooker__match strong { display: block; margin-top: 5px; color: var(--snooker-cyan); font: 700 12px/1 "Courier New", monospace; letter-spacing: .12em; text-shadow: 0 0 9px rgba(133, 248, 255, .76); }

.neon-snooker__close {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 119, 203, .52);
  border-radius: 50%;
  color: #ffc9ea;
  background: rgba(41, 3, 31, .86);
  cursor: pointer;
  font: 300 22px/1 Arial, sans-serif;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.neon-snooker__close:hover,
.neon-snooker__close:focus-visible { border-color: #fff; outline: none; box-shadow: 0 0 18px rgba(255, 48, 169, .58); transform: rotate(8deg); }

.neon-snooker__arena {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 52%, rgba(85, 15, 104, .28), transparent 65%), #020104;
}

#snooker-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.neon-snooker.is-ai-turn #snooker-canvas { cursor: wait; }

.neon-snooker__scan {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  opacity: .19;
  mix-blend-mode: screen;
  background:
    linear-gradient(180deg, transparent 0 48%, rgba(255, 88, 194, .16) 50%, transparent 52%) 0 0 / 100% 9px,
    linear-gradient(90deg, transparent, rgba(113, 245, 255, .04), transparent);
  animation: snookerScan 7s linear infinite;
}

.neon-snooker__score,
.neon-snooker__target,
.neon-snooker__turn {
  position: absolute;
  z-index: 5;
  min-width: 126px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 88, 191, .26);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  background: rgba(8, 1, 11, .78);
  backdrop-filter: blur(5px);
  box-shadow: inset 0 0 14px rgba(255, 30, 157, .07);
}

.neon-snooker__score { top: 14px; }
.neon-snooker__score--player { left: 14px; }
.neon-snooker__score--germain { right: 14px; text-align: right; }
.neon-snooker__score strong { display: block; margin-top: 3px; color: #fff; font: 700 27px/.9 "Courier New", monospace; letter-spacing: .05em; text-shadow: 0 0 12px var(--snooker-pink); }
.neon-snooker__score span { display: block; margin-top: 5px; color: var(--snooker-hot); font: 700 9px/1 "Courier New", monospace; letter-spacing: .25em; }

.neon-snooker__target { left: 14px; bottom: 14px; min-width: 116px; }
.neon-snooker__target strong { display: block; margin-top: 4px; color: var(--snooker-cyan); font: 700 12px/1 "Courier New", monospace; letter-spacing: .12em; text-shadow: 0 0 9px var(--snooker-cyan); }

.neon-snooker__turn { right: 14px; bottom: 14px; min-width: 144px; text-align: right; }
.neon-snooker__turn strong { display: block; margin-top: 4px; color: #fff0fa; font: 700 12px/1 "Courier New", monospace; letter-spacing: .12em; }
.neon-snooker__turn span { display: block; margin-top: 4px; color: rgba(255, 171, 220, .52); font: 600 7px/1 "Courier New", monospace; }

.neon-snooker__message {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: grid;
  min-width: min(430px, 72vw);
  padding: 14px 28px 13px;
  border-block: 1px solid rgba(255, 90, 193, .52);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(11, 1, 14, .92) 16%, rgba(11, 1, 14, .92) 84%, transparent);
  transform: translate(-50%, -42%) scale(.96);
  transition: opacity .22s ease, transform .25s ease;
}

.neon-snooker__message.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.neon-snooker__message strong { color: #fff5fc; font: 400 clamp(17px, 2.2vw, 29px)/1 Georgia, serif; letter-spacing: .2em; text-shadow: 0 0 12px var(--snooker-pink); }
.neon-snooker__message small { margin-top: 7px; color: var(--snooker-cyan); font: 700 8px/1.2 "Courier New", monospace; letter-spacing: .17em; text-shadow: 0 0 8px rgba(133, 248, 255, .72); }

.neon-snooker__controls {
  position: relative;
  z-index: 7;
  display: grid;
  grid-template-columns: 100px minmax(190px, 1fr) 180px;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 6px 20px;
  padding: 9px clamp(18px, 3vw, 42px) 8px;
  border-top: 1px solid rgba(255, 62, 175, .35);
  background: linear-gradient(180deg, rgba(19, 2, 22, .98), rgba(5, 1, 8, .99));
}

.snooker-readout strong { display: block; margin-top: 6px; color: var(--snooker-cyan); font: 700 15px/1 "Courier New", monospace; text-shadow: 0 0 8px var(--snooker-cyan); }
.snooker-power { display: grid; grid-template-columns: auto minmax(80px, 1fr) 34px; align-items: center; gap: 10px; }
.snooker-power small { grid-column: 1 / -1; }
.snooker-power span { grid-column: 1 / 3; display: block; height: 8px; overflow: hidden; border: 1px solid rgba(255, 108, 199, .42); background: #170314; }
.snooker-power span i { display: block; width: 42%; height: 100%; background: linear-gradient(90deg, #7436ff, #ff2da9 60%, #fff1fb); box-shadow: 0 0 9px var(--snooker-pink); transition: width .08s linear; }
.snooker-power strong { color: #ffeaf7; font: 700 12px/1 "Courier New", monospace; }

.snooker-shoot {
  position: relative;
  grid-row: 1;
  grid-column: 3;
  min-height: 46px;
  border: 1px solid rgba(143, 245, 255, .68);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  color: #efffff;
  background: linear-gradient(145deg, rgba(74, 35, 164, .94), rgba(183, 14, 131, .92));
  cursor: pointer;
  font: 800 9px/1 "Courier New", monospace;
  letter-spacing: .12em;
  text-shadow: 0 0 7px var(--snooker-cyan);
  box-shadow: 0 0 14px rgba(123, 239, 255, .22), inset 0 1px 0 rgba(255, 255, 255, .16);
}

.snooker-shoot i { position: absolute; right: 8px; bottom: 7px; left: 8px; height: 1px; background: linear-gradient(90deg, transparent, var(--snooker-cyan), transparent); }
.snooker-shoot.is-charging { filter: brightness(1.25); box-shadow: 0 0 23px rgba(255, 43, 170, .68), inset 0 1px 0 rgba(255,255,255,.2); }
.snooker-shoot:disabled { opacity: .3; cursor: default; }
.snooker-shoot:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.neon-snooker__controls p {
  grid-column: 1 / -1;
  margin: 0;
  color: rgba(255, 190, 227, .38);
  text-align: center;
  font: 600 6px/1 "Courier New", monospace;
  letter-spacing: .15em;
}

@keyframes snookerScan { to { background-position-y: 90px; } }

@media (max-width: 760px) {
  .neon-snooker { padding: 4px; }
  .neon-snooker__frame { width: calc(100vw - 8px); height: calc(100svh - 8px); min-height: 430px; grid-template-rows: 54px minmax(0, 1fr) 92px; clip-path: polygon(11px 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%, 0 11px); }
  .neon-snooker__header { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 8px; padding: 7px 9px; }
  .neon-snooker__sigil { display: none; }
  .neon-snooker__title small { font-size: 5px; }
  .neon-snooker__title strong { margin-top: 4px; font-size: 12px; letter-spacing: .08em; }
  .neon-snooker__match { min-width: 66px; }
  .neon-snooker__match small { display: none; }
  .neon-snooker__match strong { margin: 0; font-size: 8px; }
  .neon-snooker__close { width: 32px; height: 32px; font-size: 18px; }
  .neon-snooker__score { top: 6px; min-width: 84px; padding: 5px 7px; }
  .neon-snooker__score--player { left: 6px; }
  .neon-snooker__score--germain { right: 6px; }
  .neon-snooker__score strong { font-size: 18px; }
  .neon-snooker__score span { margin-top: 3px; font-size: 6px; }
  .neon-snooker__target { left: 6px; bottom: 6px; min-width: 74px; padding: 5px 7px; }
  .neon-snooker__target strong { font-size: 8px; }
  .neon-snooker__turn { right: 6px; bottom: 6px; min-width: 86px; padding: 5px 7px; }
  .neon-snooker__turn strong { font-size: 8px; }
  .neon-snooker__message { min-width: 78vw; padding: 10px 18px; }
  .neon-snooker__message strong { font-size: 17px; }
  .neon-snooker__controls { grid-template-columns: 58px minmax(95px, 1fr) 114px; gap: 5px 8px; padding: 7px 8px 6px; }
  .snooker-readout strong { font-size: 10px; }
  .snooker-power { gap: 5px; }
  .snooker-power small, .snooker-readout small { font-size: 5px; }
  .snooker-power strong { font-size: 8px; }
  .snooker-shoot { min-height: 40px; font-size: 7px; letter-spacing: .05em; }
  .neon-snooker__controls p { overflow: hidden; font-size: 5px; letter-spacing: .03em; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-height: 620px) and (min-width: 761px) {
  .neon-snooker__frame { grid-template-rows: 56px minmax(0, 1fr) 72px; }
  .neon-snooker__header { padding-block: 6px; }
  .neon-snooker__controls { padding-block: 6px; }
  .neon-snooker__controls p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .neon-snooker__scan { animation: none; }
}
