:root {
  --navy: #071733;
  --blue: #0b4fb3;
  --blue2: #0f67d8;
  --red: #c1121f;
  --green: #047857;
  --amber: #d97706;
  --bg: #eef3f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe4ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11,79,179,0.18), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(193,18,31,0.12), transparent 26rem),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { max-width: 1280px; margin: 0 auto; padding: 22px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 58px; height: 58px; object-fit: contain; border-radius: 16px; background: var(--navy); padding: 6px; }
.brand span { display: block; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.18em; font-weight: 800; }
.brand strong { display: block; font-size: clamp(1.5rem, 3vw, 2.3rem); color: var(--navy); line-height: 1; }
.back-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: #fff; color: var(--navy); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; font-weight: 800; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08); }

.setup-card, .game-area { background: rgba(255,255,255,0.92); border: 1px solid rgba(148,163,184,0.35); border-radius: 28px; padding: clamp(18px, 3vw, 34px); box-shadow: 0 22px 60px rgba(15,23,42,0.12); }
.setup-heading { max-width: 760px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); text-transform: uppercase; letter-spacing: 0.18em; font-weight: 900; font-size: 0.75rem; }
h1, h2, h3, p { margin-top: 0; }
.setup-heading h1, .match-toolbar h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 4rem); line-height: 1; color: var(--navy); }
.setup-heading p { color: var(--muted); font-size: 1.05rem; }
.mode-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 26px 0; }
.mode-tab { display: flex; justify-content: center; align-items: center; gap: 10px; border: 1px solid var(--line); background: #f8fafc; color: var(--navy); border-radius: 18px; padding: 16px; font-weight: 900; }
.mode-tab.active { background: linear-gradient(135deg, var(--blue), var(--blue2)); color: #fff; border-color: transparent; box-shadow: 0 14px 30px rgba(11,79,179,0.24); }
.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: grid; gap: 7px; font-size: 0.88rem; font-weight: 900; color: #1e293b; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; background: #fff; color: var(--text); outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(11,79,179,0.12); }
.setup-options { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 22px 0; }
.check-row { display: inline-flex; align-items: center; gap: 9px; background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; }
.check-row input { width: auto; }
.primary-btn, .ghost-btn, .danger-btn, .warning-btn { border: 0; border-radius: 16px; padding: 13px 18px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary-btn { background: linear-gradient(135deg, var(--blue), var(--blue2)); color: #fff; box-shadow: 0 16px 34px rgba(11,79,179,0.26); }
.ghost-btn { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.danger-btn { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.warning-btn { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.full { width: 100%; margin-top: 12px; }

.match-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.message-box { margin: 14px 0; padding: 12px 14px; border-radius: 16px; background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; font-weight: 800; }
.message-box.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.message-box.success { background: #ecfdf5; color: #047857; border-color: #bbf7d0; }
.score-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.player-card { border-radius: 26px; background: linear-gradient(180deg, #fff, #f8fafc); border: 2px solid var(--line); padding: 22px; position: relative; overflow: hidden; }
.player-card::after { content: ''; position: absolute; inset: auto -50px -80px auto; width: 180px; height: 180px; border-radius: 50%; background: rgba(11,79,179,0.08); }
.player-card.active { border-color: var(--blue); box-shadow: 0 18px 45px rgba(11,79,179,0.18); }
.player-card:nth-child(2).active { border-color: var(--red); box-shadow: 0 18px 45px rgba(193,18,31,0.14); }
.player-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.player-topline span { font-weight: 1000; color: var(--navy); font-size: clamp(1.1rem, 2.3vw, 1.7rem); }
.player-topline small { color: var(--muted); background: #f1f5f9; border-radius: 999px; padding: 6px 10px; font-weight: 900; }
.big-score { font-size: clamp(4rem, 10vw, 8rem); font-weight: 1000; line-height: 1; color: var(--navy); letter-spacing: -0.07em; margin: 10px 0; }
.checkout-pill { display: inline-flex; padding: 8px 12px; border-radius: 999px; background: #fef3c7; color: #92400e; font-weight: 900; }
.mini-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.mini-stats span { background: #f8fafc; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; color: var(--muted); font-weight: 800; }
.mini-stats strong { color: var(--navy); display: block; font-size: 1.1rem; }

.control-grid { display: grid; grid-template-columns: minmax(290px, 0.8fr) minmax(0, 1.2fr); gap: 18px; align-items: start; }
.input-card, .history-card { background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: 0 12px 34px rgba(15,23,42,0.07); }
.input-card h2, .history-card h2 { color: var(--navy); margin-bottom: 10px; }
.current-player { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; border-radius: 14px; padding: 10px 12px; font-weight: 900; margin-bottom: 12px; }
#scoreInput { font-size: 2rem; text-align: center; font-weight: 1000; }
.quick-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.quick-buttons button { border: 1px solid var(--line); background: #f8fafc; color: var(--navy); border-radius: 14px; padding: 12px 8px; font-weight: 1000; }
.input-actions { display: grid; grid-template-columns: 1fr 0.75fr; gap: 10px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.history-head span { color: var(--muted); font-size: 0.78rem; font-weight: 900; }
.history-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.history-duo h3 { margin-bottom: 10px; color: var(--navy); }
.visit-list { display: grid; gap: 8px; max-height: 380px; overflow: auto; padding-right: 4px; }
.visit-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--line); background: #f8fafc; border-radius: 14px; padding: 10px; }
.visit-row .visit-main { font-weight: 1000; color: var(--navy); }
.visit-row .visit-sub { color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.visit-row .visit-score { font-size: 1.1rem; font-weight: 1000; color: var(--blue); }
.visit-row.bust .visit-score { color: var(--red); }
.empty-history { color: var(--muted); font-style: italic; border: 1px dashed var(--line); border-radius: 14px; padding: 12px; background: #f8fafc; }

.modal { position: fixed; inset: 0; background: rgba(2,6,23,0.68); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal-card { width: min(440px, 100%); background: #fff; border-radius: 26px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,0.28); }
.modal-card h2 { color: var(--navy); }
.finish-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.finish-buttons button { border: 1px solid var(--line); border-radius: 16px; background: #eff6ff; color: #1e40af; font-weight: 1000; padding: 14px 10px; }

@media (max-width: 860px) {
  .app-shell { padding: 14px; }
  .topbar, .match-toolbar { align-items: stretch; flex-direction: column; }
  .setup-grid, .score-layout, .control-grid, .history-duo, .mode-tabs { grid-template-columns: 1fr; }
  #playerBCard.solo-hidden, #historyBColumn.solo-hidden { display: none; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions button { flex: 1; }
}


/* Teclado numérico interno para o modo Treino */
#scoreInput {
  caret-color: transparent;
  user-select: none;
  cursor: default;
  background: #f8fafc;
  border: 2px solid #dbeafe;
  color: var(--navy);
}

.numeric-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.keypad-btn {
  min-height: 58px;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  color: var(--navy);
  font-size: 1.45rem;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(15,23,42,0.08);
  touch-action: manipulation;
}

.keypad-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 4px 10px rgba(15,23,42,0.08);
}

.keypad-btn.muted {
  font-size: 0.9rem;
  background: #eef2ff;
  color: #1e3a8a;
}

@media (max-width: 720px) {
  .numeric-keypad {
    gap: 8px;
  }

  .keypad-btn {
    min-height: 54px;
    font-size: 1.35rem;
    border-radius: 14px;
  }

  .keypad-btn.muted {
    font-size: 0.82rem;
  }
}


/* Botões rápidos removidos do modo Treino */
.quick-buttons {
  display: none !important;
}

.numeric-keypad {
  margin-top: 14px;
  margin-bottom: 14px;
}
