/* ============================================================
   XQCHESS — Private room page (private-room.ejs).
   Loaded after game.css, which provides the lobby hero/card.
   Text on dark grounds stays ≥ 4.5:1 (--text, --text-dim, --gold,
   white on --jade / --accent); touch targets ≥ 44 px.
   ============================================================ */

.pr-page [hidden] { display: none !important; }
.pr-card { padding: 2rem; scroll-margin-top: calc(var(--nav-h, 64px) + 12px); }

.pr-state { display: flex; gap: 2rem; align-items: stretch; }
.pr-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; }
.pr-col h2, .pr-host-body h2 { font-size: 1.25rem; font-weight: 700; color: var(--text); margin: 0 0 .5rem; }
.pr-col .lc-desc { margin-bottom: 1rem; }

/* ── Create: one tap per variant ───────────────────────────── */
.pr-create { display: flex; flex-direction: column; gap: .7rem; }
.pr-create-btn {
  display: flex; align-items: center; gap: .85rem;
  width: 100%; min-height: 60px; padding: .6rem 1rem;
  border: 0; border-radius: 12px; cursor: pointer;
  background: var(--jade); color: #fff;                 /* white on --jade 4.9:1 */
  font: 700 1rem var(--font-body); text-align: left;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transition: transform .12s ease, filter .15s ease, box-shadow .15s ease;
}
.pr-create-btn--blind { background: var(--accent); }    /* white on --accent 5.4:1 */
.pr-create-btn:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(0,0,0,.32); }
.pr-create-btn:active { transform: scale(.98); }
.pr-create-btn:disabled, .pr-join-btn:disabled { opacity: .6; cursor: wait; filter: none; }
.pr-seal {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.2); border: 1.5px solid rgba(255,255,255,.6);
  font: 700 1.3rem serif; line-height: 1;
}

.pr-divider {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  border-left: 1px solid var(--border);
}
.pr-divider span { background: var(--ground-2); padding: .4rem 0; margin-left: -1px; }

/* ── Join: six cells drawn over one real input ─────────────── */
.pr-code-field { position: relative; height: 60px; margin-bottom: .75rem; }
.pr-cells {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem;
  pointer-events: none; border-radius: 12px;
}
.pr-cell {
  display: flex; align-items: center; justify-content: center;
  background: var(--ground-3); border: 1.5px solid var(--border-h); border-radius: 10px;
  font: 700 1.6rem var(--font-mono); color: var(--text); text-transform: uppercase;
  transition: border-color .15s, box-shadow .15s;
}
.pr-cell:nth-child(4) { margin-left: .45rem; }          /* 3 + 3, like the code on the host's screen */
.pr-cell.is-filled { border-color: rgba(201,168,76,.55); }
.pr-cell.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.22); }
.pr-cell.is-active:empty::after {
  content: ''; width: 2px; height: 1.6rem; background: var(--gold);
  animation: pr-caret 1s steps(1) infinite;
}
@keyframes pr-caret { 50% { opacity: 0; } }
.pr-code-input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
  border: 0; background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px;                                         /* no zoom on focus in iOS Safari */
  cursor: text;
}
.pr-code-input::selection { background: transparent; }
.pr-code-input:focus { outline: none; }
.pr-code-input:focus-visible + .pr-cells { outline: 2px solid var(--gold); outline-offset: 3px; }
.pr-join-btn {
  width: 100%; min-height: 52px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--jade); color: #fff; font: 700 1rem var(--font-body);
  transition: transform .12s ease, filter .15s ease;
}
.pr-join-btn:hover { filter: brightness(1.08); }
.pr-join-btn:active { transform: scale(.98); }
.pr-hint { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: .6rem; line-height: 1.5; }

/* ── Hosting ───────────────────────────────────────────────── */
#pr-hosting { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2rem; align-items: start; }
.pr-timer { position: relative; width: 112px; height: 112px; justify-self: center; }
.pr-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.pr-ring-bg, .pr-ring { fill: none; stroke-width: 6; }
.pr-ring-bg { stroke: var(--border-h); }
.pr-ring { stroke: var(--jade-l); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.pr-timer--low .pr-ring { stroke: var(--accent); }
.pr-timer-seal {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 2.4rem serif; color: var(--gold);
}
.pr-host-body { min-width: 0; }
.pr-variant-line { color: var(--text-dim); font-size: .9rem; margin: 0 0 .9rem; }
.pr-variant-line strong { color: var(--text); }
.pr-code-box {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  background: var(--ground-3); border: 1px dashed rgba(201,168,76,.45); border-radius: 14px;
  padding: .8rem 1rem .9rem; margin-bottom: .9rem;
}
.pr-code-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.2px; }
.pr-code {
  display: flex; justify-content: center; gap: .55em;
  font: 700 clamp(2.1rem, 9vw, 2.9rem) var(--font-mono); letter-spacing: .16em; color: var(--gold);
  line-height: 1.15; user-select: all; -webkit-user-select: all;
}
.pr-code-group { margin-right: -.16em; }                  /* no trailing letter-space: stays centred */
.pr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.pr-actions #pr-share { grid-column: 1 / -1; }
.pr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .5rem .9rem; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-h); color: var(--text);
  font: 600 .95rem var(--font-body); white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.pr-btn:hover { border-color: var(--text-dim); background: rgba(232,220,200,.04); }
