/* Copa Pixel — visual retrô (ISS / Winning Eleven, era 16/32-bit) */

:root{
  --bg: #0b1622;
  --bg-panel: #122a3d;
  --bg-panel-2: #0d1f2d;
  --pitch: #2f7d4f;
  --pitch-dark: #1f5a39;
  --line: #e7e2c9;
  --accent: #ffcc33;
  --accent-ink: #1a1203;
  --lime: #8fe24a;
  --lime-ink: #0c2306;
  --danger: #e8503a;
  --text: #f1eedd;
  --text-dim: #93a6ae;
  --border: #3a5a4a;
  --shadow: #04080b;
}

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

html{ color-scheme: dark; }

body{
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -10%, var(--pitch-dark) 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 20px;
  line-height: 1.3;
  padding-inline: 16px;
  padding-block: 16px 48px;
}

img{ max-width: 100%; }
[hidden]{ display: none !important; }

h1,h2,h3{ font-family: 'Press Start 2P', monospace; text-wrap: balance; line-height: 1.5; }

.pixel{ image-rendering: pixelated; }

/* ---------- Topbar ---------- */

.topbar{
  max-width: 920px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand{
  font-family: 'Press Start 2P', monospace;
  font-size: 15px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 1px;
}
.brand span{ text-shadow: 2px 2px 0 var(--shadow); }
#session-name-tag{
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--text-dim);
  text-shadow: none;
  letter-spacing: 0;
}

/* ---------- Layout screens ---------- */

#app{ max-width: 920px; margin: 0 auto; }
.screen-narrow{ max-width: 520px; margin: 0 auto; }

/* ---------- Rodapé: Hall da Fama + reset geral ---------- */

#app-footer{ max-width: 920px; margin: 28px auto 0; }

.hof-item{ display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 2px dashed var(--border); }
.hof-item:last-child{ border-bottom: none; }
.hof-pos{ font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--text-dim); width: 20px; flex: none; }
.hof-item:first-child .hof-pos{ color: var(--accent); }
.hof-titles{ font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--accent); flex: none; }

.footer-admin{ text-align: center; margin-top: 18px; }
.link-ghost{
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'VT323', monospace;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: .6;
  cursor: pointer;
  padding: 10px;
}
.link-ghost:hover{ opacity: 1; }

.panel{
  background: var(--bg-panel);
  border: 3px solid var(--border);
  box-shadow: 5px 5px 0 var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.eyebrow{
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--lime);
  letter-spacing: 2px;
  margin: 0 0 14px;
}

/* ---------- Buttons ---------- */

