/* ==========================================================================
   Pictionary Word Generator — play surface
   Loaded after games.css, which owns the theme tokens and shared primitives.
   ========================================================================== */

/* -- Word card ----------------------------------------------------------- */

.p-card {
  /* Fixed min-height so revealing does not shift everything below it. */
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px 18px;
  background: linear-gradient(145deg, var(--card-gradient-start), var(--card-gradient-end));
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-subtle);
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Stops the long-press text-selection callout on iOS fighting the hold */
  -webkit-touch-callout: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.p-card:hover { border-color: var(--accent); }

.p-card.is-revealed {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text-primary);
  font-size: clamp(1.5rem, 5.5vw, 2.5rem);   /* stays under the turn banner */
  font-weight: 600;
  line-height: 1.2;
  /* Long phrases must wrap, not overflow, on a 320px screen */
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.p-card__hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 8px;
  font-weight: 400;
}

.p-meta {
  min-height: 1.4em;          /* reserved, so it cannot shift the layout */
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-subtle);
  margin: 10px 0 0;
}

/* -- Timer --------------------------------------------------------------- */

.p-timer {
  text-align: center;
  font-size: clamp(2.1rem, 6vw, 2.9rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;   /* stops digits jittering as they tick */
  color: var(--text-primary);
  margin: 0 0 12px;
}
.p-timer.is-urgent { color: var(--danger); }

/* Prep is a different kind of countdown — nobody is drawing yet, so it should
   not look like the round clock running out. */
.p-timer.is-prep { color: var(--accent); }

/* Time's up: the chime carries the moment, but the visual has to work with
   the sound muted or the phone on silent. */
.p-timer.is-done {
  color: var(--danger);
  animation: p-timer-flash 0.5s ease-in-out 3;
}
@keyframes p-timer-flash {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* -- Stage --------------------------------------------------------------
   Single column since the scoring rail went. Capped rather than full-bleed:
   stretched across a wide monitor the same content reads as sparse, not
   spacious, and the word card would end up wider than it is readable.      */

.p-stage {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 6px;
}

/* -- Turn banner --------------------------------------------------------- */

/* Deliberately outranks the revealed word. Whose turn it is has to be
   readable from anywhere in the room without anyone asking. */
.p-turn {
  text-align: center;
  margin: 0 0 14px;
  line-height: 1.1;
  min-height: 2.6em;        /* reserved: names change length between turns */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.p-turn__name {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-size: clamp(2.1rem, 7vw, 3.3rem);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-turn__tail {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 400;
}

/* -- Clock --------------------------------------------------------------- */

.p-clock { margin-bottom: 18px; }
.p-clock__label {
  text-align: center;
  margin: 2px 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-subtle);
  min-height: 1.2em;        /* reserved, so phase changes cannot shift the card */
}

/* -- Big score readout --------------------------------------------------- */

.p-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 34px;
  margin-bottom: 18px;
  min-height: 62px;         /* reserved, so a score change cannot shift the card */
}
.p-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.p-total__value {
  font-size: clamp(1.9rem, 5.5vw, 2.5rem);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.p-total__label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-total.is-leading .p-total__value { color: var(--accent); }

/* -- Scoreboard rows ----------------------------------------------------- */

.p-team {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 36px 36px;
  align-items: center;
  gap: 5px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.p-team:last-child { border-bottom: 0; }

/* Setup is team creation only: a number and a name, no scores. */
.p-team--setup { grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.p-team__num {
  color: var(--text-subtle);
  font-size: 0.8rem;
  text-align: center;
}

.p-team__label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-team__name {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font: inherit;
  font-weight: 500;
  padding: 9px 10px;
  min-width: 0;
}
.p-team__name:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-main);
}

/* In the rail the name reads as a label until you touch it — the border only
   appears on hover or focus, so the column does not look like a form. */
.p-team__name--play {
  border-color: transparent;
  padding: 7px 8px;
  font-size: 0.9rem;
}
.p-team__name--play:hover { border-color: var(--border-subtle); }

/* Muted until hovered, then danger-coloured; armed state is filled so the
   second tap is obviously the committing one. */
.p-team__del {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  font-size: 1.05rem;
  line-height: 1;
  min-width: 30px;
  height: 34px;
  padding: 0 6px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.55;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.p-team__del:hover { color: var(--danger); opacity: 1; }
.p-team__del:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }
/* Armed state says the word rather than changing to another glyph: a bare
   icon is a poor place to hide something irreversible. */
.p-team__del.is-armed {
  color: var(--danger);
  opacity: 1;
  font-weight: 600;
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
.p-team__del[disabled] { opacity: 0.2; cursor: not-allowed; }
.p-team__del[disabled]:hover { color: var(--text-subtle); opacity: 0.2; }


.p-team__btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 9px;
  font-size: 1.1rem;
  line-height: 1;
  height: 40px;
  cursor: pointer;
}
.p-team__btn:hover { border-color: var(--accent); color: var(--accent); }
.p-team__btn--plus { color: var(--accent); }
.p-team__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.p-teamctl { display: flex; gap: 8px; margin-top: 14px; }
.p-teamctl .g-btn { flex: 1; font-size: 0.85rem; padding: 9px 12px; }

/* -- Play controls ------------------------------------------------------- */

.p-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}
@media (min-width: 460px) {
  /* Got it is the common outcome, so it gets the wider half rather than an
     equal split. */
  .p-controls { grid-template-columns: 2fr 1fr; }
}
.p-controls .g-btn { min-height: 58px; font-size: 1.05rem; }

.p-btn-failed {
  color: var(--text-secondary);
}
.p-btn-failed:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Secondary actions: available, but never competing with the two that end a
   round. */
.p-controls-sub {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 14px;
}
.p-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 2px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-subtle);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.p-link:hover { color: var(--accent); }
.p-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Once the buzzer has gone, Failed becomes the likelier call, so it stops
   looking like the quiet option. Got it stays live regardless. */
#playView[data-phase="timeup"] .p-btn-failed {
  border-color: var(--danger);
  color: var(--danger);
}

