* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1a12;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* the canvas takes every finger itself: no scrolling, no zooming */
canvas { display: block; touch-action: none; }

#fade {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: #000;
  transition: opacity 0.25s;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.label {
  font-size: 12px;
  letter-spacing: 2.5px;
  font-weight: 700;
}

#board {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(10, 16, 34, 0.85);
  backdrop-filter: blur(4px);
  font-weight: 800;
}

#board .side {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  min-width: 104px;
  font-size: 15px;
  letter-spacing: 1px;
}

#sideA { justify-content: flex-start; }
#sideB { justify-content: flex-end; }
#board .pts { font-size: 26px; font-variant-numeric: tabular-nums; }

#board .mid { padding: 4px 14px; text-align: center; background: rgba(255, 255, 255, 0.08); }
#clock { font-size: 22px; color: #ffe58a; font-variant-numeric: tabular-nums; }

/* top left; on rigottigames.com it sits just under the arcade's back button */
#pauseBtn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
}

.arcade #pauseBtn { top: max(52px, calc(env(safe-area-inset-top) + 42px)); }

.pill {
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  touch-action: manipulation;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(10, 16, 34, 0.6);
  color: #fff;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  min-height: 44px;
  backdrop-filter: blur(4px);
}

#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: #10203f; }

/* bottom right, out of the way of the throw */
#soundBtn {
  position: absolute;
  z-index: 2;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
}

#msg {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 90%;
  text-align: center;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 24px rgba(0, 0, 0, 0.5);
}

#msg small { display: block; font-size: 18px; letter-spacing: 2px; margin-top: 4px; }
#msg.gold { color: #ffd94a; }
#msg.bad { color: #ff8a80; }

#hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  width: max-content;
  max-width: calc(100% - 340px);
  padding: 9px 20px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 999px;
  background: rgba(10, 16, 34, 0.8);
  backdrop-filter: blur(4px);
}

#hint:empty { display: none; }

/* ---------- sticks and buttons ---------- */

/* the bottom-left part of the screen: hold anywhere in it to run */
.zone {
  position: absolute;
  bottom: 0;
  width: 45%;
  height: 55%;
  pointer-events: auto;
  touch-action: none;
}

#stick1 { left: 0; }

.stick {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  opacity: 0.6;
}

.stick.held { opacity: 1; }

#stick1 .stick { left: max(26px, calc(env(safe-area-inset-left) + 16px)); }

/* buttons sit on top of the zones */
.act, #dives { z-index: 2; }

.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

#stick1 .knob { background: rgba(255, 216, 74, 0.9); }

.stick span {
  position: absolute;
  top: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0.7;
  pointer-events: none;
}

.act {
  position: absolute;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ffd94a;
  color: #4a3200;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}

.act:disabled {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: none;
  cursor: default;
}

/* ---------- the menu card ---------- */

.card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(64px, env(safe-area-inset-top)) 20px 28px;
  text-align: center;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, rgba(24, 110, 70, 0.9), rgba(4, 20, 14, 0.96));
  backdrop-filter: blur(3px);
}

.card > * { flex-shrink: 0; }
.card .top { margin: auto 0 0; }
.card .bottom { margin: 0 0 auto; }

.card h1 {
  margin: 0;
  font-size: 64px;
  letter-spacing: 4px;
  line-height: 1.05;
  color: #ffd94a;
  text-shadow: 0 5px 0 #06301c;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: 3px;
  color: #ffd94a;
}

.card .tag { margin: 10px 0 20px; font-size: 19px; letter-spacing: 1px; }
.card .note { max-width: 520px; margin: 0 auto 20px; font-size: 15px; line-height: 1.6; opacity: 0.92; }
.card .note:empty { display: none; }

.card .keys { list-style: none; margin: 0 0 18px; padding: 0; font-size: 14px; line-height: 2; }
.card .keys b {
  display: inline-block;
  padding: 1px 8px;
  margin: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 1px;
}

/* show the keys that match what you're holding */
.forTouch { display: none; }
@media (hover: none) {
  .forTouch { display: block; }
  .forKeys { display: none; }
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 8px;
}

button.big {
  cursor: pointer;
  border: none;
  background: #ffd94a;
  color: #4a3200;
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 2.5px;
  padding: 15px 28px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #b98a10;
  touch-action: manipulation;
}