.btn{
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--lime-ink);
  background: var(--lime);
  border: 3px solid var(--shadow);
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 12px 16px;
  cursor: pointer;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  touch-action: manipulation;
}
.btn:active{ transform: translate(3px,3px); box-shadow: 0 0 0 var(--shadow); }
.btn:disabled{ opacity: .4; cursor: not-allowed; }
.btn:disabled:active{ transform: none; box-shadow: 3px 3px 0 var(--shadow); }
.btn-gold{ background: var(--accent); color: var(--accent-ink); }
.btn-danger{ background: var(--danger); color: #2a0a05; }
.btn-ghost{ background: var(--bg-panel-2); color: var(--text); }
.btn-block{ width: 100%; }
.btn-sm{ font-size: 10px; padding: 8px 10px; box-shadow: 2px 2px 0 var(--shadow); }
.btn-sm:active{ transform: translate(2px,2px); box-shadow: 0 0 0 var(--shadow); }
.btn-circle{ border-radius: 999px; width: 52px; height: 52px; padding: 0; flex: none; }

.btn-row{ display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Form ---------- */

.field-row{ display: flex; gap: 10px; align-items: center; }

input[type="text"]{
  flex: 1;
  min-width: 0;
  font-family: 'VT323', monospace;
  font-size: 22px;
  background: var(--bg-panel-2);
  color: var(--text);
  border: 3px solid var(--border);
  padding: 10px 12px;
}
input[type="text"]:focus{ outline: 2px solid var(--lime); outline-offset: 2px; }

.photo-picker{
  flex: none;
  width: 52px; height: 52px;
  border: 3px solid var(--border);
  background: var(--bg-panel-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}
.photo-picker img{ width: 100%; height: 100%; object-fit: cover; }

/* ---------- Avatars ---------- */

.avatar{
  width: 44px; height: 44px;
  flex: none;
  background: var(--bg-panel-2);
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
}
.avatar img{ width: 100%; height: 100%; object-fit: cover; }
.avatar-lg{ width: 84px; height: 84px; font-size: 20px; }

/* ---------- Roster list ---------- */

.roster-item{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px;
  border-bottom: 2px dashed var(--border);
}
.roster-item:last-child{ border-bottom: none; }
.roster-name{ flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 22px; }
.roster-tag{ font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--lime); }

.empty-hint{ color: var(--text-dim); font-style: italic; padding: 10px 4px; }

.gate-hint{ font-size: 19px; color: var(--text-dim); margin: 0 0 14px; line-height: 1.4; }
.gate-hint strong{ color: var(--accent); font-style: normal; }

.session-password-line{
  font-size: 18px;
  color: var(--lime);
  background: var(--bg-panel-2);
  border: 2px dashed var(--border);
  padding: 10px 12px;
  margin: 0;
  text-align: center;
}

.session-row{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 6px;
  border-bottom: 2px dashed var(--border);
}
.session-row:last-of-type{ border-bottom: none; }
.session-row.selected{ border-bottom: none; padding-bottom: 6px; }
.session-row-info{ flex: 1; min-width: 0; }
.session-row-name{ font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row-meta{ font-size: 15px; color: var(--text-dim); }
.session-row-password{ padding: 0 6px 14px; border-bottom: 2px dashed var(--border); }
.session-row-password:last-child{ border-bottom: none; }

.badge{
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: var(--bg-panel-2);
  border: 2px solid var(--border);
  padding: 6px 10px;
  color: var(--accent);
}

/* ---------- Confirm screen ---------- */

.mode-toggle{ display: flex; gap: 10px; margin-bottom: 16px; }
.mode-card{
  flex: 1;
  padding: 14px 10px;
  text-align: center;
  background: var(--bg-panel-2);
  border: 3px solid var(--border);
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--text-dim);
}
.mode-card .big{ font-size: 26px; display: block; margin-bottom: 8px; }
.mode-card.active{ border-color: var(--accent); color: var(--accent); box-shadow: 3px 3px 0 var(--shadow); }

/* ---------- Bracket ---------- */

.bracket-scroll{ overflow-x: auto; padding-bottom: 8px; }
.bracket-rounds{ display: flex; gap: 22px; width: max-content; min-width: 100%; }
.round-col{ display: flex; flex-direction: column; gap: 18px; min-width: 240px; }
.round-title{
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--lime);
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 2px;
}
.round-col.extra-col .round-title{ color: var(--accent); }

.match-card{
  background: var(--bg-panel-2);
  border: 3px solid var(--border);
  padding: 10px;
  cursor: pointer;
}
.match-card.playable{ border-color: var(--lime); }
.match-card.done{ opacity: .9; }
.match-card.waiting{ opacity: .55; cursor: default; }
.match-card:active.playable{ transform: translate(2px,2px); }

.match-status{
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: 1px;
}
.match-status.live{ color: var(--danger); animation: blink 1.1s steps(1) infinite; }
.match-status.done{ color: var(--lime); }
.match-status.pending{ color: var(--text-dim); }
.match-status.waiting{ color: var(--text-dim); font-style: italic; }

@media (prefers-reduced-motion: reduce){ .match-status.live{ animation: none; } }
@keyframes blink{ 50%{ opacity: .35; } }

.match-row{ display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.match-row .roster-name{ font-size: 18px; }
.match-row.winner .roster-name{ color: var(--accent); }
.match-vs{ text-align: center; color: var(--text-dim); font-size: 14px; }

.score-box{
  font-family: 'Press Start 2P', monospace;
  font-size: 15px;
  min-width: 34px;
  text-align: center;
  background: var(--bg);
  border: 2px solid var(--line);
  color: var(--lime);
  padding: 4px 2px;
  flex: none;
}

.pen-note{
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  margin-top: 6px;
  letter-spacing: .5px;
}

/* ---------- Standings table ---------- */

.table-wrap{ overflow-x: auto; }
table.standings{ width: 100%; border-collapse: collapse; font-size: 19px; min-width: 460px; }
table.standings th{
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: var(--pitch-dark);
  color: var(--line);
  padding: 8px 6px;
  text-align: center;
  border-bottom: 3px solid var(--shadow);
}
table.standings td{ padding: 7px 6px; text-align: center; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); }
table.standings td.name-cell{ text-align: left; }
table.standings tbody tr:nth-child(odd){ background: var(--bg-panel-2); }
table.standings tbody tr:first-child{ box-shadow: inset 4px 0 0 var(--accent); }

/* ---------- Champion ---------- */

.champion-panel{
  text-align: center;
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 3px solid var(--accent);
  box-shadow: 5px 5px 0 var(--shadow);
  padding: 28px 18px;
}
.champion-trophy{ font-size: 48px; display: block; margin-bottom: 10px; }
.champion-label{ font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--text-dim); letter-spacing: 2px; margin-bottom: 10px; }
.champion-name{ font-family: 'Press Start 2P', monospace; font-size: 20px; color: var(--accent); text-shadow: 2px 2px 0 var(--shadow); }

