/* Tennis Korner: HUD, screens and pop-ups over the 3D canvas. --ui scales the type with the box. */
.tn {
  --ui: 1;
  --ink: #1d1747;
  --glass: rgba(16, 14, 48, 0.42);
  --edge: rgba(255, 255, 255, 0.38);
  --ball: #dfff4a;
  position: absolute;
  inset: 0;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(180deg, #3f86e8, #e6f4ff);
  opacity: 0;
  transition: opacity 0.5s ease;
  touch-action: none;
}
.tn.ready { opacity: 1; }
.tn-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tn button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tn svg { width: 1.15em; height: 1.15em; flex: none; }

/* ------------------------------------------------ HUD */
.tn-hud { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.35s ease; }
.tn-hud.off { opacity: 0; }
.tn-hud.off * { pointer-events: none !important; }

.tn-board {
  position: absolute;
  left: calc(10px * var(--ui));
  top: calc(10px * var(--ui));
  border-radius: calc(12px * var(--ui));
  overflow: hidden;
  background: rgba(12, 12, 40, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: calc(15px * var(--ui));
  font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.tn-row { display: flex; align-items: center; height: calc(30px * var(--ui)); }
.tn-row + .tn-row { border-top: 1px solid rgba(255, 255, 255, 0.12); }
.tn-serve { width: calc(18px * var(--ui)); display: grid; place-items: center; }
.tn-serve i { width: calc(8px * var(--ui)); height: calc(8px * var(--ui)); border-radius: 50%; background: var(--ball); box-shadow: 0 0 6px var(--ball); opacity: 0; transition: opacity 0.3s; }
.tn-row.serving .tn-serve i { opacity: 1; }
.tn-name { min-width: calc(64px * var(--ui)); padding-right: calc(8px * var(--ui)); font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.tn-sets { display: flex; }
.tn-sets b, .tn-games, .tn-pts { width: calc(26px * var(--ui)); text-align: center; font-weight: 700; }
.tn-sets b { color: rgba(255, 255, 255, 0.6); }
.tn-sets b.won { color: #fff; }
.tn-games { background: rgba(255, 255, 255, 0.1); height: 100%; display: grid; place-items: center; }
.tn-pts { width: calc(36px * var(--ui)); height: 100%; display: grid; place-items: center; background: #ffd23f; color: var(--ink); font-weight: 900; }
.tn-tb .tn-pts { background: #5ad1ff; }

.tn-tools { position: absolute; right: calc(10px * var(--ui)); top: calc(10px * var(--ui)); display: flex; gap: 8px; }
.tn-icon {
  pointer-events: auto;
  width: calc(44px * var(--ui));
  height: calc(44px * var(--ui));
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--glass) !important;
  border: 2px solid var(--edge) !important;
  font-size: calc(19px * var(--ui)) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
.tn-icon:active { transform: scale(0.94); }

.tn-speed {
  position: absolute; left: 50%; top: calc(12px * var(--ui)); transform: translateX(-50%);
  padding: calc(5px * var(--ui)) calc(12px * var(--ui)); border-radius: 99px;
  background: rgba(12, 12, 40, 0.7); font-weight: 800; font-size: calc(14px * var(--ui));
  opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
.tn-speed.on { opacity: 1; }
.tn-speed small { font-weight: 600; opacity: 0.7; margin-left: 4px; }

/* ------------------------------------------------ pop-ups */
.tn-pops { position: absolute; inset: 0; pointer-events: none; }
.tn-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka One', 'Inter', sans-serif;
  font-size: calc(26px * var(--ui));
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 3px 0 rgba(30, 20, 80, 0.75), 0 5px 14px rgba(20, 10, 60, 0.5);
  animation: tn-pop 1.1s cubic-bezier(.2, .9, .3, 1.2) both;
}
.tn-pop.perfect { color: #7dff9f; font-size: calc(32px * var(--ui)); text-shadow: 0 3px 0 #0d7a3b, 0 0 18px rgba(90, 255, 140, 0.6); }
.tn-pop.good { color: #fff3a0; }
.tn-pop.bad { color: #ffb0b8; font-size: calc(22px * var(--ui)); }
.tn-pop.call { font-size: calc(22px * var(--ui)); color: #fff; }
@keyframes tn-pop {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(0.95); }
}

.tn-banner {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; width: 92%;
}
.tn-banner b {
  display: block; font-family: 'Fredoka One', sans-serif; font-weight: 400;
  font-size: calc(44px * var(--ui)); line-height: 1.05;
  text-shadow: 0 4px 0 rgba(30, 20, 90, 0.8), 0 8px 24px rgba(20, 10, 60, 0.5);
}
.tn-banner span {
  display: inline-block; margin-top: 8px; padding: 5px 14px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); font-weight: 800;
  font-size: calc(14px * var(--ui)); letter-spacing: 0.05em; text-transform: uppercase;
}
.tn-banner.go { animation: tn-banner 1.9s ease both; }
.tn-banner.big b { font-size: calc(58px * var(--ui)); color: #fff6b0; }
@keyframes tn-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

.tn-hint {
  position: absolute; left: 50%; top: calc(62px * var(--ui) + 8px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: 92%;
  padding: calc(9px * var(--ui)) calc(16px * var(--ui)); border-radius: 99px;
  background: rgba(12, 12, 40, 0.72); border: 1.5px solid rgba(255, 255, 255, 0.25);
  font-weight: 700; font-size: calc(15px * var(--ui)); pointer-events: none;
  transition: opacity 0.35s ease; text-align: center;
}
.tn-hint[hidden] { display: flex !important; opacity: 0; }
.tn-hint .tn-finger { width: 1.6em; height: 1.6em; flex: none; animation: tn-swipe 1.3s ease-in-out infinite; }
.tn-hint .tn-finger.down { animation-name: tn-swipe-down; }
.tn-hint .tn-finger.tap { animation-name: tn-tap; }
@keyframes tn-swipe { 0%, 15% { transform: translateY(6px); opacity: 0.4; } 50% { transform: translateY(-8px); opacity: 1; } 100% { transform: translateY(-8px); opacity: 0; } }
@keyframes tn-swipe-down { 0%, 15% { transform: translateY(-6px); opacity: 0.4; } 50% { transform: translateY(8px); opacity: 1; } 100% { transform: translateY(8px); opacity: 0; } }
@keyframes tn-tap { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.8); } }

/* ------------------------------------------------ screens */
.tn-screen {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 12px;
  place-items: safe center;   /* a card taller than the box starts at the top, never off it */
  background: radial-gradient(ellipse at 50% 40%, rgba(20, 16, 60, 0.15), rgba(10, 8, 30, 0.55));
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  animation: tn-fade 0.3s ease both;
}
.tn-screen[hidden] { display: none; }
@keyframes tn-fade { from { opacity: 0; } to { opacity: 1; } }
.tn-card {
  width: min(520px, 100%);
  border-radius: calc(24px * var(--ui));
  padding: calc(22px * var(--ui)) calc(22px * var(--ui));
  background: linear-gradient(160deg, rgba(40, 30, 110, 0.86), rgba(18, 16, 58, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 20px 60px rgba(10, 5, 40, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-align: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.tn-card h2 { font-family: 'Fredoka One', sans-serif; font-weight: 400; font-size: calc(32px * var(--ui)); margin-bottom: 12px; }
.tn-logo { font-family: 'Fredoka One', sans-serif; font-weight: 400; font-size: calc(44px * var(--ui)); line-height: 1; letter-spacing: 0.01em; }
.tn-logo .a { color: #ffd23f; text-shadow: 0 4px 0 #c2410c, 0 8px 20px rgba(0, 0, 0, 0.35); }
.tn-logo .b { color: #fff; text-shadow: 0 4px 0 #6b46e8, 0 8px 20px rgba(0, 0, 0, 0.35); }
.tn-logo i {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 3px 9px; border-radius: 10px;
  font-style: normal; font-family: 'Inter', sans-serif; font-weight: 900; font-size: calc(16px * var(--ui));
  background: var(--ball); color: var(--ink); transform: rotate(-6deg);
}
.tn-tag { margin: 10px 0 16px; opacity: 0.85; font-weight: 600; font-size: calc(15px * var(--ui)); }
.tn-modes { display: grid; gap: 10px; }
.tn-two { grid-template-columns: 1fr 1fr; }
.tn-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  min-height: calc(54px * var(--ui)); padding: 10px 16px; border-radius: calc(16px * var(--ui));
  background: rgba(255, 255, 255, 0.14) !important; border: 2px solid rgba(255, 255, 255, 0.28) !important;
  font-weight: 800 !important; font-size: calc(17px * var(--ui)) !important;
  transition: transform 0.12s ease, background 0.2s;
}
.tn-btn:hover { background: rgba(255, 255, 255, 0.22) !important; }
.tn-btn:active { transform: scale(0.97); }
.tn-btn small { display: block; width: 100%; font-weight: 600; font-size: 0.72em; opacity: 0.8; margin-top: -4px; }
.tn-btn-main { background: linear-gradient(180deg, #ffd23f, #ff9f1c) !important; color: var(--ink) !important; border-color: rgba(255, 255, 255, 0.6) !important; box-shadow: 0 6px 0 #b45309, 0 10px 24px rgba(0, 0, 0, 0.25); }
.tn-btn-main:hover { background: linear-gradient(180deg, #ffe066, #ffb13d) !important; }
.tn-btn-main:active { transform: translateY(3px); box-shadow: 0 3px 0 #b45309; }
.tn-btn-alt { background: linear-gradient(180deg, #22d3ee, #3b82f6) !important; border-color: rgba(255, 255, 255, 0.5) !important; box-shadow: 0 6px 0 #1e40af; }
.tn-row-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.tn-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.12) !important; border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
  font-weight: 700 !important; font-size: calc(14px * var(--ui)) !important;
}
.tn-chip.off { opacity: 0.5; }
.tn-chip.off span::after { content: ' off'; }
.tn-chip.sel { background: #fff !important; color: var(--ink) !important; }

/* outfit swatches */
.tn-swatches { display: flex; justify-content: center; gap: 8px; margin-top: 12px; align-items: center; }
.tn-swatches .tn-label { font-weight: 700; font-size: calc(13px * var(--ui)); opacity: 0.75; margin-right: 4px; }
.tn-sw { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.35) !important; }
.tn-sw.sel { border-color: #fff !important; transform: scale(1.12); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3); }

/* the ladder */
.tn-ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px; }
.tn-opp {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 8px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.1) !important; border: 2px solid rgba(255, 255, 255, 0.2) !important;
}
.tn-opp.sel { border-color: #ffd23f !important; background: rgba(255, 210, 63, 0.18) !important; }
.tn-opp.locked { opacity: 0.45; }
.tn-opp .face { width: calc(42px * var(--ui)); height: calc(42px * var(--ui)); border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.7); display: grid; place-items: center; font-family: 'Fredoka One', sans-serif; font-size: calc(20px * var(--ui)); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.tn-opp b { font-weight: 800; font-size: calc(14px * var(--ui)); }
.tn-opp small { font-size: calc(11px * var(--ui)); opacity: 0.75; }
.tn-opp .stars { font-size: calc(10px * var(--ui)); color: #ffd23f; letter-spacing: 1px; }
.tn-opp .done { position: absolute; top: 4px; right: 6px; color: #7dff9f; font-weight: 900; }
.tn-blurb { min-height: 3.2em; margin: 8px 2px 12px; font-size: calc(14px * var(--ui)); opacity: 0.88; }
.tn-blurb b { color: #ffd23f; }
.tn-lengths { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

/* match over */
.tn-final { font-family: 'Fredoka One', sans-serif; font-size: calc(36px * var(--ui)); margin: 2px 0 10px; letter-spacing: 0.04em; }
.tn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tn-grid div { padding: 8px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); }
.tn-grid .tn-label { display: block; font-size: calc(10.5px * var(--ui)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.tn-grid b { font-size: calc(20px * var(--ui)); font-weight: 800; }
.tn-ribbon { display: inline-block; margin-bottom: 8px; padding: 4px 14px; border-radius: 99px; background: #7dff9f; color: #0b3d22; font-weight: 900; font-size: calc(13px * var(--ui)); letter-spacing: 0.08em; text-transform: uppercase; }
.tn-ribbon[hidden] { display: none; }

/* help */
.tn-help { text-align: left; display: grid; gap: 10px; margin: 6px 0 14px; }
.tn-help div { display: flex; gap: 12px; align-items: flex-start; font-size: calc(14.5px * var(--ui)); line-height: 1.35; }
.tn-help i { flex: none; width: calc(34px * var(--ui)); height: calc(34px * var(--ui)); border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.12); font-style: normal; font-size: calc(17px * var(--ui)); }
.tn-help b { color: #ffd23f; }
.tn-keys { font-size: calc(12.5px * var(--ui)); opacity: 0.75; margin-bottom: 12px; }

/* phone held sideways: the game takes the whole screen */
html.tn-immersive, html.tn-immersive body { overflow: hidden !important; }
html.tn-immersive .game-container-wrapper {
  position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important;
  max-width: none !important; max-height: none !important; min-height: 0 !important; aspect-ratio: auto !important;
  border-radius: 0 !important; margin: 0 !important; z-index: 10000 !important;
}
html.tn-immersive .site-header { display: none !important; }

/* ------------------------------------------------ the thumb stick (manual movement) */
.tn-stick {
  --r: 56px;
  position: absolute; width: calc(var(--r) * 2); height: calc(var(--r) * 2); transform: translate(-50%, -50%);
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.18));
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.tn-stick[hidden], .tn-stick-ghost[hidden] { display: none; }
.tn-knob {
  position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; margin: -23% 0 0 -23%;
  border-radius: 50%; background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.tn-stick-ghost {
  position: absolute; left: calc(14% + 20px); bottom: calc(10% + 20px);
  width: calc(96px * var(--ui)); height: calc(96px * var(--ui)); transform: translate(-50%, 50%);
  border-radius: 50%; pointer-events: none; opacity: 0.55;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  animation: tn-ghost 1.6s ease-in-out infinite;
}
.tn-stick-ghost .tn-knob { width: 40%; height: 40%; margin: -20% 0 0 -20%; background: rgba(255, 255, 255, 0.6); animation: tn-ghost-knob 1.6s ease-in-out infinite; }
.tn-stick-ghost span {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px);
  font-weight: 800; font-size: calc(12px * var(--ui)); letter-spacing: 0.1em; text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
@keyframes tn-ghost { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
@keyframes tn-ghost-knob { 0%, 100% { transform: translateX(-30%); } 50% { transform: translateX(30%); } }

/* ------------------------------------------------ How to play: fits the box (review item 3) */
/* The card never grows past the box: its list scrolls, and "Got it" stays in view at the bottom. */
.tn-help-card { display: flex; flex-direction: column; max-height: 100%; }
.tn-help-card .tn-help { overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; padding-right: 4px; }
.tn-help-card h2, .tn-help-card .tn-keys, .tn-help-card .tn-modes { flex: none; }
/* a wide box (a desktop): two columns */
.tn-wide .tn-help-card { width: min(860px, 100%); }
.tn-wide .tn-help { grid-template-columns: 1fr 1fr; column-gap: 18px; }
/* a short box: a tighter card */
.tn-short .tn-card { padding: calc(14px * var(--ui)) calc(18px * var(--ui)); }
.tn-short .tn-card h2 { font-size: calc(26px * var(--ui)); margin-bottom: 8px; }
.tn-short .tn-help { gap: 7px; margin: 2px 0 8px; }
.tn-short .tn-help div { font-size: calc(13.5px * var(--ui)); line-height: 1.3; }
.tn-short .tn-help i { width: calc(28px * var(--ui)); height: calc(28px * var(--ui)); font-size: calc(15px * var(--ui)); }
.tn-short .tn-keys { margin-bottom: 8px; }
.tn-short .tn-btn { min-height: calc(46px * var(--ui)); }

/* ------------------------------------------------ personal bests and the tip after a loss */
.tn-bests { margin-top: 12px; font-size: calc(13px * var(--ui)); opacity: 0.88; }
.tn-bests b { color: #ffd23f; }
.tn-bests span { white-space: nowrap; }
.tn-best-row {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px;
  margin: -4px 0 12px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.06);
  font-size: calc(13px * var(--ui));
}
.tn-best-row .tn-label { font-size: calc(10.5px * var(--ui)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.tn-best-row b { font-weight: 800; }
.tn-best-row span.new { color: #7dff9f; }
.tn-best-row i { font-style: normal; font-weight: 900; font-size: 0.78em; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 99px; background: #7dff9f; color: #0b3d22; }
.tn-tip { margin: -4px 0 12px; font-size: calc(13.5px * var(--ui)); line-height: 1.35; opacity: 0.92; }
.tn-tip b { color: #ffd23f; }

/* ------------------------------------------------ full screen (desktop and Android) */
.game-container-wrapper:fullscreen { width: 100vw !important; height: 100vh !important; max-width: none !important; max-height: none !important; border-radius: 0 !important; aspect-ratio: auto !important; }
.game-container-wrapper:-webkit-full-screen { width: 100vw !important; height: 100vh !important; max-width: none !important; max-height: none !important; border-radius: 0 !important; }
/* the hidden attribute always hides (buttons and chips set their own display, which would win over it);
   the hint is the one exception: it fades out instead (.tn-hint[hidden] above) */
#tn [hidden]:not(.tn-hint) { display: none !important; }
