* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0d1b12;
  --panel: #16291c;
  --panel2: #1e3826;
  --green: #3ddc6a;
  --gold: #ffc83d;
  --white: #f2f7f3;
  --muted: #8fae98;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: "Arial Rounded MT Bold", -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 24px;
  overflow-y: auto;
}
.screen.active { display: flex; }

.hidden { display: none !important; }

h1 { font-size: 44px; line-height: 1.05; letter-spacing: 2px; }
h1 span { color: var(--gold); }
h2 { font-size: 26px; margin: 8px 0 14px; }

.big-btn {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 8px auto;
  padding: 16px 20px;
  font-size: 19px;
  font-weight: bold;
  font-family: inherit;
  color: var(--white);
  background: var(--panel2);
  border: 2px solid #2f5a3c;
  border-radius: 16px;
  cursor: pointer;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.gold { background: var(--gold); color: #3a2c00; border-color: #d9a51e; }
.big-btn:disabled { opacity: 0.4; }

/* TITLE */
.title-wrap { margin: auto; text-align: center; width: 100%; max-width: 420px; }
.title-ball { font-size: 84px; animation: bounce 1.6s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-22px); }
}
.tagline { color: var(--muted); margin: 10px 0 28px; font-size: 16px; }

/* SETUP */
.setup-box { width: 100%; max-width: 460px; }
.setup-box label { display: block; color: var(--muted); margin: 14px 0 6px; font-size: 14px; }
#inp-name {
  width: 100%;
  padding: 14px;
  font-size: 20px;
  font-family: inherit;
  font-weight: bold;
  color: var(--white);
  background: var(--panel);
  border: 2px solid #2f5a3c;
  border-radius: 12px;
}
.country-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 38vh;
  overflow-y: auto;
  padding: 4px;
}
.country-btn {
  padding: 10px 4px;
  background: var(--panel);
  border: 2px solid #2f5a3c;
  border-radius: 12px;
  color: var(--white);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.country-btn .cflag { display: block; font-size: 28px; margin-bottom: 2px; }
.country-btn.sel { border-color: var(--gold); background: #3a3110; }

/* HUB */
#screen-hub { max-width: 560px; margin: 0 auto; }
.hub-top { width: 100%; }
.player-card, .team-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--panel);
  border: 2px solid #2f5a3c;
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.pc-flag { font-size: 40px; }
.pc-info { flex: 1; }
.pc-name { font-size: 22px; }
.pc-sub { color: var(--muted); font-size: 14px; }
.pc-rating {
  font-size: 30px;
  color: #1d1502;
  background: var(--gold);
  border-radius: 12px;
  padding: 6px 14px;
}
.team-card { justify-content: space-between; }
.tc-team { font-size: 18px; }
.tc-league { color: var(--muted); font-size: 14px; }
.tc-stars { color: var(--gold); font-size: 18px; }

.hub-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
}
.stat {
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
}
.stat span { display: block; font-size: 22px; color: var(--green); }
.stat label { font-size: 11px; color: var(--muted); }

.next-match {
  width: 100%;
  background: var(--panel2);
  border: 2px solid #2f5a3c;
  border-radius: 16px;
  padding: 12px 16px;
  text-align: center;
  margin-bottom: 12px;
}
.nm-label { font-size: 12px; color: var(--gold); letter-spacing: 2px; }
.nm-opp { font-size: 20px; margin-top: 4px; }
.hub-btns { width: 100%; }

/* UPGRADE / TROPHIES */
.upgrade-box { width: 100%; max-width: 420px; text-align: center; }
.up-rating { font-size: 30px; margin: 12px 0 4px; }
.up-rating span { color: var(--gold); }
.up-sp { font-size: 18px; color: var(--green); margin-bottom: 16px; }
.up-hint { color: var(--muted); font-size: 14px; margin: 14px 0 24px; line-height: 1.5; }

.trophy-list { width: 100%; max-width: 460px; flex: 1; overflow-y: auto; }
.trophy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.trophy-row .ticon { font-size: 26px; }
.trophy-row .tname { flex: 1; font-size: 16px; }
.trophy-row .tyear { color: var(--muted); }
.trophy-empty { color: var(--muted); text-align: center; margin-top: 40px; line-height: 1.6; }

/* MATCH */
#screen-match { padding-top: calc(env(safe-area-inset-top, 0px) + 8px); }
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 640px;
  background: var(--panel);
  border: 2px solid #2f5a3c;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 10px;
}
.sb-team { font-size: 15px; width: 34%; }
.sb-team:last-child { text-align: right; }
.sb-score { text-align: center; }
.sb-score span:first-child { font-size: 26px; display: block; }
.sb-min { color: var(--gold); font-size: 13px; }

.match-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
#game-canvas {
  width: 100%;
  height: auto;
  max-height: 100%;
  border-radius: 14px;
  background: #1a7a3a;
  touch-action: none;
}
.moment-card {
  background: var(--panel2);
  border: 2px solid var(--gold);
  border-radius: 18px;
  padding: 22px 30px;
  text-align: center;
  width: 90%;
  max-width: 380px;
}
.mc-min { color: var(--gold); font-size: 15px; }
.mc-type { font-size: 28px; margin: 6px 0; }
.mc-desc { color: var(--muted); font-size: 15px; margin-bottom: 16px; }

.event-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  text-align: center;
  background: rgba(13, 27, 18, 0.82);
  border-radius: 14px;
  padding: 20px;
}

.event-feed {
  width: 100%;
  max-width: 640px;
  height: 88px;
  overflow-y: auto;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.event-feed .goal-us { color: var(--green); }
.event-feed .goal-them { color: #ff7b7b; }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-box {
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  text-align: center;
}
.modal-title { font-size: 24px; margin-bottom: 10px; }
.modal-body { color: var(--white); font-size: 16px; line-height: 1.6; margin-bottom: 18px; white-space: pre-line; }
