/* =============================================================================
   Cadeira Infection — sistema visual inspirado em sinalização hospitalar:
   verde da placa de saída (pedestres), azul do símbolo de acesso (cadeirantes),
   amarelo de "cuidado: piso molhado" (alertas e o seu jogador).
   ============================================================================= */

:root {
  --green: #00894b;
  --green-dark: #006a3a;
  --green-tint: #dcefe4;
  --blue: #1558b0;
  --blue-dark: #0e4185;
  --blue-tint: #e1eaf7;
  --caution: #ffcc00;
  --caution-tint: #fff4c2;
  --alarm: #d7263d;
  --ink: #1f2933;
  --ink-2: #4f5d6b;
  --ink-3: #7b8794;
  --plate: #f7f9f8;
  --plate-2: #e9efec;
  --line: #cbd6d0;
  --edge: #b3c2ba;
  --floor: #d3dfd8;

  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-lg: 14px;
  --r: 9px;
  --r-sm: 6px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--floor);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
  letter-spacing: 0.1px;
}
h2 { font-size: 26px; }
h3 { font-size: 21px; }
p { margin: 0; }

.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 7px;
  border: 1px solid var(--edge);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  line-height: 1.35;
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--caution);
  outline-offset: 2px;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* -----------------------------------------------------------------------------
   Placas e controles
   ----------------------------------------------------------------------------- */
.plate {
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 3px 0 var(--edge);
}

.picto {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  flex: none;
}

.btn {
  --btn-bg: #fff;
  --btn-fg: var(--ink);
  --btn-edge: var(--edge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: var(--r);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 3px 0 var(--btn-edge);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--blue); --btn-fg: #fff; --btn-edge: var(--blue-dark); border-color: var(--blue); }
.btn-primary:hover { background: #1a64c6; border-color: #1a64c6; }
.btn-success { --btn-bg: var(--green); --btn-fg: #fff; --btn-edge: var(--green-dark); border-color: var(--green); }
.btn-danger { --btn-bg: #fff; --btn-fg: var(--alarm); border-color: #f0b8bf; }
.btn-danger:hover { border-color: var(--alarm); }
.btn-ghost { --btn-bg: #fff; }
.btn-lg { height: 54px; font-size: 22px; padding: 0 24px; }
.btn-sm { height: 34px; font-size: 16px; padding: 0 12px; box-shadow: 0 2px 0 var(--btn-edge); }
.btn-link {
  background: none;
  border: 0;
  padding: 6px 4px;
  color: var(--ink);
  font: 600 15px var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  height: auto;
  box-shadow: none;
}
.btn-link:active { transform: none; box-shadow: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--plate);
  box-shadow: 0 3px 0 var(--edge);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn .sound-off, .icon-btn[aria-pressed="true"] .sound-on { display: none; }
.icon-btn[aria-pressed="true"] .sound-off { display: inline; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field.grow { flex: 1; }
.field label, .field legend, .field-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  padding: 0;
}
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 600 17px var(--font-body);
}
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--caution); }
.input::placeholder { color: var(--ink-3); font-weight: 500; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); margin: 0; }

/* -----------------------------------------------------------------------------
   Telas
   ----------------------------------------------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.screen-home, .screen-lobby {
  background: rgba(211, 223, 216, 0.78);
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
}

/* ------------------------------ Início ------------------------------------ */
.home-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 36px;
  align-items: start;
  padding-top: 3vh;
}

.home-brand { display: flex; flex-direction: column; gap: 20px; }

.brand-sign { display: flex; align-items: center; gap: 10px; }
.sign-plate {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 12px;
  color: #fff;
  font-size: 50px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}
.sign-green { background: var(--green); }
.sign-blue { background: var(--blue); }
.sign-arrow { width: 40px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

.brand-title {
  font-weight: 800;
  font-size: clamp(52px, 7.4vw, 88px);
  line-height: 0.88;
  letter-spacing: -1px;
  color: var(--ink);
}
.brand-lede { font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 32em; }

.invite-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--caution-tint);
  border: 2px solid var(--caution);
  font-weight: 500;
}

