/*
 * Beachball clone — UI theme.
 * Warm tropical flat-cartoon: sunlit parchment boards with a chunky wooden
 * ledge, pressable 3D buttons, one sunny primary action per screen.
 * Palette + material rules follow client/assets/STYLE.md.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --panel-a: #fdf1d3;
  --panel-b: #f6d9a2;
  --panel-c: #f2d194;
  --border: #a5640a;
  --ledge: #7c4a06;          /* darker wood under every board/button */
  --btn-a: #f4d9a0;
  --btn-b: #e0b87a;
  --btn-border: #6b3a10;
  --btn-ink: #4a2c07;
  --primary-a: #ffc95e;      /* sunny CTA */
  --primary-b: #ff9124;
  --primary-border: #8a4508;
  --ink: #4b3620;
  --ink-soft: #7a5c39;
  --key-border: #8b857a;
  --green: #1d8f43;          /* left-player accent (matches in-game flash) */
  --blue: #1f63d8;           /* right-player accent */
  --gold: #ffc107;
  --coral: #e2552f;
  --bar-track: #e8d0a0;
}

html, body { height: 100%; }
body {
  overflow: hidden;
  font-family: 'Lilita One', 'Trebuchet MS', sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.25ch;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 205, 130, 0.12), transparent 55%),
    radial-gradient(ellipse at center, #2e1e10 0%, #1a120a 62%, #0e0905 100%);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
.arial, .num { font-family: 'Open Sans', sans-serif; font-weight: 700; }

h1, h2, h3 { color: var(--ink); font-weight: 400; }
.green { color: var(--green); }
a { color: var(--ink); }

/* ------------------------------------------------ stage / canvas ------ */
#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
}
#court {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
  display: block;
  box-shadow:
    0 0 110px rgba(255, 190, 110, 0.20),
    0 0 26px rgba(0, 0, 0, 0.45);
}
.totem {
  width: min(9vw, 130px);
  height: 82vh;
  align-self: flex-end;
  margin: 0 -6px;
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}
#totem-right { transform: scaleX(-1); }
.totem { transition: filter 1.2s; }
body.venue-sunset .totem { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) sepia(0.25) saturate(1.2) brightness(0.9) hue-rotate(-12deg); }
body.venue-night .totem { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5)) brightness(0.5) saturate(0.7); }
body { transition: background 1.2s; }
body.venue-sunset {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 140, 110, 0.16), transparent 55%),
    radial-gradient(ellipse at center, #2e1a22 0%, #1a0f16 62%, #0e080c 100%);
}
body.venue-night {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(90, 130, 220, 0.14), transparent 55%),
    radial-gradient(ellipse at center, #121a30 0%, #0a0f1e 62%, #05070e 100%);
}
@media (max-aspect-ratio: 1000/700) { .totem { display: none; } }

/* ------------------------------------------------ generic UI --------- */
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: auto;
  padding-bottom: 7vh; /* the classic layouts float slightly high */
}
.screen.center { align-items: center; justify-content: center; }
.screen.center-top { align-items: flex-start; justify-content: center; padding-top: 5vh; }
.hidden { display: none !important; }

.panel {
  background: linear-gradient(165deg, var(--panel-a), var(--panel-b) 62%, var(--panel-c));
  border: 3px solid var(--border);
  border-radius: 18px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -3px 0 rgba(165, 100, 10, 0.16),
    0 5px 0 var(--ledge),
    0 16px 28px rgba(25, 12, 0, 0.4);
  padding: 18px 22px;
}

/* panel section titles: engraved ink with a short sunny underline */
.panel h2, .panel h3 {
  display: table;
  color: #5b3a10;
  letter-spacing: 0.035em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.panel h2::after, .panel h3::after {
  content: '';
  display: block;
  height: 4px;
  width: 3.2em;
  margin-top: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary-a), var(--primary-b));
  opacity: 0.85;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4ch;
  background: linear-gradient(var(--btn-a), var(--btn-b));
  border: 3px solid var(--btn-border);
  border-radius: 14px;
  padding: 7px 16px 5px;
  color: var(--btn-ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
}
.btn:hover {
  filter: brightness(1.1) saturate(1.08);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.btn.small { padding: 4px 10px 2px; font-size: 0.85em; border-radius: 11px; box-shadow: 0 3px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55); }
.btn.big { font-size: 1.5rem; padding: 10px 34px 7px; border-radius: 18px; }
.btn.disabled { filter: grayscale(0.8) brightness(0.9); cursor: default; }
.btn.disabled:hover, .btn.disabled:active { transform: none; box-shadow: 0 4px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.35); }

/* the one sunny action per screen */
.btn.primary, .menu-btn.selected {
  background: linear-gradient(var(--primary-a), var(--primary-b));
  border-color: var(--primary-border);
  color: #fff;
  text-shadow: 0 2px 0 rgba(130, 60, 0, 0.45);
  box-shadow: 0 4px 0 var(--primary-border), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover { box-shadow: 0 5px 0 var(--primary-border), inset 0 2px 0 rgba(255, 255, 255, 0.5); }
.btn.primary:active { box-shadow: 0 1px 0 var(--primary-border), inset 0 2px 0 rgba(255, 255, 255, 0.3); }

.back-btn {
  position: absolute;
  top: 14px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(var(--btn-a), var(--btn-b));
  border: 3px solid var(--btn-border);
  box-shadow: 0 3px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
}
.back-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.back-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-border); }
.back-btn::before {
  content: '\2190';
  display: block;
  text-align: center;
  line-height: 29px;
  font-size: 1.15em;
  color: var(--btn-ink);
}

.kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 3px 5px 1px;
  text-align: center;
  background: linear-gradient(#ffffff, #ddd7ca);
  border: 2px solid var(--key-border);
  border-radius: 0.45em;
  box-shadow: 0 3px 0 var(--key-border);
  color: #312f2c;
  font-size: 0.82em;
}
.kbd.arr { color: #1857c9; font-family: 'Open Sans', sans-serif; font-weight: 700; }

.coin-ico {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  margin-left: 0.3ch;
  vertical-align: -0.18em;
  background: url(assets/coins/2.svg) center / contain no-repeat;
}

.bar {
  position: relative;
  height: 30px;
  min-width: 220px;
  background: var(--bar-track);
  border: 3px solid var(--border);
  border-radius: 15px;
  box-shadow: inset 0 3px 5px rgba(122, 74, 6, 0.3);
  overflow: hidden;
}
.bar .bar-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(#9be08b, #3ba747);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 60, 20, 0.18);
  border-radius: 0 12px 12px 0;
  transition: width 0.25s;
}
.bar .bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 46%, transparent 60%);
  animation: barSheen 3.2s linear infinite;
}
@keyframes barSheen {
  0%, 55% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.bar.orange .bar-fill { background: linear-gradient(#ffd27a, #ff9d00); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.4), inset 0 -3px 0 rgba(140, 70, 0, 0.2); }
.bar .bar-text {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 25px;
  font-size: 0.82em;
  letter-spacing: 0.01em;
  color: #4a3110;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.bar.wide { width: 340px; }

/* springy pop-in for every board when a screen appears */
@keyframes panelPop {
  0% { opacity: 0; transform: translateY(20px) scale(0.92); }
  62% { opacity: 1; transform: translateY(-4px) scale(1.015); }
  100% { opacity: 1; transform: none; }
}
.screen .panel { animation: panelPop 0.42s cubic-bezier(0.33, 1.35, 0.6, 1) backwards; }

/* ------------------------------------------------ loading ------------ */
.load-panel { display: flex; align-items: center; gap: 22px; padding: 24px 34px; font-size: 1.5em; }
.load-anim { position: relative; width: 70px; height: 90px; flex: 0 0 auto; }
.load-ball {
  position: absolute; left: 5px; top: 0;
  width: 60px; height: 60px; border-radius: 50%;
  background: conic-gradient(#3fae2a 0 60deg, #ff8a00 60deg 120deg, #ffd400 120deg 180deg, #e53026 180deg 240deg, #f4f4f4 240deg 300deg, #2456d6 300deg 360deg);
  border: 3px solid rgba(0, 0, 0, 0.25);
  animation: loadBounce 0.7s cubic-bezier(0.3, 0, 0.6, 1) infinite alternate,
             loadSpin 1.4s linear infinite;
}
.load-shadow {
  position: absolute; left: 10px; bottom: 0;
  width: 50px; height: 10px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  animation: loadShadow 0.7s cubic-bezier(0.3, 0, 0.6, 1) infinite alternate;
}
@keyframes loadBounce { from { top: 0; } to { top: 24px; } }
@keyframes loadSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes loadShadow { from { transform: scaleX(0.7); opacity: 0.5; } to { transform: scaleX(1); opacity: 0.9; } }
.load-text { display: flex; flex-direction: column; gap: 10px; }
#load-bar { width: 240px; }
#load-bar .bar-text { font-family: 'Open Sans', sans-serif; font-weight: 700; font-size: 0.6em; line-height: 26px; }

/* ------------------------------------------------ main menu ---------- */
.menu-row {
  margin: auto;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 0 12px;
}
.menu-row .howto { animation-delay: 0.08s; }
.menu-row .news { animation-delay: 0.16s; }

.howto { padding: 16px 22px; }
.howto h2 { margin-bottom: 12px; }
.howto ul { list-style: none; margin-bottom: 16px; }
.howto li { margin: 8px 0; }
.howto em { font-style: normal; font-family: 'Open Sans', sans-serif; font-weight: 700; color: var(--ink-soft); }

.title-panel { display: flex; flex-direction: column; align-items: center; padding: 22px 36px 16px; }
.game-title { position: relative; margin-bottom: 20px; }
.game-title .logo-img {
  width: 330px;
  display: block;
  filter: drop-shadow(0 4px 0 rgba(122, 74, 6, 0.25));
  animation: logoSway 5s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}
@keyframes logoSway {
  from { transform: rotate(-1.3deg); }
  to { transform: rotate(1.3deg); }
}
.game-title.small .logo-img { width: 250px; animation: none; }

.menu-btn {
  min-width: 220px;
  margin: 8px 0;
  padding: 9px 0 6px;
  text-align: center;
  font-size: 1.3rem;
  background: linear-gradient(var(--btn-a), var(--btn-b));
  border: 3px solid var(--btn-border);
  border-radius: 14px;
  color: var(--btn-ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
}
.menu-btn:hover { filter: brightness(1.1) saturate(1.08); transform: translateY(-1px); }
.menu-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-border); }
.menu-btn.selected { font-size: 1.55rem; padding: 11px 0 8px; }
.menu-btn.selected:active { box-shadow: 0 1px 0 var(--primary-border); }

.corner-btns { align-self: flex-end; margin-top: 14px; display: flex; gap: 10px; }
.gear-btn, .sound-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(var(--btn-a), var(--btn-b));
  border: 3px solid var(--btn-border);
  box-shadow: 0 3px 0 var(--btn-border), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 0.08s, filter 0.12s, box-shadow 0.08s;
  position: relative;
}
.gear-btn:hover, .sound-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.gear-btn:active, .sound-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-border); }
.gear-btn::before { content: '\2699'; position: absolute; inset: 0; text-align: center; line-height: 35px; font-size: 1.35em; color: var(--btn-ink); transition: transform 0.25s; }
.gear-btn:hover::before { transform: rotate(60deg); }
.sound-btn::before { content: '\1F50A'; position: absolute; inset: 0; text-align: center; line-height: 34px; font-size: 1.05em; }
.sound-btn.muted { filter: saturate(0.4); }
.sound-btn.muted::before { content: '\1F507'; }

.news { max-width: 290px; text-align: center; }
.news h3 { margin-inline: auto; font-size: 0.95em; color: var(--ink-soft); }
.news h3::after { display: none; }
.news-headline { color: var(--coral); margin: 6px auto 8px; }
.news .news-headline::after { margin-inline: auto; }
.news p { margin-top: 10px; font-size: 0.9em; line-height: 1.35; text-wrap: balance; }
.news p b { color: var(--coral); font-weight: 400; }
#news-court-preview {
  position: relative;
  height: 120px;
  display: flex;
  border-radius: 12px;
  border: 3px solid var(--border);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 3px 0 rgba(124, 74, 6, 0.35);
}
/* three time-of-day slices of the court, painted in CSS */
.np { flex: 1; position: relative; }
.np::before {   /* sun / moon */
  content: '';
  position: absolute;
  border-radius: 50%;
}
.np::after {    /* sea + sand bands */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 46%;
}
.np-day { background: linear-gradient(#4bbcef, #9fe0f8 70%); }
.np-day::before { width: 26px; height: 26px; left: 30%; top: 16%; background: radial-gradient(circle at 40% 38%, #fffef0, #ffd23a 70%); box-shadow: 0 0 16px 6px rgba(255, 233, 150, 0.7); animation: npBreathe 3s ease-in-out infinite alternate; }
.np-day::after { background: linear-gradient(#1976d2 0 14%, #4fc6e0 14% 45%, #fff 45% 52%, #f5d494 52%); }
.np-sunset { background: linear-gradient(#2a2463, #b04f86 50%, #ffb56a 88%); }
.np-sunset::before { width: 38px; height: 38px; left: 32%; bottom: 36%; background: linear-gradient(#fff2b0, #ff9a4a 60%, #ff6a3d); box-shadow: 0 0 22px 8px rgba(255, 150, 90, 0.55); }
.np-sunset::after { background: linear-gradient(#83508c 0 14%, #e08a8c 14% 45%, #fff0e2 45% 52%, #efb788 52%); }
.np-night { background: radial-gradient(1px 1px at 20% 20%, #fff, transparent), radial-gradient(1px 1px at 70% 12%, #fff, transparent), radial-gradient(1.5px 1.5px at 45% 35%, #fff, transparent), radial-gradient(1px 1px at 85% 40%, #fff, transparent), linear-gradient(#060b21, #1a2d5e 80%); }
.np-night::before { width: 20px; height: 20px; left: 55%; top: 14%; background: radial-gradient(circle at 40% 40%, #fff, #cfd9ef); box-shadow: 0 0 14px 5px rgba(190, 215, 255, 0.45); }
.np-night::after { background: linear-gradient(#0a2350 0 14%, #155379 14% 45%, #b8fbff 45% 52%, #958e95 52%); }
@keyframes npBreathe { to { transform: scale(1.12); } }

.howto-new {
  position: relative;
  margin-top: 4px;
  padding: 9px 12px 7px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px dashed rgba(165, 100, 10, 0.45);
}
.howto-new em { font-style: normal; font-family: 'Open Sans', sans-serif; font-weight: 700; color: var(--ink-soft); font-size: 0.85em; }
.howto-sub { margin-top: 4px; font-size: 0.85em; color: var(--ink-soft); }
.spike-w { color: #d4570e; font-weight: 400; }
.dig-w { color: #1a7fb8; font-weight: 400; }
.new-tag {
  position: absolute;
  top: -11px; right: 10px;
  padding: 1px 8px 0;
  border-radius: 8px;
  font-size: 0.72em;
  color: #fff;
  background: linear-gradient(#ff7aa8, #ff3d7f);
  border: 2px solid #b3124e;
  box-shadow: 0 2px 0 #7a0b35;
  animation: tagWiggle 2.6s ease-in-out infinite;
}
@keyframes tagWiggle { 0%, 85%, 100% { transform: rotate(0); } 90% { transform: rotate(-8deg) scale(1.1); } 95% { transform: rotate(6deg) scale(1.1); } }

.footer-bar { position: fixed; left: 0; bottom: 0; width: 100%; display: flex; justify-content: center; pointer-events: auto; }
.footer {
  display: flex; gap: 3ch;
  padding: 7px 28px 4px;
  border-radius: 16px 16px 0 0;
  border-bottom: none;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6);
  animation: none;
}
.footer a, .footer span { color: var(--ink-soft); text-decoration: none; cursor: pointer; font-size: 0.85em; transition: transform 0.1s, color 0.1s; }
.footer a:hover, .footer span:hover { transform: scale(1.1); color: var(--ink); }

/* ------------------------------------------------ setup -------------- */
.setup-row {
  margin: auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0 10px;
}
.col { display: flex; flex-direction: column; gap: 14px; }
.setup-row .col:nth-child(1) .panel { animation-delay: 0.07s; }
.setup-row .col:nth-child(3) .panel { animation-delay: 0.14s; }
.col .panel:nth-child(2) { animation-delay: 0.2s; }

.choose-panel { position: relative; }
.choose-panel h3 { margin-bottom: 12px; }

.char-grid { display: flex; flex-wrap: wrap; width: 316px; gap: 8px; }
.char-item {
  width: 72px; height: 72px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: linear-gradient(#cdeffe, #92dcf8);
  box-shadow: 0 3px 0 rgba(124, 74, 6, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
}
.char-item:hover { transform: translateY(-3px) rotate(-2deg) scale(1.05); box-shadow: 0 6px 0 rgba(124, 74, 6, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.5); }
.char-item canvas { width: 62px; height: 62px; }
.char-item.locked { background: linear-gradient(#9fc6d8, #74a9c0); }
.char-item.locked canvas { filter: brightness(0) opacity(0.4); }
.char-item.locked::after {
  content: '?';
  position: absolute;
  font-size: 1.8em; color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.55);
}
.char-item.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 143, 67, 0.4), 0 3px 0 rgba(20, 90, 40, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.char-item.selected::before {
  content: '\2713';
  position: absolute;
  top: -8px; right: -8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.85em;
  line-height: 21px;
  text-align: center;
  z-index: 1;
}
.char-item.frozen { pointer-events: none; opacity: 0.5; }

#char-progress-wrap { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
#char-progress { flex: 1; }
#shop-info { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 1.05em; }
#btn-shop-back { margin-top: 10px; }
.price-tag { display: inline-flex; align-items: center; color: #8a6100; }

#ball-list { display: flex; flex-wrap: wrap; gap: 8px; width: 316px; }
.ball-item {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(124, 74, 6, 0.45);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
}
.ball-item:hover { transform: translateY(-3px) scale(1.08); box-shadow: 0 6px 0 rgba(124, 74, 6, 0.4); }
.ball-item canvas { width: 100%; height: 100%; }
.ball-item.locked { filter: saturate(0.15) brightness(0.75); }
.ball-item.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 143, 67, 0.4), 0 3px 0 rgba(20, 90, 40, 0.55);
}
#ball-info { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 1.05em; }

.start-panel { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 28px; }
#player-name {
  margin-top: 16px;
  width: 250px;
  font-size: 1.2em;
  font-family: inherit;
  text-align: center;
  padding: 8px 8px 5px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 3px 6px rgba(122, 74, 6, 0.22);
  color: var(--ink);
  outline: none;
  transition: background 0.15s, box-shadow 0.15s;
}
#player-name::placeholder { color: var(--ink); opacity: 0.55; }
#player-name:hover { background: rgba(255, 255, 255, 0.65); }
#player-name:focus { background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 3px 6px rgba(122, 74, 6, 0.22), 0 0 0 3px rgba(255, 145, 36, 0.45); }
.start-row { display: flex; align-items: center; margin-top: 18px; align-self: stretch; }
.start-row .spacer { flex: 1; }
.region-wrap { flex: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 0.8em; color: var(--ink-soft); }
#btn-region { width: 5ch; }
.tip-panel { text-align: center; font-size: 0.9em; color: var(--ink-soft); }

.account-panel h3 { display: table; }
.coins-row { margin-top: 12px; font-size: 1.05em; display: flex; align-items: center; gap: 0.4ch; }
.coins-row b { color: #8a6100; }
.acc-grid { display: flex; flex-wrap: wrap; gap: 4px 2ch; margin-top: 8px; }
#acc-level { margin-top: 14px; }
.save-tip { margin-top: 10px; font-size: 0.75em; opacity: 0.8; font-family: 'Open Sans', sans-serif; }

.friend-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.friend-panel h3 { margin-inline: auto; }
.friend-panel h3::after { margin-inline: auto; }
.bot-row { display: flex; align-items: center; gap: 8px; }
#friend-options { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.or { font-size: 0.8em; color: var(--ink-soft); }
#invite-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.invite-row { display: flex; gap: 6px; }
#invite-url {
  width: 190px; font-size: 0.8em; padding: 5px;
  border: 3px solid var(--border); border-radius: 11px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 2px 4px rgba(122, 74, 6, 0.2);
  color: var(--ink); text-align: center;
  font-family: 'Open Sans', sans-serif;
  outline: none;
}
#copied-note { font-size: 0.85em; opacity: 0; transition: opacity 0.3s; color: var(--green); }
#copied-note.show { opacity: 1; }
#invite-wait { font-size: 0.85em; font-style: italic; color: var(--ink-soft); }

/* ------------------------------------------------ highscores --------- */
.scores-panel { position: relative; display: flex; flex-direction: column; align-items: center; max-height: 88vh; }
.scores-panel h2 { margin-inline: auto; }
.scores-panel h2::after { margin-inline: auto; }
.scroll {
  overflow-y: auto;
  max-height: 55vh;
  margin: 14px 0;
  border: 3px solid #d8ab63;
  border-radius: 14px;
  background: rgba(255, 251, 240, 0.45);
  box-shadow: inset 0 3px 8px rgba(122, 74, 6, 0.18);
}
#scores-table { border-collapse: collapse; }
#scores-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px 6px;
  font-size: 0.8rem;
  font-weight: normal;
  color: #5b3a10;
  background: linear-gradient(var(--panel-a), #f3d693);
  box-shadow: 0 2px 0 rgba(165, 100, 10, 0.35);
}
#scores-table td { padding: 5px 12px 3px; text-align: center; border-top: 1px solid rgba(164, 154, 138, 0.55); font-family: 'Open Sans', sans-serif; font-size: 0.9em; }
#scores-table tr:nth-child(odd) td { background: rgba(246, 217, 162, 0.35); }
#scores-table td:nth-child(3) { font-family: inherit; font-size: 1em; }
#scores-table .name-col { width: 14ch; }
#scores-table canvas { width: 32px; height: 32px; vertical-align: middle; border-radius: 50%; border: 2px solid #cfa25c; background: #cfeefb; }
#scores-table td:first-child { font-weight: 700; color: var(--ink-soft); }
/* medal tints for the podium */
#scores-table tr.rank-1 td { background: rgba(255, 193, 7, 0.32); }
#scores-table tr.rank-2 td { background: rgba(158, 170, 185, 0.32); }
#scores-table tr.rank-3 td { background: rgba(205, 127, 50, 0.28); }
#scores-table tr.rank-1 td:first-child { color: #a67c00; }
#scores-table tr.rank-2 td:first-child { color: #5d6b7d; }
#scores-table tr.rank-3 td:first-child { color: #9c5a1d; }
#scores-table tr.me td { background: rgba(29, 143, 67, 0.22); }
#scores-table tr.me td:nth-child(3) { color: var(--green); }
.scores-you { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 1em; }

/* ------------------------------------------------ settings ----------- */
.settings-panel { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 20px 40px 24px; min-width: 380px; }
.settings-panel h2 { margin: 0 auto 6px; }
.settings-panel h2::after { margin-inline: auto; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.set-row input[type=range] { width: 170px; accent-color: var(--primary-b); cursor: pointer; }
.set-row.toggle .btn { min-width: 5ch; }
.set-tip { margin-top: 8px; text-align: center; font-size: 0.75em; opacity: 0.75; font-family: 'Open Sans', sans-serif; }

/* ------------------------------------------------ credits ------------ */
.credits-panel { position: relative; display: flex; flex-direction: column; align-items: center; padding: 20px 46px 30px; }
.credits-panel h2 { margin-inline: auto; }
.credits-panel h2::after { margin-inline: auto; }
.credits-item { margin-top: 18px; text-align: center; }
.credits-item span { font-size: 0.8em; opacity: 0.85; }

/* ------------------------------------------------ searching ---------- */
.search-panel { position: relative; text-align: center; padding: 20px 48px 22px; }
.search-panel::before {
  content: '';
  display: block;
  width: 42px; height: 42px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: conic-gradient(#3fae2a 0 60deg, #ff8a00 60deg 120deg, #ffd400 120deg 180deg, #e53026 180deg 240deg, #f4f4f4 240deg 300deg, #2456d6 300deg 360deg);
  border: 3px solid rgba(0, 0, 0, 0.25);
  animation: searchBounce 0.6s cubic-bezier(0.35, 0, 0.65, 1) infinite alternate,
             loadSpin 1.6s linear infinite;
}
@keyframes searchBounce { from { transform: translateY(-10px); } to { transform: translateY(6px); } }
#search-text { font-size: 1.5em; }
#search-region { margin-top: 6px; font-size: 0.85em; color: var(--ink-soft); }
#search-time { margin-top: 6px; font-size: 1.3em; font-family: 'Open Sans', sans-serif; font-weight: 700; color: #5b3a10; }
.search-hint { margin-top: 8px; font-size: 0.8em; font-style: italic; color: var(--ink-soft); }

/* ------------------------------------------------ found -------------- */
.found-panel { min-width: 36ch; padding: 20px 26px; display: flex; flex-direction: column; }
#found-title { font-size: 2.3rem; text-align: center; white-space: nowrap; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55); }
#found-server { text-align: center; margin: 2px 0 16px; font-size: 0.9em; color: var(--ink-soft); }
.vs-row { display: flex; align-items: center; gap: 12px; }
.vs-row.left { align-self: flex-start; }
.vs-row.right { align-self: flex-end; }
.vs-portrait {
  width: 96px; height: 96px; border-radius: 18px;
  border: 3px solid var(--green);
  background: linear-gradient(#cdeffe, #8ed9f6);
  box-shadow: 0 3px 0 rgba(20, 90, 40, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.5);
  display: flex; align-items: center; justify-content: center;
}
.vs-row.right .vs-portrait { border-color: var(--blue); box-shadow: 0 3px 0 rgba(16, 55, 120, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.5); }
.vs-portrait canvas { width: 84px; height: 84px; }
.vs-name { font-size: 1.4em; }
.vs-row.left .vs-name { color: var(--green); }
.vs-row.right .vs-name { color: var(--blue); }
.vs-meta { display: flex; flex-direction: column; }
.vs-meta > div:last-child { color: var(--ink-soft); }
.vs-mark {
  position: relative;
  align-self: center;
  font-size: 2.3em;
  margin: -6px 0;
  color: var(--coral);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.vs-mark::before {
  content: '';
  position: absolute;
  inset: -18px -26px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(255, 193, 7, 0.55), rgba(255, 193, 7, 0) 72%);
}

/* versus intro card (start freeze): two colored halves, sliding portraits */
.vs-card {
  position: relative;
  width: min(760px, 92vw);
  height: 300px;
  display: flex;
  pointer-events: none;
}
.vs-half {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 3px solid #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25), 0 18px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.vs-half::before {   /* speed stripes */
  content: '';
  position: absolute;
  inset: -40%;
  background: repeating-linear-gradient(-60deg, rgba(255, 255, 255, 0.12) 0 14px, rgba(255, 255, 255, 0) 14px 40px);
  animation: stripeRun 1.6s linear infinite;
}
@keyframes stripeRun { to { transform: translateX(46px); } }
.vs-half.left {
  border-radius: 26px 0 0 26px;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%);
  background: linear-gradient(135deg, #3fd06a, #1d8f43 60%, #13692f);
}
.vs-half.right {
  border-radius: 0 26px 26px 0;
  clip-path: polygon(12% 0, 100% 0, 100% 100%, 0 100%);
  margin-left: -9%;
  background: linear-gradient(225deg, #5aa2ff, #1f63d8 60%, #143f94);
}
.st-face {
  position: relative;
  width: 150px; height: 150px;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.25));
}
.vs-half.left .st-face { margin-right: 8%; }
.vs-half.right .st-face { margin-left: 8%; }
.st-name {
  position: relative;
  font-size: 1.7em;
  color: #fff;
  -webkit-text-stroke: 2px rgba(0, 40, 20, 0.6);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vs-half.left .st-name { margin-right: 8%; }
.vs-half.right .st-name { margin-left: 8%; -webkit-text-stroke-color: rgba(10, 30, 80, 0.6); }
.vs-center {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.vs-badge {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6em;
  color: #fff;
  -webkit-text-stroke: 3px #8a2a00;
  paint-order: stroke fill;
  background: radial-gradient(circle at 38% 32%, #ffe27a, #ff9124 60%, #e2552f);
  border: 4px solid #fff;
  box-shadow: 0 5px 0 #8a4508, 0 0 0 8px rgba(255, 200, 90, 0.35), 0 14px 26px rgba(0, 0, 0, 0.45);
}
.st-sub {
  padding: 3px 12px 2px;
  border-radius: 10px;
  font-size: 0.85em;
  color: #5b3a10;
  background: linear-gradient(var(--panel-a), var(--panel-c));
  border: 2px solid var(--border);
  box-shadow: 0 3px 0 var(--ledge);
  white-space: nowrap;
  text-transform: capitalize;
}
.st-sub:empty { display: none; }
.vs-card .starting-panel {
  position: absolute;
  left: 0; right: 0; bottom: -34px;
  margin: 0 auto;
  width: fit-content;
  padding: 6px 26px;
  z-index: 3;
  animation-delay: 0.45s;
}
.starting-panel h2 { padding: 2px 10px; white-space: nowrap; margin-inline: auto; }
.starting-panel h2::after { display: none; }
#starting-text.count {
  font-size: 2.2em;
  color: var(--coral);
  animation: countPop 0.9s cubic-bezier(0.3, 1.6, 0.6, 1);
}
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 30% { opacity: 1; } to { transform: none; } }
.vs-card.go .vs-half.left { animation: vsInL 0.5s cubic-bezier(0.2, 1.3, 0.5, 1) backwards; }
.vs-card.go .vs-half.right { animation: vsInR 0.5s cubic-bezier(0.2, 1.3, 0.5, 1) backwards; }
.vs-card.go .vs-badge { animation: vsSlam 0.5s cubic-bezier(0.3, 1.8, 0.5, 1) 0.35s backwards; }
.vs-card.go .st-face { animation: faceBob 1.2s ease-in-out 0.6s infinite alternate; }
@keyframes vsInL { from { transform: translateX(-70vw); } }
@keyframes vsInR { from { transform: translateX(70vw); } }
@keyframes vsSlam { from { transform: scale(3) rotate(-25deg); opacity: 0; } }
@keyframes faceBob { to { transform: translateY(-6px) rotate(2deg); } }
@media (max-height: 540px) {
  .vs-card { height: 210px; }
  .st-face { width: 100px; height: 100px; }
  .vs-badge { width: 70px; height: 70px; font-size: 2em; }
}

/* ------------------------------------------------ reconnect ---------- */
.reconnect-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 40px; }
.reconnect-panel h2 { margin-inline: auto; }
.reconnect-panel h2::after { margin-inline: auto; }
.recon-sub { font-size: 0.95em; color: var(--ink-soft); }
.recon-anim { transform: scale(0.75); margin: -4px 0; }

#net-note {
  position: absolute;
  top: 13vh;
  left: 0; right: 0;
  margin: 0 auto;
  width: fit-content;
  padding: 8px 24px 6px;
  background: linear-gradient(165deg, var(--panel-a), var(--panel-b));
  border: 3px solid #d32f2f;
  border-radius: 14px;
  font-size: 1.1em;
  color: #b3541e;
  box-shadow: 0 4px 0 #8e1f1f, 0 10px 18px rgba(30, 15, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  animation: panelPop 0.35s cubic-bezier(0.33, 1.35, 0.6, 1) backwards;
}

#hud-ping {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: 'Open Sans', sans-serif;
  font-weight: 700;
  font-size: 0.78em;
  padding: 3px 10px 2px;
  border-radius: 11px;
  background: rgba(20, 12, 4, 0.5);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
#hud-ping.ping-good { color: #7dff9b; }
#hud-ping.ping-ok { color: #ffd54f; }
#hud-ping.ping-bad { color: #ff6e40; }

/* ------------------------------------------------ HUD ---------------- */
/* A wooden beach scoreboard hanging on two ropes from the top edge:
   portraits + names on the wings, carved score slots in the middle,
   and a strip of point pips (the match's momentum) under the board. */
#hud { position: absolute; top: 0; left: 0; width: 100%; pointer-events: none; }
.scoreboard {
  position: relative;
  margin: 0 auto;
  width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 14px;
  animation: hudDrop 0.55s cubic-bezier(0.33, 1.3, 0.6, 1) backwards;
  transform-origin: 50% 0;
}
@keyframes hudDrop {
  from { transform: translateY(-120%) rotate(-3deg); }
  to { transform: none; }
}
.sb-rope {
  position: absolute;
  top: -4px;
  width: 6px;
  height: 26px;
  border-radius: 3px;
  background: repeating-linear-gradient(160deg, #e9dcc0 0 5px, #c9b28a 5px 8px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.sb-rope.left { left: 22%; }
.sb-rope.right { right: 22%; }
.hud-bar.sb-board {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px 8px;
  border-radius: 16px;
  border: 3px solid #5a3510;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0) 0 21px, rgba(60, 30, 5, 0.22) 21px 23px),
    repeating-linear-gradient(91deg, rgba(255, 235, 200, 0.06) 0 3px, rgba(90, 50, 10, 0.05) 3px 9px),
    linear-gradient(#d9a15e, #b87a37 55%, #9c6128);
  box-shadow:
    inset 0 2px 0 rgba(255, 230, 180, 0.55),
    inset 0 -3px 0 rgba(60, 30, 5, 0.3),
    0 5px 0 #4a2a0a,
    0 14px 24px rgba(20, 10, 0, 0.45);
  color: #fff6e2;
  font-size: 1.2rem;
}
/* brass nail heads in the corners */
.hud-bar.sb-board::before, .hud-bar.sb-board::after {
  content: '';
  position: absolute;
  top: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1c0, #c9962a 60%, #7a5610);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.hud-bar.sb-board::before { left: 8px; }
.hud-bar.sb-board::after { right: 8px; }
.sb-side { display: flex; align-items: center; gap: 10px; min-width: 15ch; }
.sb-side.left { justify-content: flex-end; }
.sb-meta { display: flex; flex-direction: column; }
.sb-meta.right-align { align-items: flex-end; }
.sb-face-wrap { position: relative; flex: 0 0 auto; }
.sb-face {
  display: block;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 3px solid var(--green);
  background: radial-gradient(circle at 40% 35%, #dff6ff, #8fd6f5);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.6);
}
.sb-side.right .sb-face { border-color: var(--blue); }
.sb-serve {
  position: absolute;
  bottom: -4px;
  right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: conic-gradient(#3fae2a 0 60deg, #ff8a00 60deg 120deg, #ffd400 120deg 180deg, #e53026 180deg 240deg, #f4f4f4 240deg 300deg, #2456d6 300deg 360deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  transform: scale(0);
  transition: transform 0.25s cubic-bezier(0.33, 1.6, 0.6, 1);
}
.sb-side.right .sb-serve { right: auto; left: -6px; }
.sb-serve.on { transform: scale(1); animation: serveSpin 2.4s linear infinite; }
@keyframes serveSpin { to { transform: scale(1) rotate(360deg); } }
.hud-name {
  font-size: 1.05em;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 rgba(60, 30, 5, 0.6);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hud-name-l { color: #b9ffc9; }
#hud-name-r { color: #cfe0ff; }
.hud-wins { color: var(--gold); text-shadow: 0 1px 0 rgba(60, 30, 0, 0.6); font-size: 0.7em; min-height: 1em; }
.hud-score {
  position: relative;
  text-align: center;
  min-width: 7.2ch;
}
.sb-digits { display: flex; align-items: center; justify-content: center; gap: 4px; }
.sb-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55em;
  height: 1.3em;
  padding: 0 6px;
  font-size: 1.95em;
  font-family: 'Lilita One', sans-serif;
  border-radius: 10px;
  background: linear-gradient(#2f2418, #3d2e1e);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 230, 180, 0.45);
  overflow: hidden;
}
.sb-slot.left .sb-num { color: #7dff9b; text-shadow: 0 0 10px rgba(80, 255, 130, 0.45); }
.sb-slot.right .sb-num { color: #8cc2ff; text-shadow: 0 0 10px rgba(90, 160, 255, 0.5); }
.sb-num { display: inline-block; line-height: 1; }
.hud-dash { margin: 0 0.1ch; color: #ffe9c2; font-size: 1.5em; text-shadow: 0 2px 0 rgba(60, 30, 5, 0.6); }
.hud-goal-note {
  margin-top: 3px;
  font-size: 0.55em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffe9c2;
  opacity: 0.9;
  text-shadow: 0 1px 0 rgba(60, 30, 5, 0.6);
}
.sb-momentum {
  display: flex;
  gap: 4px;
  margin-top: -2px;
  padding: 5px 9px 4px;
  border-radius: 0 0 11px 11px;
  background: linear-gradient(#6b4015, #53300d);
  box-shadow: 0 3px 6px rgba(20, 10, 0, 0.35), inset 0 2px 3px rgba(0, 0, 0, 0.35);
}
.sb-momentum:empty { display: none; }
.sb-momentum i {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 245, 220, 0.8);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  animation: pipIn 0.35s cubic-bezier(0.33, 1.6, 0.6, 1) backwards;
}
.sb-momentum i.l { background: #2fbf5a; }
.sb-momentum i.r { background: #3b82f6; }
@keyframes pipIn { from { transform: scale(0); } }

/* point / fault callouts: a chunky sticker with a burst behind it */
.callout {
  position: absolute;
  top: 26vh;
  left: 0; right: 0;
  margin: 0 auto;
  width: fit-content;
  text-align: center;
  font-size: 4.6em;
  font-family: 'Lilita One', sans-serif;
  color: #fff;
  -webkit-text-stroke: 3px #1a8a2e;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(10, 70, 25, 0.55), 0 10px 18px rgba(0, 0, 0, 0.3);
  animation: goalPop 1.2s ease-out;
  pointer-events: none;
}
.callout::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%; top: 52%;
  width: 3.4em; height: 3.4em;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255, 230, 120, 0.5) 0 9deg, rgba(255, 230, 120, 0) 9deg 24deg);
  -webkit-mask: radial-gradient(closest-side, #000 30%, transparent 72%);
  mask: radial-gradient(closest-side, #000 30%, transparent 72%);
  animation: raysSpin 6s linear infinite;
}
.callout-ace { -webkit-text-stroke-color: #b36b00; color: #fff3b0; text-shadow: 0 5px 0 rgba(120, 60, 0, 0.55), 0 10px 18px rgba(0, 0, 0, 0.3); font-size: 5.4em; }
.callout-kill { -webkit-text-stroke-color: #b3261e; color: #ffe0b0; text-shadow: 0 5px 0 rgba(110, 20, 10, 0.55), 0 10px 18px rgba(0, 0, 0, 0.3); }
.callout-kill::before { background: repeating-conic-gradient(rgba(255, 120, 60, 0.5) 0 9deg, rgba(255, 120, 60, 0) 9deg 24deg); }
.callout-fault { -webkit-text-stroke-color: #d32f2f; text-shadow: 0 5px 0 rgba(120, 10, 10, 0.5), 0 10px 18px rgba(0, 0, 0, 0.3); }
.callout-fault::before { display: none; }
@keyframes goalPop {
  0% { transform: scale(0.2) rotate(-6deg); opacity: 0; }
  22% { transform: scale(1.18) rotate(2deg); opacity: 1; }
  38% { transform: scale(1) rotate(0); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1) translateY(-10px); opacity: 0; }
}

/* single drama-banner slot (match point / on fire / comeback / so close) */
#banner {
  position: absolute;
  top: 17vh;
  left: 0; right: 0;
  text-align: center;
  font-family: 'Lilita One', sans-serif;
  color: #fff;
  pointer-events: none;
  animation: goalPop 1.7s ease-out forwards;
}
.banner-matchpoint { font-size: 4.2em; -webkit-text-stroke: 3px #b3002d; text-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.banner-fire { font-size: 3.2em; -webkit-text-stroke: 3px #e65100; text-shadow: 0 4px 12px rgba(0,0,0,0.35); }
.banner-comeback { font-size: 4em; -webkit-text-stroke: 3px #6a1b9a; text-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.banner-close { font-size: 2.4em; -webkit-text-stroke: 2px #01579b; text-shadow: 0 3px 10px rgba(0,0,0,0.35); }

#rally-note {
  position: absolute;
  top: 11vh;
  left: 0; right: 0;
  text-align: center;
  font-size: 1.5em;
  font-family: 'Lilita One', sans-serif;
  color: #fff;
  -webkit-text-stroke: 1.5px #1a6ea8;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  pointer-events: none;
}

#touch-pips { display: flex; justify-content: center; gap: 4px; margin: 3px 0 0; }
#touch-pips i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(30, 18, 5, 0.45);
  border: 1.5px solid rgba(255, 230, 190, 0.45);
}
#touch-pips i.lit { background: #ffd54f; border-color: #b8860b; }
#touch-pips i.warm { background: #ff9100; border-color: #a84a00; }
#touch-pips i.hot { background: #ff3d00; border-color: #8f1c00; animation: pipPulse 0.5s infinite alternate; }
@keyframes pipPulse { from { transform: scale(1); } to { transform: scale(1.35); } }

/* score flip on change: the new number drops into its slot */
#hud-score-l.pop, #hud-score-r.pop { animation: scoreFlip 0.5s cubic-bezier(0.3, 1.4, 0.6, 1); }
@keyframes scoreFlip {
  0% { transform: translateY(-70%) scaleY(0.4); opacity: 0; filter: brightness(2); }
  55% { transform: translateY(8%) scaleY(1.1); opacity: 1; }
  100% { transform: none; filter: none; }
}

/* ------------------------------------------------ chat --------------- */
#chat-ui { position: fixed; right: 0; bottom: 0; padding: 10px; pointer-events: auto; }
.chat-row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.chat-key {
  width: 34px; height: 34px;
  background: linear-gradient(#ffffff, #ddd7ca);
  border: 2px solid var(--key-border);
  border-radius: 0.45em;
  box-shadow: 0 3px 0 var(--key-border);
  color: #312f2c;
  display: flex; align-items: center; justify-content: center;
  padding-top: 2px;
  cursor: pointer;
  font-size: 0.9em;
}
.chat-tag { padding: 3px 10px; cursor: pointer; border-radius: 13px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 3px 0 var(--ledge), 0 6px 10px rgba(25, 12, 0, 0.3); transition: transform 0.08s, filter 0.12s; }
.chat-tag:hover { filter: brightness(1.07); transform: translateY(-1px); }
.chat-tag canvas { width: 30px; height: 30px; vertical-align: middle; }
#chat-list { display: flex; flex-direction: column-reverse; }
#chat-list .chat-row { animation: chatPop 0.22s cubic-bezier(0.33, 1.35, 0.6, 1) backwards; }
@keyframes chatPop {
  from { opacity: 0; transform: translateX(24px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
#chat-list .chat-row:nth-child(1) { animation-delay: 0s; }
#chat-list .chat-row:nth-child(2) { animation-delay: 0.025s; }
#chat-list .chat-row:nth-child(3) { animation-delay: 0.05s; }
#chat-list .chat-row:nth-child(4) { animation-delay: 0.075s; }
#chat-list .chat-row:nth-child(5) { animation-delay: 0.1s; }
#chat-list .chat-row:nth-child(6) { animation-delay: 0.125s; }
#chat-list .chat-row:nth-child(7) { animation-delay: 0.15s; }
#chat-list .chat-row:nth-child(8) { animation-delay: 0.175s; }
#chat-list .chat-row:nth-child(9) { animation-delay: 0.2s; }
#chat-list .chat-row:nth-child(10) { animation-delay: 0.225s; }

/* ------------------------------------------------ end screen --------- */
.end-cols { margin: auto; display: flex; gap: 14px; align-items: flex-start; }
.end-panel { display: flex; flex-direction: column; align-items: center; padding: 20px 28px; }
.end-right .continue-panel { animation-delay: 0.12s; }
.end-right #chest-panel { animation-delay: 0.22s; }

.end-headline { position: relative; z-index: 0; font-size: 2.7rem; letter-spacing: 0.03em; color: #2e8f3c; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6); }
#end-win::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%; top: 50%;
  width: 340px; height: 340px;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255, 193, 7, 0.28) 0 11deg, rgba(255, 193, 7, 0) 11deg 30deg);
  -webkit-mask: radial-gradient(closest-side, rgba(0, 0, 0, 0.8), transparent 72%);
  mask: radial-gradient(closest-side, rgba(0, 0, 0, 0.8), transparent 72%);
  animation: raysSpin 16s linear infinite;
  pointer-events: none;
}
@keyframes raysSpin {
  from { transform: translate(-50%, -50%) rotate(0); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
.end-headline.lose { color: #b3541e; }
.end-sub { font-size: 1.6rem; margin-top: 2px; }
.end-note { font-size: 1rem; margin-top: 4px; color: #7a4b12; }
.end-score-row { display: flex; align-items: center; gap: 14px; margin: 16px 0; font-size: 1.3rem; }
.end-side { display: flex; flex-direction: column; min-width: 10ch; }
.end-side.right-align { align-items: flex-end; }
#end-name-l { color: var(--green); }
#end-name-r { color: var(--blue); }
#end-wins-l, #end-wins-r { color: var(--gold); text-shadow: 0 1px 0 rgba(120, 80, 0, 0.4); font-size: 0.75em; min-height: 1em; }
.end-score {
  font-size: 1.7em; display: flex; gap: 10px;
  font-family: 'Open Sans', sans-serif; font-weight: 700;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.42);
  border-radius: 14px;
  box-shadow: inset 0 2px 5px rgba(122, 74, 6, 0.25);
}
.end-stats { margin: 2px 0 10px; font-size: 0.95em; color: #7a4b12; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.es-grid {
  display: grid;
  grid-template-columns: auto 8ch 8ch;
  gap: 2px 10px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 2px 5px rgba(122, 74, 6, 0.18);
}
.es-h { text-align: center; font-size: 0.85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-h.l { color: var(--green); }
.es-h.r { color: var(--blue); }
.es-label { color: var(--ink-soft); font-size: 0.9em; text-align: right; }
.es-v { text-align: center; font-family: 'Open Sans', sans-serif; font-weight: 700; color: var(--ink); }
.es-v.lead { color: #d4570e; }
.es-v.lead::after { content: ' \2605'; font-size: 0.7em; color: #e0a800; }
.es-line { font-size: 0.9em; }
.end-rating { margin-bottom: 8px; font-size: 1.05em; }
.end-rating .delta-up { color: var(--green); }
.end-rating .delta-down { color: #d32f2f; }
#end-xp { margin-top: 6px; }
#end-charbar { margin-top: 8px; }
.end-coins { display: flex; gap: 3ch; margin-top: 14px; font-size: 1em; }
.end-coins b { color: #8a6100; }
.share-row { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.share-note { font-size: 0.9em; color: var(--ink-soft); }

.end-right { display: flex; flex-direction: column; gap: 14px; }
.continue-panel { display: flex; flex-direction: column; align-items: center; padding: 18px 16px; }
#continue-title { font-size: 1.5rem; }
#continue-title .q { color: #d84315; font-size: 1.3em; }
#rematch-note, #left-note { margin-top: 6px; font-size: 0.9em; color: var(--ink-soft); }
.continue-btns { display: flex; gap: 10px; margin-top: 14px; }

#chest-panel { display: flex; flex-direction: column; align-items: center; padding: 14px; }
.chest-title { font-size: 1.4em; color: #a67c00; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
#chest-canvas { cursor: pointer; margin: 6px 0; transition: transform 0.15s; }
#chest-canvas:hover { transform: translateY(-3px) scale(1.04); }
#chest-canvas.shake { animation: chestShake 0.35s; }
@keyframes chestShake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg) scale(1.05); }
  75% { transform: rotate(8deg) scale(1.05); }
}
#chest-hint { font-size: 0.85em; font-style: italic; color: var(--ink-soft); }
#chest-reward { font-size: 1.2em; }
#chest-reward b { color: #8a6100; }

/* ------------------------------------------------ profile ------------ */
.profile-cols {
  display: flex;
  gap: 18px;
  align-items: stretch;
  max-width: 96vw;
}
.profile-id-panel { width: 300px; position: relative; text-align: center; }
.profile-id-panel h2 { margin: 0 auto 6px; }
.profile-id-panel h3 { margin: 12px auto 6px; }
.prof-portrait-wrap { display: flex; justify-content: center; }
#prof-portrait { width: 120px; height: 120px; }
.prof-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  text-align: left;
  font-size: 0.95em;
  margin-top: 8px;
}
.prof-grid div { display: flex; justify-content: space-between; color: var(--ink-soft); }
.prof-grid b { color: var(--ink); }
.prof-grid b.green { color: var(--green); }
.prof-bests {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px dashed rgba(165, 100, 10, 0.35);
  font-size: 0.9em;
  color: var(--ink-soft);
  text-align: left;
}
.prof-bests b { color: var(--coral); }
.trophy-row { display: flex; justify-content: center; gap: 12px; }
.trophy {
  width: 64px;
  padding: 6px 4px 4px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: linear-gradient(#fff6dd, #f4d9a0);
  font-size: 1.5em;
  line-height: 1.1;
  position: relative;
}
.trophy .trophy-n {
  display: block;
  font-size: 0.55em;
  color: var(--ink-soft);
}
.trophy.locked { filter: grayscale(1) opacity(0.45); }

.profile-mid-panel { width: 440px; display: flex; flex-direction: column; }
#prof-spark {
  width: 100%;
  height: 110px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(165, 100, 10, 0.35);
  border-radius: 10px;
}
.history-list { flex: 1; min-height: 120px; max-height: 40vh; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.35);
  font-size: 0.92em;
}
.hist-row.win { box-shadow: inset 3px 0 0 var(--green); }
.hist-row.loss { box-shadow: inset 3px 0 0 var(--coral); }
.hist-row canvas { width: 34px; height: 34px; flex: 0 0 auto; }
.hist-opp { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-score { font-family: 'Open Sans', sans-serif; font-weight: 700; }
.hist-delta.up { color: var(--green); }
.hist-delta.down { color: var(--coral); }
.hist-tag { font-size: 0.8em; color: var(--ink-soft); font-style: italic; }
.hist-time { font-size: 0.78em; color: var(--ink-soft); width: 52px; text-align: right; }
.hist-empty { color: var(--ink-soft); font-style: italic; padding: 14px; text-align: center; }

.profile-ach-panel { width: 360px; display: flex; flex-direction: column; }
.ach-count { font-size: 0.7em; color: var(--ink-soft); }
.ach-grid { flex: 1; max-height: 62vh; }
.ach-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  margin-bottom: 5px;
  background: rgba(255, 255, 255, 0.35);
}
.ach-item.locked { filter: saturate(0.25) opacity(0.72); }
.ach-badge {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45em;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: radial-gradient(circle at 35% 30%, #fff3cf, #ffc95e 70%, #ff9124);
}
.ach-item.locked .ach-badge { background: radial-gradient(circle at 35% 30%, #eee6d6, #cbbFA4); }
.ach-info { flex: 1; min-width: 0; }
.ach-name { font-size: 0.95em; }
.ach-desc { font-size: 0.78em; color: var(--ink-soft); }
.ach-bar { height: 8px; border-radius: 4px; background: var(--bar-track); margin-top: 3px; overflow: hidden; }
.ach-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-a), var(--primary-b)); }
.ach-coins { font-size: 0.8em; color: #8a6100; white-space: nowrap; }

/* achievement unlock toasts on the end screen */
.end-ach { margin-top: 8px; }
.ach-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 4px 10px;
  margin-top: 4px;
  border-radius: 12px;
  border: 2px solid var(--primary-border);
  background: linear-gradient(#fff3cf, #ffc95e);
  animation: achPop 0.5s cubic-bezier(0.33, 1.5, 0.6, 1) backwards;
}
.ach-toast .t-icon { font-size: 1.2em; }
.ach-toast .t-name b { color: #8a4508; }
.ach-toast .t-coins { color: #8a6100; font-size: 0.85em; }
@keyframes achPop {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------ cup ---------------- */
.cup-entry-panel h3 { margin-bottom: 8px; }
.cup-note { font-size: 0.82em; color: var(--ink-soft); font-style: italic; margin-top: 8px; }
.cup-panel { position: relative; min-width: 760px; }
.cup-bracket {
  display: flex;
  gap: 26px;
  justify-content: center;
  align-items: stretch;
  margin: 14px 0 10px;
}
.cup-round { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.cup-col-title { text-align: center; font-size: 0.85em; color: var(--ink-soft); }
.cup-pair {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  border-radius: 12px;
  background: rgba(165, 100, 10, 0.10);
}
.cup-slot {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 150px;
  padding: 3px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid transparent;
  font-size: 0.9em;
}
.cup-slot canvas { width: 30px; height: 30px; flex: 0 0 auto; }
.cup-slot.you { border-color: var(--green); background: #eaf7ee; }
.cup-slot.out { opacity: 0.45; text-decoration: line-through; }
.cup-slot.tbd { color: var(--ink-soft); font-style: italic; }
.cup-slot.champ { border-color: var(--gold); background: #fff6d6; }
.cup-trophy-big { font-size: 2.1em; text-align: center; }
.cup-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 6px;
}
#cup-status { font-size: 1.05em; }
#cup-status .cup-win { color: var(--green); }
#cup-status .cup-loss { color: var(--coral); }

/* ------------------------------------------------ party rule --------- */
.mod-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.mod-label { font-size: 0.85em; color: var(--ink-soft); }

/* ------------------------------------------------ touch controls ----- */
#touch-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
.touch-left, .touch-right {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  pointer-events: none;
}
.touch-left { left: max(16px, env(safe-area-inset-left)); }
.touch-right { right: max(16px, env(safe-area-inset-right)); }
.tbtn {
  pointer-events: auto;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7em;
  color: var(--btn-ink);
  background: radial-gradient(circle at 38% 32%, rgba(253, 241, 211, 0.9), rgba(240, 200, 130, 0.82));
  border: 3px solid rgba(107, 58, 16, 0.75);
  box-shadow: 0 4px 0 rgba(107, 58, 16, 0.55);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.tbtn.active {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 1px 0 rgba(107, 58, 16, 0.55);
  background: radial-gradient(circle at 38% 32%, #ffe9b8, #ffb84d);
}
.tbtn-jump { width: 100px; height: 100px; font-size: 2em; }

/* the back arrow floats over the cup panel's corner — clear the title */
.cup-panel > h2 { margin-left: 46px; }

/* short screens (phones in landscape): shrink chrome, drop the totems */
@media (max-height: 540px) {
  .totem { display: none !important; }
  #ui { font-size: 13px; }
  .hud-bar.sb-board { padding: 4px 10px; gap: 8px; }
  .sb-face { width: 34px; height: 34px; }
  .sb-slot { font-size: 1.6em; }
  .scoreboard { padding-top: 6px; }
  .sb-rope { height: 12px; }
  .screen { padding-bottom: 2vh; }
}

/* touch pads occupy the bottom corners — lift the chat button clear */
@media (pointer: coarse) {
  #chat-ui { bottom: 120px; }
}

/* portrait phones: the court is landscape — ask for a rotate */
#rotate-note {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 4, 0.78);
}
#rotate-note .panel { font-size: 1.2em; padding: 22px 30px; }
@media (pointer: coarse) and (orientation: portrait) {
  #rotate-note { display: flex; }
}

/* ------------------------------------------------ quality floor ------ */
a:focus-visible, input:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .screen .panel, .hud-bar, #chat-list .chat-row,
  .game-title .logo-img, .bar .bar-fill::after,
  #end-win::before, .search-panel::before,
  .load-ball, .load-shadow, #net-note,
  #touch-pips i.hot, #hud-score-l.pop, #hud-score-r.pop,
  .ach-toast, .scoreboard, .callout::before, .sb-serve.on, .sb-momentum i,
  .howto-new .new-tag, .np, .vs-half::before, .vs-card.go .vs-half, .vs-card.go .vs-badge,
  .vs-card.go .st-face, #starting-text.count {
    animation: none;
  }
}
