:root {
  --field-dark: #0a3d1f;
  --field-mid: #0d4a26;
  --field-light: #1a6b3a;
  --accent: #f0c040;
  --accent-hover: #ffd966;
  --red: #e63946;
  --blue: #457b9d;
  --yellow: #e9c46a;
  --green: #2a9d8f;
  --white: #f1faee;
  --dark: #1d3557;
  --card-bg: rgba(10, 40, 20, 0.92);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

body {
  font-family: 'Roboto', sans-serif;
  background: var(--field-dark);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

.field-bg {
  position: fixed;
  inset: 0;
  background: 
    linear-gradient(180deg, #051a0c 0%, #0a3d1f 40%, #0d4a26 70%, #051a0c 100%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 49px,
      rgba(255,255,255,0.03) 50px,
      rgba(255,255,255,0.03) 51px
    );
  z-index: -1;
}

.field-bg::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80vmin;
  height: 80vmin;
  border: 3px solid rgba(255,255,255,0.08);
  border-radius: 50%;
}

.field-bg::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.06);
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Logo */
.logo {
  font-family: 'Russo One', sans-serif;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  color: var(--accent);
  text-shadow: 0 0 20px rgba(240,192,64,0.5), 0 4px 8px rgba(0,0,0,0.5);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.logo.floating {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.subtitle {
  color: rgba(255,255,255,0.7);
  margin-bottom: 30px;
  font-size: 1.1rem;
}

/* Auth */
.auth-container {
  background: var(--card-bg);
  padding: 40px 36px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.tab.active {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form.hidden {
  display: none;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
  padding: 14px 16px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
}

.error-msg {
  color: #ff6b6b;
  margin-top: 12px;
  font-size: 0.9rem;
  min-height: 20px;
}

/* Buttons */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(240,192,64,0.35);
}

.btn-secondary {
  background: rgba(255,255,255,0.12);
  color: white;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}

.btn-big {
  width: 100%;
  max-width: 280px;
  padding: 18px;
  font-size: 1.2rem;
  margin: 8px 0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background: #4a4a4a !important;
  color: #999 !important;
}

/* Menu */
.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

/* Create tournament */
.create-container {
  background: var(--card-bg);
  padding: 36px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  border: 1px solid rgba(255,255,255,0.08);
}

.create-container h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--accent);
}

.create-step label {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
}

.create-step label.label-center {
  text-align: center;
  margin-top: 10px;
  margin-bottom: 20px;
}

.create-step input[type="text"] {
  width: 100%;
  margin-bottom: 16px;
}

.create-footer-btns {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 22px;
}

.create-footer-btns .btn {
  min-width: 150px;
}

.player-count-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0 8px;
}

.count-btn {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  border: 3px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.count-btn:hover, .count-btn.selected {
  border-color: var(--accent);
  background: rgba(240,192,64,0.2);
  color: var(--accent);
  transform: scale(1.05);
}

.team-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}

.team-row input {
  flex: 1;
}

.color-picker {
  display: flex;
  gap: 6px;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.color-btn.selected {
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
}

.color-btn[data-color="red"] { background: var(--red); }
.color-btn[data-color="blue"] { background: var(--blue); }
.color-btn[data-color="yellow"] { background: var(--yellow); }
.color-btn[data-color="green"] { background: var(--green); }

/* Table */
#screen-table {
  justify-content: flex-start;
  padding-top: 30px;
}

.table-header {
  text-align: center;
  margin-bottom: 20px;
}

.table-header h2 {
  font-family: 'Russo One', sans-serif;
  color: var(--accent);
  font-size: 1.8rem;
  margin-bottom: 6px;
}

#tour-info {
  color: rgba(255,255,255,0.6);
  font-size: 0.95rem;
}

.table-wrapper {
  width: 100%;
  max-width: 900px;
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 12px 10px;
  text-align: center;
}

th {
  background: rgba(0,0,0,0.35);
  color: var(--accent);
  font-weight: 600;
  position: sticky;
  top: 0;
}

th.abbr {
  cursor: help;
  position: relative;
}

th.points {
  font-weight: 800;
  color: #fff;
}

td:first-child {
  text-align: left;
  padding-left: 16px;
  font-weight: 600;
}

tr:nth-child(even) {
  background: rgba(255,255,255,0.03);
}

tr:hover {
  background: rgba(240,192,64,0.08);
}

