/* Shared theme for screens shown before play. */
:is(.pk-entry, .pk-setup, .pk-lobby) {
  --pk-ink: #172638;
  --pk-soft: #42566c;
  --pk-paper: #fff9ed;
  --pk-border: #d9e2e7;
  --pk-blue: #d9eff6;
  --pk-coral: #ffb094;
  background: radial-gradient(ellipse at 82% 0%, #2c4b62, transparent 65%), var(--pk-ink);
  font-family: system-ui, sans-serif;
}

body.pk-entry {
  justify-content: start;
  padding: clamp(16px, 4vw, 38px) clamp(12px, 4vw, 32px) 40px;
}

.pk-entry .container {
  display: grid;
  gap: clamp(14px, 3vw, 24px);
  max-width: 1040px;
}

.pk-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #fff3db;
  font-weight: 650;
  text-underline-offset: 4px;
}

.pk-hero {
  display: grid;
  grid-template-columns: 1fr minmax(0, .75fr);
  align-items: center;
  gap: clamp(18px, 4vw, 40px);
  padding: clamp(20px, 5vw, 52px);
  background: var(--pk-paper);
  color: var(--pk-ink);
  border-radius: 26px;
}

.pk-hero h1, .pk-setup-heading h1, .pk-wait-card h1, .pk-card h2 {
  margin: 0 0 .35em;
  font: 700 clamp(1.65rem, 5vw, 2.65rem)/1.05 Georgia, serif;
  letter-spacing: -.045em;
}

.pk-hero h1 { font-size: clamp(2.75rem, 8vw, 5.5rem); }
.pk-hero p { max-width: 35ch; color: var(--pk-soft); line-height: 1.55; }

