/* ==========================================================================
   Game: PopLine (bubble shooter)
   Self-contained — every class is prefixed .pl-. The game panel is always a
   dark "stage" in both site themes; the board itself is a <canvas>.
   ========================================================================== */

.pl {
  --pl-bg: #14122e;
  --pl-card: rgba(255, 255, 255, .06);
  --pl-card-hover: rgba(255, 255, 255, .11);
  --pl-line: rgba(255, 255, 255, .12);
  --pl-text: #fff;
  --pl-sub: rgba(255, 255, 255, .72);
  --pl-good: #19c28f;
  --pl-bad: #ff5c8a;
  --pl-accent: var(--hot);

  position: relative;
  margin: 10px 0 40px;
  padding: 36px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 80% at 100% 0%, rgba(38, 208, 124, .22), transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(58, 141, 255, .4), transparent 60%),
    var(--pl-bg);
  color: var(--pl-text);
  isolation: isolate;
  min-height: 520px;
}
:root[data-theme="dark"] .pl { border: 1px solid var(--line); }


.pl-screen[hidden] { display: none !important; }
.pl-screen { animation: pl-fade .35s var(--ease); }
@keyframes pl-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.pl-ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Shared buttons ---------- */
.pl-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 18px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--pl-text);
  font: 600 .875rem/1.2 var(--font);
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.pl-ghost:hover { background: var(--pl-card-hover); }
.pl-ghost--danger { color: var(--pl-sub); }
.pl-ghost--danger.is-confirm { border-color: var(--pl-bad); color: var(--pl-bad); }

.pl-ico--off { display: none; }
.is-off > .pl-ico--on { display: none; }
.is-off > .pl-ico--off { display: block; }

.pl-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 1px solid var(--pl-line);
  border-radius: 50%;
  background: var(--pl-card);
  color: var(--pl-text);
  cursor: pointer;
  transition: background-color .2s var(--ease);
}
.pl-icon-btn:hover { background: var(--pl-card-hover); }

.pl .btn-pill { min-height: 46px; padding: 11px 24px; }
.pl .btn-pill:not(.btn-pill--hot) { background: var(--brand-soft); color: var(--night); }

.pl button:focus-visible { outline: 3px solid var(--pl-accent); outline-offset: 2px; }

/* ==========================================================================
   Screen 1: level select
   ========================================================================== */
.pl-home__head { display: flex; align-items: flex-start; gap: 22px; max-width: 760px; }