/* -- Mode picker --------------------------------------------------------- */

.p-modes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: var(--gap);
}
@media (min-width: 560px) {
  .p-modes { grid-template-columns: 1fr 1fr 1fr; }
}
.p-mode {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  background: var(--bg-card);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.p-mode[aria-pressed="true"] { border-color: var(--accent); }
.p-mode__title { color: var(--text-primary); font-weight: 600; display: block; }
.p-mode__desc { font-size: 0.82rem; color: var(--text-subtle); }
.p-mode[disabled] { opacity: 0.5; cursor: not-allowed; }

/* -- Narrow screens ------------------------------------------------------ */

@media (max-width: 400px) {
  .p-team { grid-template-columns: 20px minmax(0, 1fr) 34px 34px; gap: 4px; }
  .p-team__name { padding: 8px 6px; font-size: 0.9rem; }
  .p-team__btn { height: 36px; font-size: 1rem; }
  .p-card { min-height: 150px; }
  .p-totals { gap: 8px 18px; min-height: 54px; }
}

/* -- Session controls ---------------------------------------------------- */

.p-session-note {
  text-align: center;
  margin: 10px 0 0;
}
.p-link--end { color: var(--danger); opacity: 0.75; }
.p-link--end:hover { color: var(--danger); opacity: 1; }

/* -- End screen ---------------------------------------------------------- */

.p-end { max-width: 620px; margin: 0 auto; text-align: center; padding-top: 12px; }
.p-end__title { font-size: clamp(1.5rem, 6vw, 2.2rem); margin: 4px 0 6px; }
.p-end__scores { margin-top: 26px; text-align: left; }

.p-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 30px 0 6px;
}
.p-podium__col {
  flex: 1 1 0;
  max-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.p-podium__names {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
  max-width: 100%;
}
.p-podium__names span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-podium__score {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Height carries the ranking, so the podium reads at a glance without
   needing the numerals. */
.p-podium__block {
  width: 100%;
  border-radius: 10px 10px 0 0;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-on-accent);
  margin-top: 8px;
}
.p-podium__col--1 .p-podium__block { height: 120px; background: var(--accent); }
.p-podium__col--2 .p-podium__block {
  height: 84px;
  background: var(--text-secondary);
}
.p-podium__col--3 .p-podium__block {
  height: 58px;
  background: var(--text-subtle);
}
.p-podium__col--1 .p-podium__score { color: var(--accent); }

/* -- Final score list ---------------------------------------------------- */

.p-final {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.p-final:last-child { border-bottom: 0; }
.p-final__pos { color: var(--text-subtle); font-size: 0.82rem; text-align: center; }
.p-final__name {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-final__score {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 400px) {
  .p-podium { gap: 6px; }
  .p-podium__names { font-size: 0.78rem; }
  .p-podium__col--1 .p-podium__block { height: 96px; }
  .p-podium__col--2 .p-podium__block { height: 68px; }
  .p-podium__col--3 .p-podium__block { height: 48px; }
}


/* -- Settings drawer -----------------------------------------------------
   The same #setupView, presented as a panel over the live board instead of a
   page of its own. Nothing about the round is torn down to show it.        */

.p-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 60;
  animation: p-fade 0.18s ease-out;
}
@keyframes p-fade { from { opacity: 0; } to { opacity: 1; } }

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

#setupView.is-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(430px, 92vw);
  z-index: 61;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 20px 18px 0;
  background: var(--bg-main);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  animation: p-slide-in 0.22s cubic-bezier(0.22, 0.8, 0.3, 1);
}
@keyframes p-slide-in {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  #setupView.is-drawer, .p-scrim { animation: none; }
}

/* In drawer mode the page-level primary and the hero are redundant — the
   sticky foot carries the way out. */
#setupView.is-drawer .g-hero,
#setupView.is-drawer .p-modes,
#setupView.is-drawer #startBtn { display: none; }

.p-drawer-foot { display: none; }
#setupView.is-drawer .p-drawer-foot {
  display: block;
  position: sticky;
  bottom: 0;
  margin: 18px -18px 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-main);
  border-top: 1px solid var(--border-subtle);
}

.p-remaining { text-align: center; margin: 14px 0 0; font-size: 0.78rem; }


/* -- Confirm modal ------------------------------------------------------- */

.p-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 10, 14, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: p-fade 0.15s ease-out;
}
.p-modal__box {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px 22px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.p-modal__title { margin: 0 0 8px; font-size: 1.2rem; }
.p-modal__body { margin: 0 0 20px; font-size: 0.9rem; }
.p-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* The destructive option is the one that has to look destructive, and it is
   deliberately not the one focus lands on. */
.p-btn-leave {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.p-btn-leave:hover { background: var(--danger); border-color: var(--danger); opacity: 0.88; }