/* ---------- Modal (zoom) ---------- */

.modal-backdrop{
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  z-index: 50;
  height: 100vh; height: 100dvh;
}
.modal-panel{
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow-y: auto;
}
@media (min-width: 560px){
  .modal-backdrop{ align-items: center; justify-content: center; background: rgba(4,8,11,.82); padding: 16px; }
  .modal-panel{ width: 100%; max-width: 480px; max-height: 92vh; border: 4px solid var(--accent); box-shadow: 6px 6px 0 var(--shadow); padding: 20px; }
}

.modal-head{ display: flex; align-items: center; justify-content: space-between; flex: none; margin-bottom: clamp(8px, 3vh, 16px); }
.modal-title{ font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--danger); letter-spacing: 1px; }
.modal-title.final{ color: var(--lime); }

.duel{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 3vw, 20px);
}
.duel-side{ flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.6vh, 12px); text-align: center; }
.duel-side .avatar-lg{ width: clamp(44px, 14vw, 84px); height: clamp(44px, 14vw, 84px); font-size: clamp(14px, 4vw, 20px); flex: none; }
.duel-name{
  font-size: clamp(15px, 4.2vw, 22px);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.duel-score{
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(24px, 8vw, 44px);
  color: var(--accent);
  background: var(--bg);
  border: 3px solid var(--line);
  padding: clamp(6px, 1.6vh, 10px) 6px;
  width: 100%;
  max-width: 110px;
  text-align: center;
  flex: none;
}
.duel-mid{ font-family: 'Press Start 2P', monospace; color: var(--text-dim); font-size: clamp(11px, 3vw, 14px); flex: none; }

.duel-side .btn{ width: 100%; font-size: clamp(10px, 2.6vw, 12px); padding: clamp(8px, 1.6vh, 12px) 8px; }
.correction-row{ display: flex; justify-content: center; margin-top: 4px; width: 100%; }
.correction-row .btn{ font-size: clamp(9px, 2.4vw, 10px); }

.pen-box{
  width: 100%;
  margin-top: clamp(4px, 1.4vh, 10px);
  padding-top: clamp(4px, 1.4vh, 10px);
  border-top: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pen-label{ font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--accent); letter-spacing: 1px; }
.pen-score{
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 5vw, 26px);
  color: var(--accent);
  background: var(--bg);
  border: 2px solid var(--accent);
  padding: 4px 10px;
}
.pen-final-note{ flex: none; text-align: center; color: var(--accent); font-size: clamp(14px, 3.6vw, 18px); margin: clamp(4px, 1.5vh, 8px) 0 0; }

.tie-hint{ flex: none; color: var(--danger); text-align: center; margin: clamp(6px, 2vh, 10px) 0 0; font-size: clamp(14px, 3.6vw, 18px); }

.modal-actions{ flex: none; display: flex; justify-content: center; margin-top: clamp(10px, 3vh, 16px); }

.toast{
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--bg-panel); border: 3px solid var(--danger);
  color: var(--text); padding: 10px 16px; font-size: 18px; z-index: 100;
  box-shadow: 4px 4px 0 var(--shadow);
  max-width: 90vw;
}