.pl-logo {
  position: relative;
  flex: none;
  width: 78px;
  height: 78px;
  border-radius: 20px;
  background: linear-gradient(145deg, #173a6b, #2a1f6b);
  box-shadow: 0 12px 30px rgba(58, 141, 255, .35);
  overflow: hidden;
}
.pl-logo span {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--pl-c) 40%, rgba(0, 0, 0, .35) 100%);
  animation: pl-bob 2.2s ease-in-out infinite alternate;
}
.pl-logo span:nth-child(1) { --pl-c: #ff3d5f; left: 6px; top: 8px; }
.pl-logo span:nth-child(2) { --pl-c: #ffd23f; left: 28px; top: 8px; animation-delay: -.4s; }
.pl-logo span:nth-child(3) { --pl-c: #3a8dff; left: 50px; top: 8px; animation-delay: -.8s; }
.pl-logo span:nth-child(4) { --pl-c: #26d07c; left: 17px; top: 27px; animation-delay: -1.2s; }
.pl-logo span:nth-child(5) { --pl-c: #a65bff; left: 39px; top: 27px; animation-delay: -1.6s; }
.pl-logo i {
  position: absolute;
  left: 34px;
  bottom: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffd84d;
  box-shadow: 0 -10px 0 -3px rgba(255, 216, 77, .7), 0 -19px 0 -4px rgba(255, 216, 77, .45);
}
@keyframes pl-bob { to { transform: translateY(-2px) scale(1.05); } }

.pl-kicker {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 216, 77, .14);
  color: var(--pl-accent);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.pl-title { margin: 0 0 8px; font-size: clamp(2rem, 4.4vw, 3rem); letter-spacing: -.035em; line-height: 1.05; }
.pl-lead { margin: 0; color: var(--pl-sub); }

.pl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 28px 0 22px;
}
.pl-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.pl-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-pill);
  background: var(--pl-card);
}
.pl-chip__label { color: var(--pl-sub); font-size: .78rem; font-weight: 500; }
.pl-chip strong { color: var(--pl-accent); font-size: 1rem; }
.pl-toolbar__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.pl-worlds { display: grid; gap: 22px; }
.pl-world {
  --pl-w: #3a8dff;
  padding: 18px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(var(--pl-wrgb, 58, 141, 255), .16), rgba(255, 255, 255, .03) 60%);
}
.pl-world--0 { --pl-wrgb: 58, 141, 255; }
.pl-world--1 { --pl-wrgb: 255, 120, 40; }
.pl-world--2 { --pl-wrgb: 120, 220, 255; }
.pl-world--3 { --pl-wrgb: 180, 92, 255; }
.pl-world--4 { --pl-wrgb: 255, 216, 77; }

.pl-world__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.pl-world__name { margin: 0; font-size: 1.1rem; letter-spacing: -.01em; }
.pl-world__stars { color: var(--pl-accent); font-size: .85rem; font-weight: 700; }
.pl-world__blurb { margin: 2px 0 14px; color: var(--pl-sub); font-size: .85rem; }

.pl-levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pl-level {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 14px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-sm);
  background: rgba(10, 10, 30, .35);
  color: var(--pl-text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.pl-level:hover:not(:disabled) { transform: translateY(-3px); border-color: rgba(255, 216, 77, .55); background: rgba(255, 255, 255, .08); }
.pl-level.is-cleared { border-color: rgba(25, 194, 143, .5); }
.pl-level.is-locked { cursor: not-allowed; opacity: .5; }

.pl-level__num {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--pl-accent);
  color: var(--night);
  font-size: 1rem;
  font-weight: 700;
}
.pl-level.is-locked .pl-level__num { background: rgba(255, 255, 255, .14); color: var(--pl-text); }
.pl-level__body { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pl-level__name { font-size: .95rem; font-weight: 700; line-height: 1.3; }
.pl-level__goal { color: var(--pl-sub); font-size: .78rem; line-height: 1.4; }
.pl-level__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--pl-line);
}
.pl-level__best { color: var(--pl-sub); font-size: .74rem; font-weight: 600; }

.pl-star { color: rgba(255, 255, 255, .22); font-size: 1rem; line-height: 1; }
.pl-star.is-on { color: var(--pl-accent); text-shadow: 0 0 12px rgba(255, 216, 77, .5); }

.pl-noscript { margin: 16px 0 0; padding: 14px 18px; border-radius: var(--radius-sm); background: rgba(255, 92, 138, .15); }

/* ==========================================================================
   Screen 2: playing
   ========================================================================== */
.pl-play { position: relative; }