.pr-btn.is-done { border-color: var(--jade-l); color: var(--jade-l); }
.pr-btn--primary { background: var(--jade); border-color: transparent; color: #fff; font-weight: 700; }
.pr-btn--primary:hover { background: var(--jade); filter: brightness(1.08); }
.pr-btn-icon { font-size: 1.1rem; line-height: 1; }
.pr-link {
  width: 100%; min-height: 44px; margin-top: .6rem;
  background: var(--ground-3); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 10px; padding: .5rem .75rem; font-size: 14px;
}
.pr-status { min-height: 1.35em; margin: .45rem 0 0; font-size: 13.5px; color: var(--jade-l); }
.pr-host-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap;
  margin-top: .6rem; padding-top: .75rem; border-top: 1px solid var(--border);
}
.pr-expiry { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.pr-expiry strong { color: var(--text); font-variant-numeric: tabular-nums; }
.pr-cancel { min-height: 44px; padding: .5rem 1.1rem; font-size: .875rem; }

/* ── Matched ───────────────────────────────────────────────── */
#pr-found { flex-direction: column; align-items: center; text-align: center; gap: 1rem; padding: 1rem 0; }
.pr-found-seal {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #F6E7C8; box-shadow: 0 0 0 3px var(--gold), 0 10px 30px rgba(0,0,0,.35);
  font: 700 2.5rem serif; animation: pop .45s cubic-bezier(.175,.885,.32,1.275);
}
#pr-found .lc-body h2 { margin-bottom: .25rem; }
#pr-found .lc-body p { color: var(--text-dim); margin: 0; }

/* What-to-expect cards: seal characters, as elsewhere on the site */
.pr-mode-seal {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--gold); color: var(--gold); font: 700 1.05rem serif;
}

.pr-alert {
  margin-bottom: 1.25rem; padding: .7rem 1rem; border-radius: 10px; font-size: 14px; line-height: 1.5;
  color: #F09A8E; background: rgba(192,58,43,.14); border: 1px solid rgba(192,58,43,.4);
}

/* Keyboard focus in the site's gold */
.pr-create-btn:focus-visible, .pr-join-btn:focus-visible, .pr-btn:focus-visible,
.pr-cancel:focus-visible, .pr-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ── Phones ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pr-card { padding: 1.25rem 1rem; }
  .pr-state { flex-direction: column; gap: 1.25rem; }
  .pr-divider { border-left: 0; border-top: 1px solid var(--border); height: 0; margin: .5rem 0; }
  .pr-divider span { margin: 0; padding: 0 .6rem; transform: translateY(-1px); }
  /* Two variant cards side by side, seal above the name */
  .pr-create { display: grid; grid-template-columns: 1fr 1fr; }
  .pr-create-btn { flex-direction: column; justify-content: center; text-align: center; min-height: 104px; gap: .55rem; padding: .6rem .4rem; font-size: .92rem; }
  .pr-cell { font-size: 1.4rem; }
  .pr-cells { gap: .3rem; }
  .pr-cell:nth-child(4) { margin-left: .3rem; }
  #pr-hosting { grid-template-columns: minmax(0, 1fr); gap: 1rem; justify-items: stretch; }
  .pr-timer { width: 88px; height: 88px; }
  .pr-timer-seal { font-size: 1.9rem; }
  .pr-host-body h2, .pr-variant-line { text-align: center; }
}
@media (max-width: 360px) {
  .pr-actions { grid-template-columns: 1fr; }
}

/* Phones held sideways: the waiting room fits the short screen (no hero while hosting) */
@media (orientation: landscape) and (max-height: 500px) {
  .pr-page { gap: 1rem; padding-top: 1rem; }
  .pr-page.is-hosting .lobby-hero, .pr-page.is-hosting .lobby-modes { display: none; }
  .pr-card { padding: 1rem 1.25rem; }
  #pr-hosting { grid-template-columns: auto minmax(0, 1fr); gap: 1.25rem; }
  .pr-timer { width: 84px; height: 84px; }
  .pr-timer-seal { font-size: 1.8rem; }
  .pr-variant-line { margin-bottom: .5rem; }
  .pr-code-box { padding: .45rem 1rem .55rem; margin-bottom: .6rem; }
  .pr-code { font-size: 2rem; }
  .pr-actions { grid-template-columns: repeat(3, 1fr); }
  .pr-actions #pr-share { grid-column: auto; }
  .pr-link { display: none; }                              /* "Sao chép link" stays */
  .pr-host-foot { margin-top: .35rem; padding-top: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pr-page *, .pr-page *::before, .pr-page *::after { animation: none !important; transition: none !important; }
}
