/* Payload: the canvas fills the stage; the HUD, menus and banners are HTML over it */
.pl { display: flex; flex-direction: column; color: #dfe9ff; --pl-hud: 48px; }
.pl-stage { position: relative; width: 100%; height: min(78vh, 680px); min-height: 360px; background: #03050c; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; outline: none; }
@media (max-width: 600px) { .pl-stage { height: auto; aspect-ratio: 3 / 4.4; max-height: 78vh; min-height: 0; } }
#pl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: none; }
.pl.pl-menu #pl-canvas { cursor: default; }

/* HUD */
.pl-hud { position: absolute; left: 0; right: 0; top: 0; height: var(--pl-hud); display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; z-index: 3; pointer-events: none; }
.pl-hud > * { pointer-events: auto; }
.pl-who { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.pl-who b { font-size: 15px; font-weight: 900; letter-spacing: 0.04em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-who span { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #8aa3c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-who span .hot { color: #ffd166; }
.pl-sp { flex: 1 1 auto; }
.pl-tool { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid #1c2b4a; background: rgba(11,19,40,0.8);
  color: #bfe0ff; cursor: pointer; touch-action: manipulation; padding: 0; transition: border-color .15s, color .15s, opacity .15s; }
.pl-tool svg { width: 19px; height: 19px; }
@media (hover: hover) { .pl-tool:hover:not(:disabled) { border-color: #ffd166; color: #fff; } }
.pl-tool:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; }
.pl-tool:disabled { opacity: 0.35; cursor: default; }
#pl-pause .pl-play { display: none; } #pl-pause.is-paused .pl-play { display: inline; } #pl-pause.is-paused .pz { display: none; }
#pl-sound .off { display: none; } #pl-sound[aria-pressed="true"] { color: #6f84a3; } #pl-sound[aria-pressed="true"] .on { display: none; } #pl-sound[aria-pressed="true"] .off { display: inline; }

/* banner (online: waiting for the other player, reconnecting) */
.pl-banner[hidden] { display: none; }
.pl-banner { position: absolute; left: 50%; top: calc(var(--pl-hud) + 8px); transform: translateX(-50%); z-index: 5; max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 12px;
  background: rgba(8,13,30,0.92); border: 1px solid #ffd166; color: #fff3cf; font-size: 13.5px; font-weight: 700; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); pointer-events: none; }
.pl-banner b { color: #ffd166; font-variant-numeric: tabular-nums; }

/* menus */
.pl-overlay[hidden] { display: none; }
.pl-overlay { position: absolute; left: 0; right: 0; bottom: 0; top: var(--pl-hud); display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(ellipse at center, rgba(3,6,16,0.35), rgba(3,5,12,0.8)); z-index: 4; overflow: auto; }
.pl-overlay.pl-ov-title { background: radial-gradient(ellipse at center, rgba(3,6,16,0.15), rgba(3,5,12,0.55)); }
.pl-panel { width: min(100%, 380px); margin: auto; text-align: center; padding: 22px 20px 20px; border: 1px solid #1c2b4a; border-radius: 18px;
  background: rgba(8,13,30,0.88); box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,209,102,0.06) inset; animation: pl-in .28s cubic-bezier(.2,.9,.25,1.1); }
.pl-panel.wide { width: min(100%, 440px); text-align: left; }
@keyframes pl-in { from { opacity: 0; transform: scale(.94) translateY(8px); } }
.pl-logo { margin: 0 0 4px; font-size: clamp(32px, 9vw, 44px); font-weight: 900; letter-spacing: 0.12em; line-height: 1.05;
  background: linear-gradient(90deg, #55d6ff, #ffffff 35%, #ffd166 60%, #ff4fd8 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255,209,102,0.4)); }
.pl-tag { margin: 0 0 14px; color: #8aa3c4; font-size: 13.5px; line-height: 1.45; }
.pl-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 13px; background: #050a18; border: 1px solid #1c2b4a; margin: 0 0 8px; }
.pl-opt { font: inherit; font-size: 13.5px; font-weight: 700; color: #8aa3c4; background: transparent; border: 0; border-radius: 9px; min-height: 40px; padding: 0 4px; cursor: pointer; touch-action: manipulation; transition: background .15s, color .15s; }
.pl-opt[aria-checked="true"] { background: #13234a; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,209,102,0.5), 0 0 16px rgba(255,209,102,0.18); }
.pl-opt.d-insane[aria-checked="true"] { box-shadow: inset 0 0 0 1px rgba(255,79,216,0.7), 0 0 18px rgba(255,79,216,0.3); color: #ffd6f4; }
@media (hover: hover) { .pl-opt:hover { color: #fff; } }
.pl-opt:focus-visible { outline: 2px solid #ffd166; outline-offset: 1px; }
.pl-desc { margin: 0 0 12px; font-size: 12.5px; color: #8aa3c4; min-height: 1.4em; }
.pl-desc b { color: #ffd166; font-variant-numeric: tabular-nums; }
.pl-actions { display: flex; flex-direction: column; gap: 8px; }
.pl-row { display: flex; gap: 8px; } .pl-row > * { flex: 1 1 0; }
.pl-btn { font: inherit; font-weight: 700; font-size: 14.5px; padding: 11px 16px; min-height: 46px; border-radius: 12px; cursor: pointer; touch-action: manipulation;
  border: 1px solid #1c2b4a; background: #0b1328; color: #dfe9ff; transition: background .15s, border-color .15s, transform .1s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
@media (hover: hover) { .pl-btn:hover:not(:disabled) { border-color: #ffd166; } }
.pl-btn:active { transform: translateY(1px); }
.pl-btn:disabled { opacity: .45; cursor: default; }
.pl-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pl-btn-primary { background: linear-gradient(135deg, #fff1a8, #ffd166 45%, #ffae00); color: #1a1200; border-color: transparent; font-size: 16px; font-weight: 900; letter-spacing: 0.02em; box-shadow: 0 6px 26px rgba(255,190,40,0.35); }
@media (hover: hover) { .pl-btn-primary:hover:not(:disabled) { border-color: transparent; filter: brightness(1.06); } }
.pl-btn small { display: block; font-size: 11.5px; font-weight: 600; color: #8aa3c4; }
.pl-btn.tile { flex-direction: column; gap: 1px; min-height: 58px; }
.pl-keys { margin: 12px 0 0; font-size: 11.5px; color: #6f84a3; }
.pl-head { margin: 0 0 2px; font-size: 13px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: #8aa3c4; }
.pl-big { margin: 2px 0 2px; font-size: 40px; font-weight: 900; line-height: 1.05; color: #fff; text-shadow: 0 0 24px rgba(255,209,102,0.45); }
.pl-big.lose { text-shadow: 0 0 24px rgba(85,214,255,0.35); }
.pl-final { margin: 0 0 6px; font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }
.pl-final .a { color: #55d6ff; text-shadow: 0 0 14px rgba(85,214,255,.6); } .pl-final .b { color: #ff4fd8; text-shadow: 0 0 14px rgba(255,79,216,.6); } .pl-final i { color: #4a5b7a; font-style: normal; padding: 0 8px; }
.pl-badge { display: inline-block; margin: 4px 0 6px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase;
  color: #1a1200; background: linear-gradient(90deg, #ffd166, #fff1b8, #ffd166); background-size: 200% 100%; animation: pl-shine 1.6s linear infinite; box-shadow: 0 0 22px rgba(255,209,102,0.55); }
@keyframes pl-shine { to { background-position: -200% 0; } }
.pl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 14px; }
.pl-stats div { padding: 8px 4px; border-radius: 10px; background: #050a18; border: 1px solid #16223d; }
.pl-stats span { display: block; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: #6f84a3; font-weight: 700; }
.pl-stats b { display: block; margin-top: 2px; font-size: 17px; color: #dfe9ff; font-variant-numeric: tabular-nums; }
.pl-stats .gold b { color: #ffd166; }
.pl-panel h2 { margin: 0 34px 10px 0; font-size: 20px; color: #fff; }
.pl-panel h3 { margin: 14px 0 6px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #8aa3c4; }
.pl-panel.wide p, .pl-panel li { font-size: 13.5px; line-height: 1.5; color: #b9c9e4; }
.pl-panel ul { margin: 0 0 6px; padding-left: 18px; }
.pl-panel kbd { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 5px; border: 1px solid #2a3c62; background: #0b1328; color: #fff; font: 700 12px/1.6 system-ui, sans-serif; text-align: center; }
.pl-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #cfe0ff; font-size: 20px; line-height: 1; cursor: pointer; }
.pl-panel { position: relative; }
.pl-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.pl-field > span { font-size: 13.5px; font-weight: 700; color: #dfe9ff; }
.pl-field .pl-seg { margin: 0; flex: 0 1 260px; }
.pl-switch { position: relative; width: 48px; height: 28px; flex: none; border-radius: 14px; border: 1px solid #24375e; background: #0b1328; cursor: pointer; padding: 0; transition: background .15s, border-color .15s; }
.pl-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #6f84a3; transition: transform .15s, background .15s; }
.pl-switch[aria-checked="true"] { background: #4a3a0c; border-color: #ffd166; } .pl-switch[aria-checked="true"]::after { transform: translateX(20px); background: #ffd166; box-shadow: 0 0 10px rgba(255,209,102,.6); }
.pl-switch:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; }
.pl-note { font-size: 12px !important; color: #6f84a3 !important; margin: 6px 0 0; }

/* online */
.pl-link { display: flex; gap: 6px; margin: 6px 0 10px; }
.pl-input { flex: 1 1 auto; min-width: 0; font: 600 14px/1.2 system-ui, sans-serif; padding: 10px 12px; border-radius: 10px; border: 1px solid #24375e; background: #050a18; color: #fff; }
.pl-input:focus { outline: 2px solid #ffd166; outline-offset: 1px; }
.pl-code { display: inline-block; font: 900 26px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; color: #ffd166; text-shadow: 0 0 14px rgba(255,209,102,.45); margin: 2px 0 8px; }
.pl-form { display: flex; gap: 6px; margin: 4px 0 4px; } .pl-form .pl-btn { flex: none; min-height: 42px; }
.pl-open { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; text-align: left; }
.pl-open button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid #1c2b4a; background: #050a18; color: #dfe9ff; font: 600 13px system-ui, sans-serif; cursor: pointer; }
.pl-open button b { flex: 1 1 auto; text-align: left; } .pl-open button i { font-style: normal; color: #ffd166; font-weight: 800; }
.pl-spin { width: 34px; height: 34px; margin: 4px auto 10px; border-radius: 50%; border: 3px solid rgba(255,209,102,.18); border-top-color: #ffd166; animation: pl-rot .9s linear infinite; }
@keyframes pl-rot { to { transform: rotate(360deg); } }
.pl-vs { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 10px; font-weight: 800; }
.pl-vs .a { color: #55d6ff; } .pl-vs .b { color: #ff4fd8; } .pl-vs i { color: #6f84a3; font-style: normal; font-size: 12px; }
.pl-emotes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.pl-emotes button { font: 700 12.5px system-ui, sans-serif; padding: 6px 10px; border-radius: 999px; border: 1px solid #24375e; background: #0b1328; color: #dfe9ff; cursor: pointer; }

.pl-toast[hidden] { display: none; }
.pl-toast { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; padding: 8px 14px; border-radius: 999px; background: #fff1b8; color: #1a1200; font-size: 13px; font-weight: 800; animation: pl-in .2s ease-out; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.pl-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #8aa3c4; font-weight: 700; z-index: 7; background: #03050c; }
.pl-loading[hidden] { display: none; }
.pl-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* short stages (a phone held sideways): tighter menus */
.pl-short .pl-panel { padding: 12px 14px 12px; width: min(100%, 520px); }
.pl-short .pl-logo { font-size: 26px; }
.pl-short .pl-tag, .pl-short .pl-keys { display: none; }
.pl-short .pl-desc { margin-bottom: 6px; }
.pl-short .pl-big { font-size: 30px; }
.pl-short .pl-stats { margin: 6px 0 8px; } .pl-short .pl-stats div { padding: 4px; }
.pl-short .pl-btn { min-height: 40px; padding: 7px 12px; }
.pl-short .pl-actions.pl-wide { flex-direction: row; } .pl-short .pl-actions.pl-wide > * { flex: 1 1 0; }

.pl-help { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 14px; }
.pl-help .hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .pl-help .hint-kb { display: none; } .pl-help .hint-touch { display: inline; } }
.stage .pl-help { padding: 10px 14px 12px; }
@media (max-width: 400px) { .pl-hud { gap: 6px; padding-left: 10px; } .pl-tool { width: 36px; height: 36px; } }

/* full screen: the field takes every pixel */
.stage.is-immersive .stage-body > .pl { min-height: 0; }
.stage.is-immersive .pl-stage { flex: 1 1 auto; height: auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.stage.is-immersive .pl-help { display: none; }
@media (prefers-reduced-motion: reduce) { .pl-panel, .pl-toast { animation: none; } .pl-badge { animation: none; } .pl-spin { animation-duration: 3s; } }
