/* Contrattack — mesa online.
   Paleta tirada da arte real: navy do logo, e as 4 cores de posição das cartas. */

:root {
  --navy:        #283378;
  --navy-deep:   #1B2350;
  --navy-ink:    #0F1430;
  --blue:        #2766A9;
  --red:         #A02825;
  --purple:      #57548F;

  --gol:  #59347D;
  --def:  #2B7F34;
  --mei:  #2B7EC1;
  --ata:  #B51B1A;

  --turf:        #1F5E33;
  --turf-alt:    #24693A;
  --turf-line:   rgba(255,255,255,.42);

  --paper:       #F4F5FA;
  --ink:         #10142C;
  --muted:       #6C7392;

  --panel:       #161C3D;
  --panel-2:     #1E2650;
  --panel-line:  #2E3766;
  --panel-ink:   #E8EBF7;
  --panel-muted: #9AA3C8;

  --gold:        #E8B94D;
  --good:        #4FBE79;
  --bad:         #E46A55;

  --r: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.28), 0 8px 26px rgba(0,0,0,.28);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--navy-ink);
  color: var(--panel-ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1 { font-size: 22px; margin: 0; text-wrap: balance; }
button, input, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ botões */
.btn {
  border: 1px solid var(--panel-line);
  background: var(--panel-2);
  color: var(--panel-ink);
  border-radius: 8px;
  padding: 9px 15px;
  font-weight: 600;
  transition: background .12s ease, transform .12s ease;
}
.btn:hover:not(:disabled) { background: #27306096; transform: translateY(-1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #2A1E02; }
.btn-primary:hover:not(:disabled) { background: #F2C862; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #6A2A22; color: #F0A090; }

/* ------------------------------------------------------------------ lobby */
#scr-lobby { align-items: center; justify-content: center; overflow: auto; }
.lobby {
  text-align: center;
  padding: 32px 24px 48px;
  max-width: 560px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.lobby-logo { width: min(400px, 78vw); height: auto; }
.lobby-sub { color: var(--panel-muted); margin: 0; }
.lobby-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.lobby-or { color: var(--panel-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
.lobby-join { display: flex; gap: 8px; }
#inp-code {
  width: 160px; text-align: center; letter-spacing: .28em; font-weight: 700;
  text-transform: uppercase; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--panel-line); background: var(--panel); color: var(--panel-ink);
}
.lobby-msg { min-height: 1.4em; margin: 0; color: var(--gold); font-size: 14px; }
.lobby-help {
  margin-top: 8px; text-align: left; color: var(--panel-muted); font-size: 13.5px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--r);
  padding: 12px 16px; width: 100%;
}
.lobby-help summary { cursor: pointer; color: var(--panel-ink); font-weight: 600; }
.lobby-help p { margin: 10px 0 0; }

/* ----------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--panel-line);
  flex: 0 0 auto;
}
.topbar-logo { height: 26px; width: auto; }
.topbar-code { color: var(--panel-muted); font-size: 13.5px; }
.topbar-code b { color: var(--panel-ink); letter-spacing: .12em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.conn { color: var(--good); font-size: 20px; line-height: 1; transition: color .2s; }
.conn.stale { color: var(--bad); }

/* ------------------------------------------------------------------ setup */
#scr-setup { overflow: auto; }
.setup-wrap { padding: 20px 24px 60px; max-width: 1180px; margin: 0 auto; width: 100%; }
.setup-head p { color: var(--panel-muted); margin: 6px 0 0; max-width: 68ch; }
.setup-controls {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 18px 0 10px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--r);
  position: sticky; top: 0; z-index: 5;
}
.setup-controls label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--panel-muted); }
.setup-controls select {
  background: var(--panel-2); color: var(--panel-ink);
  border: 1px solid var(--panel-line); border-radius: 8px; padding: 7px 10px;
}
.setup-count { font-family: var(--mono); font-size: 13px; color: var(--panel-muted); }
.setup-count.ok { color: var(--good); }
.setup-status { min-height: 1.5em; color: var(--gold); font-size: 14px; margin-bottom: 10px; }

.squad { display: flex; flex-direction: column; gap: 20px; }
.squad-group h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--panel-muted); margin: 0 0 8px; font-weight: 700;
}
.squad-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ------------------------------------------------------------------ carta */
.card {
  position: relative; flex: 0 0 auto;
  border-radius: 6px; overflow: hidden;
  background: var(--panel-2);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: transform .12s ease, border-color .12s ease;
  display: block; padding: 0; line-height: 0;
}
.card img { display: block; width: 100%; height: auto; }
.card.pick:hover { transform: translateY(-3px); }
.card.chosen { border-color: var(--gold); }
.card.dim { opacity: .38; filter: saturate(.5); }
.card.fora { transform: rotate(90deg) scale(.86); opacity: .6; }
.card.yellow::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 3px var(--gold);
}
.card.can-act { border-color: var(--gold); cursor: pointer; }
.card.can-act:hover { transform: translateY(-4px); }
.card.target { border-color: var(--good); cursor: pointer; }
.card.target:hover { transform: translateY(-4px); }
.card.ball-here { border-color: #FFF; }

.card-w56 { width: 56px; }
.card-w72 { width: 72px; }
.card-w94 { width: 94px; }
.card-w118 { width: 118px; }

.ball {
  position: absolute; right: -7px; top: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff 0 46%, #C9CEE4 47% 100%);
  border: 2px solid var(--navy-ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  z-index: 3;
}
.equip-chip {
  position: absolute; left: -5px; bottom: -5px; z-index: 3;
  background: var(--gold); color: #2A1E02;
  font-size: 10px; font-weight: 800; border-radius: 999px;
  padding: 1px 6px; border: 2px solid var(--navy-ink);
}

/* ------------------------------------------------------------------- jogo */
.game-grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: minmax(0,1fr) 320px;
}
.pitch-area { min-width: 0; display: flex; flex-direction: column; }
.pitch-scroll { flex: 1 1 auto; overflow: auto; padding: 14px; }

.scoreline { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.score-team { display: flex; align-items: center; gap: 8px; }
.score-team .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--panel-muted); }
.score-team.is-a .dot { background: var(--blue); }
.score-team.is-b .dot { background: var(--red); }
.score-team.turn { color: var(--gold); font-weight: 700; }
.score-team .en { font-family: var(--mono); font-size: 12.5px; color: var(--panel-muted); }
.score-nums { font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: .04em; }
.score-you { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }

/* campo */
.pitch {
  --lane-h: 108px;
  position: relative;
  min-width: 1080px;
  background:
    repeating-linear-gradient(90deg, var(--turf) 0 96px, var(--turf-alt) 96px 192px);
  border: 3px solid var(--turf-line);
  border-radius: 6px;
  padding: 10px 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
/* marcações do campo */
.pitch::before {
  content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px;
  width: 3px; background: var(--turf-line); transform: translateX(-50%); pointer-events: none;
}
.pitch::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 132px; height: 132px; margin: -66px 0 0 -66px;
  border: 3px solid var(--turf-line); border-radius: 50%; pointer-events: none;
}
.pitch-box {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 92px; height: 62%; border: 3px solid var(--turf-line); pointer-events: none;
}
.pitch-box.left  { left: 4px;  border-left: none; }
.pitch-box.right { right: 4px; border-right: none; }

.col {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; justify-content: space-around; align-items: center;
  gap: 4px; min-height: 520px;
}
.col-label {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255,255,255,.72); background: rgba(0,0,0,.34);
  padding: 1px 6px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}
.col.is-mine .col-label { color: var(--gold); }
.slot { display: flex; align-items: center; justify-content: center; min-height: 96px; }
.slot.empty { opacity: 0; }

.lane-legend {
  position: absolute; left: 2px; top: 0; bottom: 0; width: 0;
  pointer-events: none;
}

/* dado */
.dice-strip {
  flex: 0 0 auto; padding: 10px 14px; border-top: 1px solid var(--panel-line);
  background: var(--panel); display: flex; align-items: center; gap: 14px; min-height: 62px;
  flex-wrap: wrap;
}
.die {
  width: 44px; height: 44px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 20px; font-weight: 700;
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow);
}
.die.rolling { animation: shake .5s ease-in-out; }
@keyframes shake {
  0%,100% { transform: rotate(0) }
  20% { transform: rotate(-14deg) scale(1.08) }
  45% { transform: rotate(12deg) scale(1.05) }
  70% { transform: rotate(-7deg) }
}
.duel { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 14px; }
.duel .sum { font-size: 17px; font-weight: 700; }
.duel .win { color: var(--good); }
.duel .lose { color: var(--bad); }
.duel .vs { color: var(--panel-muted); font-size: 12px; }
.duel-who { font-family: var(--font); font-size: 13px; color: var(--panel-muted); }

/* painel lateral */
.side {
  border-left: 1px solid var(--panel-line); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.panel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--panel-line); }
.panel-title {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--panel-muted); padding: 10px 14px 6px; font-weight: 700;
}
.prompt-panel { flex: 0 0 auto; }
.prompt-body { padding: 0 14px 10px; font-size: 14px; }
.prompt-body .hint { color: var(--panel-muted); font-size: 13px; }
.prompt-actions { padding: 0 14px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-actions .btn { flex: 0 0 auto; }
.cost { font-family: var(--mono); font-size: 11.5px; opacity: .85; }

.log { flex: 1 1 auto; overflow-y: auto; padding: 4px 14px 14px; display: flex; flex-direction: column-reverse; gap: 7px; }
.log-entry { font-size: 13px; display: flex; gap: 8px; }
.log-entry .n { font-family: var(--mono); font-size: 10.5px; color: var(--panel-muted); padding-top: 2px; flex: 0 0 auto; }
.log-entry.goal { color: var(--gold); font-weight: 700; }
.log-entry.turnover { color: var(--bad); }
.log-entry.card { color: var(--blue); }

/* mão */
.hand-bar {
  flex: 0 0 auto; background: var(--panel); border-top: 1px solid var(--panel-line);
  padding: 8px 14px 12px;
}
.hand-meta { display: flex; align-items: baseline; gap: 12px; margin-bottom: 7px; }
.hand-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--panel-muted); font-weight: 700; }
.hand-count, .deck-count { font-family: var(--mono); font-size: 12px; color: var(--panel-muted); }
.hand { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; min-height: 118px; align-items: flex-start; }
.hand .card { cursor: pointer; }
.hand .card:hover { transform: translateY(-6px); }
.hand-empty { color: var(--panel-muted); font-size: 13px; padding: 30px 0; }

/* zoom */
.zoom {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8,10,24,.86); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; gap: 24px; padding: 24px;
}
.zoom img { max-height: 86vh; max-width: 46vw; border-radius: 10px; box-shadow: var(--shadow); }
.zoom-extra { max-width: 340px; color: var(--panel-ink); font-size: 14px; }
.zoom-extra h3 { margin: 0 0 8px; }
.zoom-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: none; color: #fff; font-size: 34px; line-height: 1;
}

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--gold); color: #2A1E02; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; z-index: 70; box-shadow: var(--shadow);
}

@media (max-width: 1000px) {
  .game-grid { grid-template-columns: 1fr; }
  .side { border-left: none; border-top: 1px solid var(--panel-line); max-height: 40vh; }
  .zoom { flex-direction: column; }
  .zoom img { max-width: 84vw; max-height: 62vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
