/* Netplay surfaces: the TV room screen and the phone controller.
   Loaded only by tv.html and play.html — index.html (hotseat) is untouched.
   Design notes: docs/04-NETPLAY.md */

/* ---------------------------------------------------------------- the TV */

.tv-body .screen { padding: 2vmin; }

.room-code-wrap {
  text-align: center;
  margin: 2vh auto 3vh;
}

.room-label {
  font-size: clamp(14px, 2vw, 22px);
  letter-spacing: 0.4em;
  opacity: 0.7;
}

.room-code {
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(64px, 18vw, 220px);
  line-height: 1;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff2a8 0%, #ffb703 45%, #ff4d3a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 3px #14103a;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35));
}

.room-url {
  margin-top: 0.6em;
  font-size: clamp(12px, 1.4vw, 20px);
  opacity: 0.65;
  word-break: break-all;
}

.room-players {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2vmin;
  justify-content: center;
  margin: 1.5vh 0;
  min-height: 3vh;
}

.room-player {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.4em 1em;
  border: 3px solid var(--pc, #fff);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 800;
  font-size: clamp(14px, 1.8vw, 26px);
}

.room-dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--pc, #fff);
  box-shadow: 0 0 10px var(--pc, #fff);
}

#room-purse {
  font: inherit;
  background: rgba(0, 0, 0, 0.4);
  color: inherit;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

.tv-waiting {
  position: absolute;
  inset: auto 0 6% 0;
  text-align: center;
  pointer-events: none;
}

.tv-waiting-title {
  font-weight: 900;
  font-size: clamp(18px, 3vw, 40px);
  letter-spacing: 0.15em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}

.tv-waiting-sub {
  font-size: clamp(11px, 1.3vw, 18px);
  opacity: 0.7;
  margin-bottom: 1vh;
}

.tv-waiting-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1vmin;
  justify-content: center;
}

.tv-wait-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.3em 0.9em;
  border-radius: 999px;
  border: 3px solid var(--pc, #fff);
  background: rgba(0, 0, 0, 0.5);
  font-weight: 800;
  opacity: 0.55;
}

.tv-wait-row.done {
  opacity: 1;
  box-shadow: 0 0 18px var(--pc, #fff);
}

.tv-wait-state {
  font-size: 0.75em;
  opacity: 0.8;
}

/* ----------------------------------------------------------- the phone */

.phone-body {
  --me: #ff4d3a;
  overscroll-behavior: none;
}

.phone-body .screen {
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  margin: 4vh auto 0;
}

.join-code,
.join-name {
  font: inherit;
  font-weight: 900;
  text-align: center;
  padding: 0.5em;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.join-code {
  font-size: clamp(34px, 12vw, 60px);
  letter-spacing: 0.3em;
  text-indent: 0.3em; /* centres text that has trailing letter-spacing */
}

.join-name { font-size: clamp(18px, 5vw, 26px); }

/* The phone screen is a grid, not the hotseat's centred flex column: the
   battlefield gets whatever height is left over after the chrome, and the
   buttons sit BELOW it rather than floating on top of it. The global rule
   `#battlefield { position:absolute; inset:0 }` still applies, so the canvas
   is confined by a positioned stage instead of being re-positioned. */
#screen-play {
  display: none;
  gap: 4px;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  justify-content: initial;
  align-items: stretch;
}

#screen-play.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}

#phone-stage {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
}

.phone-body #battlefield { touch-action: none; }

#phone-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  padding: 2px 4px 6px;
  border-bottom: 2px solid var(--me);
}

#phone-gold.broke { color: #ff4d3a; }

#phone-banner {
  padding: 6px 4px;
  font-size: 0.85em;
  opacity: 0.85;
  text-align: center;
  min-height: 1.4em;
}

.phone-actions { margin-top: 6px; }

#phone-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

#phone-tools .type-btn {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-height: 44px; /* thumb target */
}

#phone-tools .type-btn.active {
  outline: 3px solid var(--me);
  outline-offset: 2px;
}

.type-sub {
  font-size: 0.7em;
  opacity: 0.75;
  font-weight: 600;
}

.wait-spinner {
  width: 56px;
  height: 56px;
  margin: 6vh auto;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--me);
  animation: cx-spin 900ms linear infinite;
}

@keyframes cx-spin { to { transform: rotate(360deg); } }

/* tactics controls on the phone (session 10) */
#phone-tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 4px; }
#phone-tabs .tab-btn { min-width: 0; flex: 1; max-width: 140px; min-height: 40px; }
.phone-break { flex-basis: 100%; height: 0; }
#phone-tools .stance-chip { min-height: 36px; display: inline-flex; align-items: center; }

/* phone held sideways: the battlefield takes the left, the controls stack on
   the right — a far bigger map to draw on (session 12) */
@media (orientation: landscape) and (max-height: 620px) {
  #screen-play.active {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 36vw);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    column-gap: 8px;
  }
  #phone-stage { grid-column: 1; grid-row: 1 / -1; }
  #phone-hud, #phone-banner, #phone-tabs, #phone-tools, .phone-actions { grid-column: 2; }
  #phone-tools { overflow-y: auto; align-content: flex-start; }
}
/* held upright: say once, quietly, that sideways is bigger */
@media (orientation: portrait) {
  #phone-stage::after {
    content: 'two fingers: pan + zoom \00b7  sideways: bigger';
    position: absolute;
    left: 0; right: 0; bottom: 6px;
    text-align: center;
    font-size: 11px;
    opacity: 0.45;
    pointer-events: none;
  }
}

/* --- big thumbs (AB, session 13: "large buttons for the phone version so
   the players dont make too many mistakes") — docs/01-HOW-IT-WORKS.md#phone-pinch-zoom
   Every control is at least 52px tall with a bigger label; the row gaps grow
   so a fat thumb lands on one button, and DONE (which sends the turn) sits
   apart from UNDO at the far end of its row. */
.phone-body #screen-play .btn { min-height: 52px; font-size: 17px; padding: 10px 14px; }
.phone-body #screen-play .btn-tool { font-size: 16px; }
.phone-body #phone-tools,
.phone-body #phone-tabs,
.phone-body .phone-actions { gap: 10px; }
.phone-body #phone-tools .type-btn { min-height: 60px; min-width: 96px; flex: 1 1 96px; max-width: 180px; }
.phone-body #phone-tools .stance-chip { min-height: 52px; }
.phone-body #phone-tabs .tab-btn { min-height: 52px; }
.phone-body .phone-actions { display: flex; flex-wrap: nowrap; }
.phone-body .phone-actions .btn { flex: 1 1 0; min-width: 0; min-height: 60px; font-size: 19px; }
.phone-body .phone-actions #btn-commit { margin-left: 14px; }
.phone-body #phone-banner { font-size: 1em; }
.phone-body .type-sub { font-size: 0.72em; }

/* two-finger zoom: a FIT button brings the whole field back */
#btn-fit {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 2;
  min-height: 44px !important;
  font-size: 15px !important;
  padding: 6px 12px !important;
  opacity: 0.9;
}

/* sideways the controls column is narrow: the four big actions go 2 x 2 */
@media (orientation: landscape) and (max-height: 620px) {
  .phone-body .phone-actions { flex-wrap: wrap; }
  .phone-body .phone-actions .btn { flex: 1 1 40%; min-height: 52px; }
  .phone-body .phone-actions #btn-commit { margin-left: 0; }
  .phone-body #phone-tools .type-btn { min-width: 84px; flex-basis: 84px; }
}