.profile { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.profile-row { display: flex; gap: 16px; align-items: flex-end; }
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: var(--floor);
  border: 1px solid var(--line);
  flex: none;
}

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(31, 41, 51, 0.25);
  cursor: pointer;
  padding: 0;
  transition: transform 100ms ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }

.profile-actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.create-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.directory { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.directory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.rooms-list { list-style: none; margin: 0; padding: 0; max-height: min(52vh, 460px); overflow-y: auto; }
.room-row {
  width: 100%;
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 12px 0;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.room-row:hover { background: var(--plate-2); }
.room-state-bar { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--green); }
.room-row[data-state="PLAYING"] .room-state-bar,
.room-row[data-state="COUNTDOWN"] .room-state-bar { background: var(--blue); }
.room-row[data-state="GAME_OVER"] .room-state-bar { background: var(--caution); }
.room-row.is-full { cursor: not-allowed; opacity: 0.6; }
.room-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--ink-2); }
.room-count { font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.room-count small { font-size: 15px; color: var(--ink-3); }
.room-go {
  width: 10px;
  height: 10px;
  border-right: 3px solid var(--ink-3);
  border-top: 3px solid var(--ink-3);
  transform: rotate(45deg);
  margin-right: 4px;
}
.rooms-empty { padding: 28px 20px; color: var(--ink-2); text-align: center; }

.join-code { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); margin-top: auto; }
.join-code label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.join-code-row { display: flex; gap: 10px; }
.input-code { font-family: var(--font-display); font-size: 22px; letter-spacing: 3px; text-transform: uppercase; }

.home-foot {
  max-width: 1120px;
  margin: 28px auto 0;
  display: flex;
  gap: 20px;
}

/* ------------------------------- Lobby ------------------------------------ */
.screen-lobby { display: flex; flex-direction: column; gap: 18px; }
.screen-lobby > * { width: 100%; max-width: 1180px; margin-left: auto; margin-right: auto; }

.lobby-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
}
.lobby-title h1 { font-size: 40px; font-weight: 800; }
.lobby-code { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}
.code-chip strong { font-family: var(--font-display); font-size: 24px; letter-spacing: 3px; }

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.5fr);
  gap: 18px;
  align-items: start;
}
.lobby-grid > .plate { padding: 18px 20px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.player-row.is-you { border-color: var(--caution); box-shadow: inset 4px 0 0 var(--caution); }
.player-row.is-empty { background: transparent; border-style: dashed; color: var(--ink-3); min-height: 38px; }
.player-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(31, 41, 51, 0.3); }
.player-name { font-weight: 600; font-size: 17px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.player-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font: 700 13px var(--font-body);
  background: var(--plate-2);
  color: var(--ink-2);
  flex: none;
}
.tag-host { background: var(--caution); color: var(--ink); }
.tag-ready { background: var(--green-tint); color: var(--green-dark); }
.tag-wait { background: transparent; color: var(--ink-3); border: 1px solid var(--line); }
.player-side { display: flex; align-items: center; gap: 8px; }
.player-score { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.bot-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-weight: 600;
}
.bot-controls > span:first-child { margin-right: auto; }
.bot-count { font-family: var(--font-display); font-size: 22px; min-width: 24px; text-align: center; }
.bot-controls .btn { width: 38px; padding: 0; font-size: 24px; }