.club-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.club-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.points-cell {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.table-exit-wrap {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  margin-bottom: 20px;
}

.btn-exit {
  background: rgba(230, 57, 70, 0.25);
  color: #ff8a95;
  border: 1px solid rgba(230, 57, 70, 0.5);
  padding: 12px 36px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-exit:hover {
  background: rgba(230, 57, 70, 0.45);
  color: #fff;
  transform: translateY(-2px);
}

/* Балансы команд */
.balances-board {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  margin: 20px auto 8px;
  padding: 0;
  box-sizing: border-box;
  align-items: stretch;
}

.balances-board.layout-2 {
  grid-template-columns: 1fr 1fr;
}

.balances-board.layout-3 {
  grid-template-columns: 1fr 1fr;
}

.balances-board.layout-3 .balance-card:last-child {
  grid-column: 1 / -1;
  width: 100%;
  max-width: calc((100% - 12px) / 2);
  justify-self: center;
}

.balances-board.layout-4 {
  grid-template-columns: 1fr 1fr;
}

.balance-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 14px 16px;
  border: 2px solid transparent;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  width: 100%;
  min-height: 72px;
  height: 100%;
  box-sizing: border-box;
}

.balance-card .bal-color {
  width: 12px;
  align-self: stretch;
  min-height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
}

.balance-card .bal-info {
  flex: 1;
  min-width: 0;
}

.balance-card .bal-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.balance-card .bal-money {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.balance-card .bal-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.balance-card .bal-btn {
  width: 32px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}

.balance-card .bal-btn:hover {
  background: rgba(240, 192, 64, 0.35);
  color: var(--accent);
}

.balance-card .bal-btn.minus:hover {
  background: rgba(230, 57, 70, 0.35);
  color: #ff8a95;
}

/* Simulation */
.sim-container {
  background: var(--card-bg);
  padding: 28px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  border: 1px solid rgba(255,255,255,0.08);
}

.sim-container h2 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 20px;
}

.teams-setup {
  display: flex;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.team-box {
  flex: 1;
  min-width: 240px;
  background: rgba(0,0,0,0.25);
  padding: 18px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.1);
}

.team-box h3 {
  text-align: center;
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.stats-inputs label {
  display: grid;
  grid-template-columns: 110px 1fr 22px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.stats-inputs .stat-label {
  text-align: left;
  white-space: nowrap;
}

.stats-inputs input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.stats-inputs span {
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}

.vs {
  display: flex;
  align-items: center;
  font-family: 'Russo One', sans-serif;
  font-size: 1.5rem;
  color: var(--accent);
  padding: 0 8px;
}

.sim-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.sim-actions.hidden {
  display: none;
}

/* Живое табло матча */
.live-scoreboard {
  background: rgba(0,0,0,0.45);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: 0 0 20px rgba(240,192,64,0.2);
  animation: fadeIn 0.3s ease;
}

.live-scoreboard.hidden {
  display: none;
}

.scoreboard-time {
  font-family: 'Russo One', sans-serif;
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.scoreboard-score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.scoreboard-team {
  font-weight: 600;
  font-size: 1rem;
  min-width: 120px;
}

.scoreboard-team.home {
  text-align: right;
  color: #90ee90;
}

.scoreboard-team.away {
  text-align: left;
  color: #ffb4a2;
}

.scoreboard-digits {
  font-family: 'Russo One', sans-serif;
  font-size: 2rem;
  color: white;
  background: rgba(0,0,0,0.4);
  padding: 6px 18px;
  border-radius: 10px;
  min-width: 90px;
}

.sim-result {
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
}

.sim-result.hidden {
  display: none;
}

.match-events {
  max-height: 260px;
  overflow-y: auto;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 10px 8px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.4;
  min-height: 40px;
}

.event-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
  animation: goalPop 0.35s ease;
}

.event-side {
  min-height: 1.4em;
  padding: 4px 8px;
  border-radius: 8px;
}

.event-side.home {
  text-align: left;
  justify-self: stretch;
}

.event-side.away {
  text-align: right;
  justify-self: stretch;
}

.event-side.goal-home {
  color: #90ee90;
  background: rgba(144, 238, 144, 0.08);
}

.event-side.goal-away {
  color: #ffb4a2;
  background: rgba(255, 100, 80, 0.08);
}

.event-side.red-home,
.event-side.red-away {
  color: #ff4d5a;
  font-weight: 600;
  background: rgba(255, 77, 90, 0.12);
}

@keyframes goalPop {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

.event-minute {
  color: #ffffff;
  font-weight: 600;
}

.final-score {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent);
}

.final-score.hidden {
  display: none;
}

.sim-result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.sim-result-actions.hidden {
  display: none;
}

/* Tour results */
.tour-container {
  background: var(--card-bg);
  padding: 28px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  border: 1px solid rgba(255,255,255,0.08);
}

.tour-container h2 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 8px;
}

.tour-hint {
  text-align: center;
  color: rgba(255,255,255,0.6);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.tour-match {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  background: rgba(0,0,0,0.25);
  padding: 12px 14px;
  border-radius: 12px;
}

.tour-match .team-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.tour-match .score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tour-match input[type="number"] {
  width: 48px;
  text-align: center;
  padding: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

.tour-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* My games */
.mygames-container {
  background: var(--card-bg);
  padding: 28px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  border: 1px solid rgba(255,255,255,0.08);
}

.mygames-container h2 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 20px;
}

.game-card {
  background: rgba(0,0,0,0.3);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.game-card:hover {
  border-color: var(--accent);
  background: rgba(240,192,64,0.1);
}

.game-card h3 {
  color: var(--accent);
  margin-bottom: 6px;
}

.game-card p {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
}

.empty-games {
  text-align: center;
  color: rgba(255,255,255,0.5);
  padding: 30px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 40px rgba(240,192,64,0.3);
}

.winner-content h1 {
  font-family: 'Russo One', sans-serif;
  color: var(--accent);
  font-size: 1.8rem;
  margin-bottom: 16px;
}

#winner-text {
  font-size: 1.2rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

#golden-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

#golden-choices button {
  padding: 14px;
  font-size: 1.05rem;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: #1a1a1a;
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
}

.tooltip.hidden {
  display: none;
}

/* Confetti simple */
.confetti {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti::before,
.confetti::after {
  content: '🎉 ⚽ 🏆 🎊 ⚽ 🎉';
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 1.8rem;
  animation: confettiFall 2.5s ease-in infinite;
}

.confetti::after {
  animation-delay: 1.2s;
  font-size: 1.4rem;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(320px) rotate(20deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 600px) {
  .teams-setup {
    flex-direction: column;
  }
  .vs {
    padding: 8px 0;
  }
  .table-actions {
    flex-direction: column;
    align-items: center;
  }
  .btn {
    width: 100%;
    max-width: 280px;
  }
}