.pk-board-art {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  min-height: 145px;
  aspect-ratio: 1.6;
  font: 800 clamp(2rem, 6vw, 4rem)/1 system-ui, sans-serif;
  border: 6px solid #385a73;
  border-radius: 18px;
  background:
    linear-gradient(#65859b 1px, transparent 1px),
    linear-gradient(90deg, #65859b 1px, transparent 1px),
    var(--pk-ink);
  background-size: calc(100% / 3) calc(100% / 3);
  box-shadow: 0 6px #263e52, 0 12px 22px #1726383d;
}

.pk-x { color: var(--pk-coral); }
.pk-o { color: #9fdce9; }
.pk-mark-1 { grid-area: 1 / 1; }
.pk-mark-2 { grid-area: 1 / 3; }
.pk-mark-3 { grid-area: 2 / 2; }
.pk-mark-4 { grid-area: 3 / 1; }
.pk-mark-5 { grid-area: 3 / 3; }

.pk-entry .container:has(form:not([hidden])) .pk-hero { display: none; }
.pk-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pk-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: 12px;
  align-items: start;
  padding: clamp(12px, 2vw, 20px);
  border: 1px solid var(--pk-border);
  border-radius: 16px;
  background: var(--pk-paper);
  color: var(--pk-ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.pk-choice small { color: var(--pk-soft); margin-top: .25em; }
.pk-choice-primary { background: var(--pk-coral); border-color: #ef926f; }
.pk-choice:hover, .pk-primary:hover, .pk-secondary:hover { filter: brightness(1.06); }

.pk-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 40px;
  aspect-ratio: 1;
  border-radius: 11px;
  color: var(--pk-ink);
  background: var(--pk-blue);
  font: 700 1.25rem/1 system-ui, sans-serif;
}
.pk-choice-primary .pk-icon { background: #fff0e6; }

.pk-card {
  width: min(100%, 620px);
  margin-inline: auto;
  padding: clamp(16px, 4vw, 30px);
  border: 1px solid var(--pk-border);
  border-radius: 20px;
  background: var(--pk-paper);
  color: var(--pk-ink);
  box-shadow: 0 12px 30px #09142338;
}
.pk-card h2 { margin-bottom: .75em; }
.pk-card label {
  margin-bottom: 6px;
  color: var(--pk-ink);
  font: 650 .9rem/1.4 system-ui, sans-serif;
  letter-spacing: normal;
  text-transform: none;
}
.pk-card input:is([type=text], [type=number]) {
  min-height: 44px;
  color: var(--pk-ink);
  background: #fff;
  border: 1px solid #aabac6;
  font: 1rem system-ui, sans-serif;
}
.pk-card input.code-input { font-family: ui-monospace, monospace; }

.pk-card :is(.mode-btn, .board-btn, .tog-btn) {
  min-height: 44px;
  background: #fff;
  border: 1px solid #aabac6;
  color: var(--pk-ink);
  font: 600 .85rem/1.25 system-ui, sans-serif;
}
.pk-card :is(.mode-btn, .board-btn, .tog-btn)[aria-pressed="true"] {
  background: var(--pk-blue);
  border-color: #42738c;
  color: #173c53;
  box-shadow: inset 0 0 0 1px #42738c;
}

.pk-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pk-card :is(.pk-primary, .pk-secondary) {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: .65em 1em;
  border: 1px solid transparent;
  border-radius: 10px;
  font: 700 .95rem/1.25 system-ui, sans-serif;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
}
.pk-actions .pk-primary { width: auto; }
.pk-card .pk-primary { background: var(--pk-coral); color: #3f251d; }
.pk-card .pk-secondary { background: transparent; border-color: #aabac6; color: var(--pk-ink); }
.pk-card :is(.error, .pk-error) {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #e8bab0;
  border-radius: 8px;
  background: #fce9e2;
  color: #842b1e;
  font-size: .9rem;
}

:is(.pk-entry, .pk-setup, .pk-lobby) :is(a, button, input):focus-visible {
  outline: 3px solid #4c88a4;
  outline-offset: 2px;
}
:is(.pk-entry, .pk-setup) .pk-back:focus-visible { outline-color: #9fdce9; }
.pk-entry [hidden] { display: none !important; }

#setup-screen.pk-setup, #waiting.pk-lobby {
  overflow-y: auto;
  align-items: start;
  justify-content: start;
  padding: clamp(12px, 4vw, 32px);
}
.pk-setup .setup-inner, .pk-lobby .pk-wait-card { margin: auto; }
.pk-setup .setup-inner { max-width: 620px; }
.pk-setup-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 18px;
  color: #fff3db;
}
.pk-setup-heading p { color: #d2e4ec; }
.pk-setup-heading .pk-icon { flex: none; }
.pk-setup .panel { padding: clamp(16px, 4vw, 30px); }

.pk-lobby .pk-wait-card { text-align: center; }
.pk-wait-card > p { color: var(--pk-soft); line-height: 1.5; }
.pk-invite-code {
  display: grid;
  padding: 10px;
  margin: 18px 0 12px;
  border: 1px dashed #62859b;
  border-radius: 12px;
  background: var(--pk-blue);
  font-weight: 650;
}
.pk-lobby .wait-code {
  color: var(--pk-ink);
  font: 800 clamp(1.9rem, 7vw, 3rem)/1.2 ui-monospace, monospace;
  letter-spacing: .18em;
  padding-left: .18em;
  text-shadow: none;
  user-select: all;
}
.pk-lobby .invite { width: 100%; }
.pk-lobby .copy-btn {
  background: #e3edf3;
  color: var(--pk-ink);
  border-color: #aabac6;
  font: 650 .88rem/1.2 system-ui, sans-serif;
}
.pk-lobby .copy-btn-main { background: var(--pk-coral); }
.pk-lobby .copy-btn-wa { background: #176840; color: #fff; }
.pk-wait-card .pk-wait-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 8px;
  padding: 8px;
}
.pk-lobby .wait-spinner { width: 18px; height: 18px; border-color: #aabac6; border-top-color: #285a77; }
body:has(#waiting:not(.hidden)) #toast { z-index: 151; }

@media (max-width: 680px) {
  .pk-choices, .pk-hero { grid-template-columns: 1fr; }
  .pk-board-art { aspect-ratio: 2.1; }
}
@media (prefers-reduced-motion: reduce) {
  .pk-lobby .wait-spinner { animation: none; }
}