.map-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.map-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 12px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--r);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  position: relative;
}
.map-card:hover { border-color: var(--ink-3); }
.map-card[aria-checked="true"] { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.map-card[aria-checked="true"]::after {
  content: 'Escolhido';
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  font: 700 13px var(--font-body);
}
.map-card canvas { width: 100%; height: auto; border-radius: 6px; display: block; background: var(--floor); margin-bottom: 6px; }
.map-card strong { font-family: var(--font-display); font-size: 20px; line-height: 1.1; padding: 0 4px; }
.map-card small { color: var(--ink-2); font-size: 13.5px; line-height: 1.35; padding: 0 4px; }
.map-card .map-players { color: var(--ink-3); font-weight: 600; }
.is-guest .map-card, .is-guest .segmented button, .is-guest #input-powerups { pointer-events: none; }
.is-guest .map-card:not([aria-checked="true"]) { opacity: 0.55; }

.settings-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 28px; margin-bottom: 18px; }
.segmented { display: inline-flex; border: 2px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 0 14px;
  height: 40px;
  font: 700 17px var(--font-display);
  color: var(--ink);
  cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--ink); color: #fff; }
.check-inline { height: 44px; }

.lobby-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-top: auto;
}
.lobby-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
#btn-ready[aria-pressed="true"] { --btn-bg: var(--green); --btn-fg: #fff; --btn-edge: var(--green-dark); border-color: var(--green); }

/* ------------------------------- HUD -------------------------------------- */
.screen-game { overflow: hidden; pointer-events: none; }
.screen-game button, .screen-game .touch { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
}
.team-counter { display: flex; gap: 8px; }
.team {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 14px 0 10px;
  border-radius: 10px;
  color: #fff;
  font-size: 30px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.team strong { font-family: var(--font-display); font-weight: 800; font-size: 30px; font-variant-numeric: tabular-nums; }
.team-ped { background: var(--green); }
.team-wc { background: var(--blue); }

.hud-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 18px 6px;
  border-radius: 10px;
  background: var(--plate);
  border: 1px solid var(--line);
  box-shadow: 0 3px 0 var(--edge);
}
#hud-timer { font-family: var(--font-display); font-weight: 800; font-size: 40px; line-height: 1.05; font-variant-numeric: tabular-nums; }
#hud-map { font-size: 13px; font-weight: 600; }
.hud-timer.is-urgent #hud-timer { color: var(--alarm); animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { opacity: 0.55; } }
.hud-buttons { display: flex; gap: 8px; justify-content: flex-end; }

.announce {
  position: absolute;
  top: calc(86px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 640px);
}
.announce-item {
  padding: 10px 22px;
  border-radius: 10px;
  color: #fff;
  font: 700 26px/1.15 var(--font-display);
  text-align: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  animation: drop 260ms cubic-bezier(.2, .9, .3, 1.3);
}
.announce-item small { display: block; font: 500 16px var(--font-body); opacity: 0.92; margin-top: 2px; }
.announce-item.tone-ped { background: var(--green); }
.announce-item.tone-wc { background: var(--blue); }
.announce-item.tone-warn { background: var(--caution); color: var(--ink); }
.announce-item.tone-ink { background: var(--ink); }
.announce-item.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity 300ms, transform 300ms; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(0.96); } }

.killfeed {
  position: absolute;
  top: calc(76px + var(--safe-top));
  right: calc(14px + var(--safe-right));
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 330px;
}
.kill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(247, 249, 248, 0.94);
  border: 1px solid var(--line);
  font-size: 14.5px;
  font-weight: 500;
  animation: slide 220ms ease-out;
}
.kill strong { font-weight: 700; }
.kill .picto { font-size: 18px; color: var(--blue); }
.kill.kill-warn .picto { color: var(--green); }
.kill.is-leaving { opacity: 0; transition: opacity 400ms; }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