button.big.plain { background: #fff; color: #10203f; box-shadow: 0 6px 0 #8f9bc0; }
button.big:disabled { opacity: 0.5; cursor: default; }
button.big small { display: block; font-size: 10px; letter-spacing: 1.5px; font-weight: 700; }

.points { font-size: 16px; margin: 0 0 12px; }
.points b { color: #8ff08f; font-size: 20px; }

/* team picker */
.teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  width: min(100%, 980px);
  margin: 6px 0 14px;
}

.confName {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  text-align: left;
  font-size: 13px;
  letter-spacing: 3px;
  opacity: 0.8;
}

.team {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 3px solid var(--c2);
  border-radius: 14px;
  background: var(--c1);
  color: #fff;
  font: inherit;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  touch-action: manipulation;
}

.team .flag { font-size: 30px; line-height: 1.1; text-shadow: none; }
.team .nm { font-size: 18px; font-weight: 800; letter-spacing: 1px; }
.team .ovr { font-size: 11px; letter-spacing: 1.5px; opacity: 0.9; }
.team:disabled { opacity: 0.3; cursor: default; }

/* lists: careers, your players, the shop, standings */
.list {
  width: min(100%, 560px);
  margin: 6px 0 14px;
  border-radius: 18px;
  background: #f1f4ff;
  color: #10203f;
  padding: 10px;
  text-align: left;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
}

.list .row + .row { border-top: 1px solid #d8def5; }
.list .row.me { background: #fff3c4; }
.row .icon { font-size: 26px; width: 36px; text-align: center; }
.row .about { flex: 1; min-width: 0; }
.row .name { font-weight: 800; letter-spacing: 0.5px; font-size: 15px; }
.row .what { font-size: 12px; line-height: 1.4; opacity: 0.75; }
.row .num { font-weight: 800; font-size: 18px; min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.row .chip { width: 18px; height: 18px; border-radius: 5px; border: 2px solid; flex-shrink: 0; }

.row button {
  border: none;
  border-radius: 999px;
  padding: 9px 12px;
  min-width: 84px;
  background: #3cb043;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 4px 0 #237a29;
  cursor: pointer;
  touch-action: manipulation;
}

.row button:disabled { background: #b9bdd0; box-shadow: 0 4px 0 #9094a8; cursor: default; }
.row button.del { min-width: 0; background: #d8dcf5; color: #10203f; box-shadow: none; }

.segs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 6px 0 18px; }
.segs button {
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  touch-action: manipulation;
}

.segs button.on { background: #ffd94a; border-color: #ffd94a; color: #4a3200; }

.next {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 16px;
  padding: 12px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 16px;
}

.next .vs { font-size: 13px; letter-spacing: 2px; opacity: 0.7; }
.next b { font-size: 20px; }
.trophies { font-size: 26px; letter-spacing: 4px; margin: 0 0 6px; }

/* narrow screens: the scoreboard drops below the buttons and the trophy pill */
@media (max-width: 760px) {
  #board { top: max(116px, calc(env(safe-area-inset-top) + 106px)); }
}

@media (max-width: 700px), (max-height: 560px) {
  .card { padding-top: max(52px, env(safe-area-inset-top)); }
  .card h1 { font-size: 40px; }
  .card h2 { font-size: 26px; }
  .card .tag { font-size: 15px; margin: 6px 0 12px; }
  .card .note { font-size: 13px; margin-bottom: 12px; }
  button.big { font-size: 14px; padding: 12px 18px; }
  #msg { font-size: 30px; }
  #msg small { font-size: 14px; }
  #board .side { min-width: 80px; padding: 4px 8px; font-size: 12px; }
  #board .pts { font-size: 20px; }
  #clock { font-size: 17px; }
  #hint { font-size: 12px; max-width: calc(100% - 300px); }
  .stick { width: 112px; height: 112px; }
  .act { width: 88px; height: 88px; font-size: 13px; }
  .act.small { width: 70px; height: 70px; font-size: 11px; }
  #act2 { bottom: max(118px, calc(env(safe-area-inset-bottom) + 108px)); }
  #act1 { bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px)); }
  #radar { display: none; }
}

/* ---------- soccer ---------- */

#board .abbr { display: flex; align-items: center; gap: 6px; }
#board .abbr i { font-style: normal; font-size: 20px; }

/* SHOOT is the big one, PASS sits above and to the left of it */
#act1 {
  right: max(28px, calc(env(safe-area-inset-right) + 18px));
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 24px));
}

.act.small {
  width: 84px;
  height: 84px;
  font-size: 13px;
  background: #fff;
  color: #10203f;
}

#act2 {
  right: max(150px, calc(env(safe-area-inset-right) + 140px));
  bottom: max(120px, calc(env(safe-area-inset-bottom) + 110px));
}

.act.go { background: #8ff08f; color: #08391a; }
.act.save { background: #6edcff; color: #003040; }
.act.hot { animation: hot 0.5s ease-in-out infinite alternate; }
@keyframes hot { to { transform: scale(1.1); } }
.act:active { filter: brightness(0.9); }

#radar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 54px));
  width: 70px;
  height: 108px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  opacity: 0.9;
}

#dives {
  position: absolute;
  left: 50%;
  bottom: max(30px, calc(env(safe-area-inset-bottom) + 20px));
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

#dives button {
  cursor: pointer;
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 16px 24px;
  font: inherit;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 1.5px;
  background: #6edcff;
  color: #003040;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
}

#dives button[data-dive="0"] { background: #fff; color: #10203f; }
#dives button.on { background: #ffd94a; color: #4a3200; }
#dives button:disabled { opacity: 0.45; }

/* the shootout: tap the goal where you want it to go */
.pens #stick1, .pens #act1, .pens #act2, .pens #radar { display: none; }

/* picking your position */
.positions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  width: min(100%, 920px);
  margin: 6px 0 14px;
}

.position {
  cursor: pointer;
  padding: 14px 14px 16px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  text-align: center;
  touch-action: manipulation;
}

.position .icon { font-size: 40px; }
.position .nm { font-size: 20px; font-weight: 800; letter-spacing: 1px; margin: 4px 0; }
.position .what { font-size: 13px; line-height: 1.45; opacity: 0.9; }

/* the group table */
table.group { width: 100%; border-collapse: collapse; font-size: 15px; }
table.group th { font-size: 11px; letter-spacing: 1.5px; opacity: 0.6; font-weight: 700; padding: 4px 6px; text-align: right; }
table.group td { padding: 7px 6px; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid #d8def5; }
table.group th:first-child, table.group td:first-child { text-align: left; }
table.group tr.me td { background: #fff3c4; font-weight: 800; }
table.group tr.through td:first-child { box-shadow: inset 4px 0 0 #3cb043; }

.results { font-size: 14px; line-height: 1.9; }
.results b { font-variant-numeric: tabular-nums; }
.stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 0 0 16px; }
.stats div { min-width: 82px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.12); font-size: 11px; letter-spacing: 1.5px; }
.stats b { display: block; font-size: 26px; letter-spacing: 0; color: #ffd94a; }