.pl-hud { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pl-hud__level { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pl-hud__world { color: var(--pl-accent); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pl-hud__level strong { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-hud__actions { display: flex; gap: 8px; margin-left: auto; }

.pl-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 460px;
  margin: 0 auto 12px;
}
.pl-stat {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-sm);
  background: var(--pl-card);
  line-height: 1.2;
}
.pl-stat__label { color: var(--pl-sub); font-size: .66rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.pl-stat strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-stat--par strong { color: var(--pl-accent); font-size: .92rem; line-height: 1.45; }

.pl-stage { position: relative; display: flex; justify-content: center; }
.pl-canvas {
  display: block;
  width: 100%;
  max-width: 460px;
  border-radius: 18px;
  background: #120f30;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 22px 50px rgba(0, 0, 0, .45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: crosshair;
  outline: none;
}
.pl-canvas:focus-visible { box-shadow: 0 0 0 3px var(--pl-accent), 0 22px 50px rgba(0, 0, 0, .45); }

.pl-banner {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 40%;
  margin: 0;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  background: rgba(14, 13, 36, .92);
  box-shadow: 0 0 0 2px var(--pl-accent), 0 14px 40px rgba(0, 0, 0, .5);
  color: #fff;
  font-size: clamp(.95rem, 3vw, 1.2rem);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: pl-fade .3s var(--ease);
}
.pl-banner[hidden] { display: none; }

.pl-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  max-width: 460px;
  margin: 14px auto 0;
}
.pl-controls .pl-ghost:disabled { opacity: .45; cursor: default; }
.pl-tip { flex: 1 1 240px; margin: 0; color: var(--pl-sub); font-size: .8rem; }

/* Level list colour dots */
.pl-level__dots { display: flex; gap: 4px; margin-top: 4px; }
.pl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pl-c); box-shadow: inset -2px -2px 3px rgba(0, 0, 0, .3); }
.pl-dot--0 { --pl-c: #ff3d5f; }
.pl-dot--1 { --pl-c: #ffd23f; }
.pl-dot--2 { --pl-c: #26d07c; }
.pl-dot--3 { --pl-c: #3a8dff; }
.pl-dot--4 { --pl-c: #a65bff; }
.pl-dot--5 { --pl-c: #ff8a1f; }

/* Pause overlay hides the board */
.pl-play.is-paused .pl-stage, .pl-play.is-paused .pl-controls, .pl-play.is-paused .pl-stats { filter: blur(12px); pointer-events: none; user-select: none; }
.pl-paused { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; padding: 16px; }
.pl-paused[hidden] { display: none; }
.pl-paused__card {
  max-width: 400px;
  padding: 28px;
  border: 1px solid var(--pl-line);
  border-radius: var(--radius-md);
  background: rgba(20, 18, 46, .95);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
  text-align: center;
}
.pl-paused__title { margin: 0 0 6px; font-size: 1.6rem; }
.pl-paused__card p { margin: 0 0 20px; color: var(--pl-sub); font-size: .9rem; }
.pl-paused__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ==========================================================================
   Screen 3: results
   ========================================================================== */
.pl-result { max-width: 640px; margin: 0 auto; padding: 10px 0; text-align: center; }
.pl-result__stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.pl-star--big { font-size: clamp(3rem, 9vw, 4.25rem); opacity: 0; animation: pl-star-in .5s var(--ease) forwards; }
@keyframes pl-star-in {
  from { opacity: 0; transform: scale(.3) rotate(-30deg); }
  to   { opacity: 1; transform: none; }
}
.pl-result__title { margin: 0 0 6px; font-size: clamp(1.8rem, 4vw, 2.5rem); }
.pl-result__new {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--pl-accent);
  color: var(--night);
  font-size: .8rem;
  font-weight: 700;
}
.pl-result__new[hidden] { display: none; }
.pl-result__text { margin: 0 auto 24px; max-width: 480px; color: var(--pl-sub); }
.pl-result__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 26px; }
.pl-result__stats div { padding: 14px 8px; border: 1px solid var(--pl-line); border-radius: var(--radius-sm); background: var(--pl-card); }
.pl-result__stats dt { color: var(--pl-sub); font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.pl-result__stats dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-result__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pl-result__actions [hidden] { display: none; }

/* ==========================================================================
   How-to-play (site theme)
   ========================================================================== */
.pl-guide { margin: 0 0 56px; }
.pl-guide .section-head__title { margin-bottom: 22px; }
.pl-guide__item {
  height: 100%;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pl-guide__item h3 { margin: 12px 0 6px; font-size: 1.05rem; }
.pl-guide__item p { margin: 0; color: var(--sub); font-size: .9rem; }
.pl-guide__num {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--onbrand);
  font-weight: 700;
}
.pl-guide__back { margin: 24px 0 0; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 991.98px) {
  .pl-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .pl { padding: 24px 20px; min-height: 0; }
  .pl-result__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
  .pl { margin-left: -4px; margin-right: -4px; padding: 18px 12px; border-radius: var(--radius-md); }
  .pl-home__head { flex-direction: column; gap: 16px; }
  .pl-toolbar { flex-direction: column; align-items: stretch; }
  .pl-toolbar__actions .pl-ghost { flex: 1; }
  .pl-world { padding: 14px 12px; }
  .pl-levels { gap: 8px; }
  .pl-level { padding: 11px; }
  .pl-hud { margin-bottom: 8px; gap: 8px; }
  .pl-hud__level strong { font-size: .98rem; }
  .pl-icon-btn { width: 40px; height: 40px; }
  .pl-stats { gap: 6px; margin-bottom: 10px; }
  .pl-stat { padding: 6px 8px; }
  .pl-stat strong { font-size: .98rem; }
  .pl-stat--par strong { font-size: .8rem; }
  .pl-canvas { border-radius: 14px; }
  .pl-tip { font-size: .76rem; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .pl-logo span { animation: none; }
  .pl-star--big { opacity: 1; animation: none; }
  .pl-screen, .pl-banner { animation: none; }
}