.hud-bottom {
  position: absolute;
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
}
.ability { width: 310px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ability-role { display: flex; align-items: center; gap: 12px; }
.ability-role strong { display: block; font: 700 22px/1 var(--font-display); }
.ability-role small { font-size: 14px; }
.role-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  color: #fff;
  font-size: 36px;
}
.role-badge.role-ped { background: var(--green); }
.role-badge.role-wc { background: var(--blue); }
.meter-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.boost-label { color: var(--ink); background: var(--caution); padding: 0 6px; border-radius: 4px; }
.meter-track { height: 10px; border-radius: 5px; background: var(--plate-2); overflow: hidden; }
.meter-fill { height: 100%; width: 100%; background: var(--green); border-radius: 5px; transform-origin: left; }
.meter-fill.is-wc { background: var(--blue); }
.meter-fill.is-low { background: var(--alarm); }
.skill { display: grid; grid-template-columns: auto 1fr 90px; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.skill-track { height: 8px; border-radius: 4px; background: var(--plate-2); overflow: hidden; }
.skill-fill { height: 100%; width: 100%; background: var(--caution); }
.skill.is-ready .skill-fill { background: var(--ink); }

.minimap {
  width: 220px;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 3px 0 var(--edge);
  background: var(--plate);
}

.controls-card {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(560px, 92vw);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise 300ms ease-out;
}
.controls-card h3 { display: flex; align-items: center; gap: 8px; font-size: 22px; }
.controls-card .keys { margin: 0; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; margin: 10px 0; }
.keys dt { display: flex; gap: 4px; flex-wrap: wrap; }
.keys dd { margin: 0; }

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
.countdown-number {
  font: 800 min(34vw, 180px)/0.9 var(--font-display);
  color: var(--ink);
  text-shadow: 0 6px 0 var(--caution);
  animation: pop 1s ease-out infinite;
}
.countdown-number.is-go { color: var(--green); text-shadow: 0 6px 0 var(--ink); animation: none; }
.countdown-text {
  padding: 8px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font: 700 24px var(--font-display);
  text-align: center;
  max-width: 92vw;
}
.countdown-text.is-zero { background: var(--blue); }
@keyframes pop { 0% { transform: scale(1.25); opacity: 0.3; } 25% { transform: scale(1); opacity: 1; } }

/* Controles de toque */
.touch { position: absolute; inset: 0; pointer-events: none; }
.touch-stick-zone { position: absolute; left: 0; top: 30%; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
.touch-stick {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 3px solid rgba(31, 41, 51, 0.35);
  background: rgba(247, 249, 248, 0.35);
  transform: translate(-50%, -50%);
  left: 110px;
  bottom: 40px;
  opacity: 0.6;
}
.touch-stick.is-active { opacity: 1; }
.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: var(--plate);
  border: 2px solid var(--ink-3);
  box-shadow: 0 3px 0 var(--edge);
}
.touch-buttons {
  position: absolute;
  right: calc(18px + var(--safe-right));
  bottom: calc(26px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
}
.touch-btn {
  border-radius: 50%;
  border: 0;
  color: #fff;
  font: 700 18px var(--font-display);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-action { width: 92px; height: 92px; background: var(--green); }
.touch-action.is-wc { background: var(--blue); }
.touch-sprint { width: 68px; height: 68px; background: var(--ink); }
.touch-btn.is-down { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }

/* -----------------------------------------------------------------------------
   Resultado e diálogos
   ----------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 51, 0.5);
  overflow-y: auto;
}
.screen-results { z-index: 30; }

.results { width: min(820px, 100%); overflow: hidden; padding: 0; }
.results-banner { display: flex; align-items: center; gap: 18px; padding: 20px 24px; color: #fff; }
.results-banner.banner-ped { background: var(--green); }
.results-banner.banner-wc { background: var(--blue); }
.results-banner h1 { font-size: 42px; font-weight: 800; }
.results-banner p { font-size: 17px; opacity: 0.94; margin-top: 4px; }
.banner-picto { font-size: 64px; display: grid; }

.awards { list-style: none; margin: 0; padding: 16px 24px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.award { padding: 8px 12px; border-radius: var(--r); background: #fff; border: 1px solid var(--line); }
.award small { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.award strong { font-family: var(--font-display); font-size: 19px; }

.table-wrap { padding: 12px 24px 0; overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.results-table th {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 8px;
  border-bottom: 2px solid var(--line);
}
.results-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.results-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.results-table td.num { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.results-table tr.is-you td { background: var(--caution-tint); }
.results-table .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.results-table .who .picto { font-size: 20px; }
.results-table .end-ped { color: var(--green); }
.results-table .end-wc { color: var(--blue); }
.results-table .rank { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--ink-3); width: 32px; }

.results-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 24px 22px; }

.dialog { width: min(440px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.help { width: min(780px, 100%); gap: 14px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.help-cols > div { padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.help-role { display: flex; align-items: center; gap: 8px; font-size: 24px; }
.help-role .picto { font-size: 30px; }
.role-ped-text { color: var(--green); }
.role-wc-text { color: var(--blue); }

.connection {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 16px;
  border-radius: var(--r);
  background: var(--caution);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 3px 0 var(--caution-dark, #d9ad00);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(480px, 92vw);
  pointer-events: none;
}
.toast {
  width: 100%;
  padding: 10px 14px 10px 16px;
  border-radius: var(--r);
  background: var(--plate);
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  box-shadow: 0 3px 0 var(--edge);
  font-weight: 500;
  animation: rise-toast 200ms ease-out;
}
.toast.kind-error { border-left-color: var(--alarm); }
.toast.kind-warn { border-left-color: var(--caution); }
.toast.kind-ok { border-left-color: var(--green); }
.toast.is-leaving { opacity: 0; transition: opacity 300ms; }
@keyframes rise-toast { from { opacity: 0; transform: translateY(8px); } }

/* -----------------------------------------------------------------------------
   Responsivo
   ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; gap: 24px; padding-top: 0; }
  .lobby-grid { grid-template-columns: 1fr; }
  .help-cols { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .brand-title { font-size: 52px; }
  .brand-lede { font-size: 16px; }
  .sign-plate { width: 54px; height: 54px; font-size: 40px; }
  .profile-actions { grid-template-columns: 1fr; }
  .lobby-title h1 { font-size: 32px; }
  .map-picker { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .results-banner h1 { font-size: 32px; }
  .banner-picto { font-size: 46px; }
  .results-table th:nth-child(4), .results-table td:nth-child(4) { display: none; }
}

/* HUD compacto em telas pequenas ou baixas (celular deitado) */
@media (max-width: 760px), (max-height: 520px) {
  .team { height: 38px; font-size: 24px; padding: 0 10px 0 8px; }
  .team strong { font-size: 24px; }
  #hud-timer { font-size: 30px; }
  #hud-map { display: none; }
  .hud-buttons .icon-btn { width: 38px; height: 38px; }
  .ability { width: 220px; padding: 8px 10px; gap: 6px; }
  .ability-role small, .skill kbd { display: none; }
  .role-badge { width: 34px; height: 34px; font-size: 26px; }
  .ability-role strong { font-size: 18px; }
  .skill { grid-template-columns: 1fr 70px; font-size: 13px; }
  .minimap { width: 140px; }
  .killfeed { max-width: 220px; }
  .kill { font-size: 13px; padding: 4px 8px; }
  .announce-item { font-size: 21px; padding: 8px 14px; }
  .announce { top: calc(64px + var(--safe-top)); }
  .controls-card { display: none; }
}

/* Telas baixas (celular deitado): lobby sem barra fixa e HUD mais enxuto */
@media (max-height: 520px) {
  .lobby-actions { position: static; }
  .lobby-head { padding: 10px 14px; }
  .lobby-title h1 { font-size: 28px; }
  .ability-role { display: none; }
  .ability { width: 190px; }
  .minimap { width: 124px; }
}

/* Em modo toque, o painel de habilidade sobe para dar espaço ao joystick */
.touch-mode .hud-bottom { bottom: auto; top: calc(66px + var(--safe-top)); align-items: flex-start; }
.touch-mode .ability { order: 0; }
.touch-mode .killfeed { top: auto; bottom: calc(260px + var(--safe-bottom)); }
.touch-mode .skill kbd { display: none; }

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