:root {
  --bg-1: #f4ecd9;
  --bg-2: #d6c2a6;
  --panel: rgba(255, 249, 239, 0.82);
  --ink: #1b1a18;
  --line: rgba(27, 26, 24, 0.12);
  --shadow: 0 24px 70px rgba(52, 35, 20, 0.18);
  --accent: #c7502e;
  --accent-2: #275d52;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  /* overflow-x: hidden; */
  color: var(--ink);
  font-family: "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  background-color: #EDE1CC;
  /* background:
    radial-gradient(circle at top left, rgba(199, 80, 46, 0.16), transparent 26%),
    radial-gradient(circle at bottom right, rgba(39, 93, 82, 0.17), transparent 24%),
    linear-gradient(145deg, var(--bg-1) 0%, #eadcc5 42%, var(--bg-2) 100%); */
}

/* Every page except the game (and Court View, which ships its own CSS) must
   scroll normally — guard height/overflow explicitly so no inherited or cached
   game rule (--app-height locks, overflow:hidden) can trap the viewport.
   IMPORTANT: use overflow:visible (NORMAL document scroll), NOT overflow:auto.
   An overflow:auto body becomes a scroll container, and iOS WebKit then clips /
   insets position:fixed children — that was leaving the bottom cookie bar with
   side gaps on iPhone. Document-level scroll keeps fixed elements viewport-bound. */
body[data-page="menu"] {
  /* !important so a menu page ALWAYS scrolls even if a stale inline lock (overflow:hidden / fixed
     height) is left from the game or restored by bfcache — no menu page locks body scroll itself,
     so this is safe. Still overflow:visible (document scroll), never overflow:auto (iOS clips fixed). */
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}
/* html safety net for menu pages (covers a stuck html-level lock the JS unlock might miss on a race). */
html:has(> body[data-page="menu"]) {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

body[data-page="game"] {
  overflow: hidden;
  /* The court page never scrolls (modals scroll internally) — only game & court-view. */
  overscroll-behavior: none;
  height: var(--app-height, 100vh);
  min-height: var(--app-height, 100vh);
}

.crop-text-1 {
  -webkit-line-clamp: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.crop-text-2 {
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.crop-text-3 {
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.crop-text-4 {
  -webkit-line-clamp: 4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.crop-text-5 {
  -webkit-line-clamp: 5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.crop-text-6 {
  -webkit-line-clamp: 6;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.srt-ad {
  border: 1px dotted #ffffff;
  color: #ffffff;
  font-size: 0.8rem;
  display: none !important;
}

/* Search-term highlight on list pages (/drill, /routine, My Drills) — orange bold. (user, 2026-07-12) */
.sq-hl {
  color: #ff7a00;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.76rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}

h1,
h2,
p {
  margin: 0;
}

.menu-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 26px 0 30px;
}

.menu-shell .container,
.menu-shell .list-group,
.menu-shell .list-group-item,
.menu-shell .row,
.menu-shell [class*="col-"] {
  min-width: 0;
}

.menu-lang-switch {
  display: inline-flex;
  gap: 8px;
  justify-self: end;
}

.lang-btn {
  border: 1px solid rgba(27, 26, 24, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 7px 14px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.is-active {
  background: #1f1a13;
  color: #fff8ea;
  border-color: #1f1a13;
}

.visualizer-link.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 999px;
  background: #d93025;
  color: #ffffff !important;
  box-shadow: 0 10px 24px rgba(217, 48, 37, 0.28);
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.visualizer-link.btn:hover,
.visualizer-link.btn:focus-visible {
  background: #b92920;
  color: #ffffff !important;
  transform: translateY(-1px);
}

.menu-hero,
.mode-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.menu-hero {
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 22px;
  align-items: center;
}

.menu-hero-copy {
  min-width: 0;
}

.menu-hero h1 {
  font-size: clamp(2.2rem, 4.5vw, 4.2rem);
  line-height: 0.95;
}

.menu-intro {
  margin-top: 14px;
  max-width: 767px;
  font-size: 1rem;
  line-height: 1.65;
}

.menu-logo-panel {
  border-radius: 20px;
  border: 1px solid rgba(27, 26, 24, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
}

.menu-logo {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  object-fit: contain;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.training-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guide-card {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 249, 239, 0.82);
  border: 1px solid rgba(27, 26, 24, 0.12);
}

.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.guide-head h2 {
  font-size: 1.2rem;
}

.guide-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(39, 93, 82, 0.14);
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

.guide-actions {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.guide-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(27, 26, 24, 0.18);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.guide-help:hover {
  background: #ffffff;
}

.guide-go:hover {
  background: rgba(39, 93, 82, 0.22);
}

.guide-card p {
  margin-top: 10px;
  line-height: 1.55;
  color: rgba(27, 26, 24, 0.85);
  min-height: 72px;
}

.mindset-panel {
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(27, 26, 24, 0.12);
}

.mindset-panel h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.mindset-panel p+p {
  margin-top: 10px;
}

.mode-help-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.mode-help-modal.is-visible {
  display: block;
}

.mode-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.mode-help-panel {
  position: relative;
  width: min(880px, calc(100% - 24px));
  max-height: min(88vh, 980px);
  overflow: auto;
  margin: 4vh auto 0;
  padding: 18px 20px;
  border-radius: 16px;
  background: #fff8ea;
  border: 1px solid rgba(27, 26, 24, 0.15);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

.mode-help-panel h2 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.mode-help-body p {
  margin-top: 10px;
  line-height: 1.55;
}

#mode-help-close {
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  background: #1f1a13;
  color: #fff8ea;
  padding: 9px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.online-room-list {
  margin-top: 6px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(27, 26, 24, 0.12);
}

.online-room-list h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.online-room-list-desc {
  margin: 0 0 10px;
  font-size: 0.86rem;
  opacity: 0.8;
}

#online-room-list {
  margin: 0;
  padding-left: 18px;
}

#online-room-list li {
  margin: 4px 0;
}

#online-room-list a {
  color: #1b1a18;
  text-decoration: underline;
}

.mode-card {
  display: block;
  padding: 22px;
  color: inherit;
  text-decoration: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.mode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 75px rgba(52, 35, 20, 0.24);
  border-color: rgba(199, 80, 46, 0.22);
}

.mode-chip {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(39, 93, 82, 0.12);
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-card h2 {
  margin-top: 13px;
  font-size: 1.6rem;
}

.mode-card p {
  margin-top: 10px;
  line-height: 1.62;
  color: rgba(27, 26, 24, 0.8);
}

.layout {
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 380px minmax(320px, 880px);
  gap: 24px;
  align-items: center;
  padding: 24px 0;
}

.layout.online-performance {
  grid-template-columns: minmax(320px, 920px);
  justify-content: center;
  width: min(980px, calc(100% - 20px));
}

.layout.online-performance .sidebar {
  display: none;
}

.layout.online-performance .stage {
  width: 100%;
  max-width: 920px;
}

body[data-page="game-adj"] .layout.online-performance {
  grid-template-columns: 380px minmax(320px, 880px);
  width: min(1320px, calc(100% - 28px));
}

body[data-page="game-adj"] .layout.online-performance .sidebar {
  display: block;
}

body[data-page="game-adj"] .layout.online-performance .stage {
  width: auto;
  max-width: none;
}

/* Full screen layout for non-admin match view */
body.is-not-admin .layout {
  grid-template-columns: 1fr;
  width: 100vw;
  max-width: none;
  height: var(--app-height, 100vh);
  margin: 0;
  padding: 0;
  gap: 0;
}

body.is-not-admin .sidebar {
  display: none;
}

body.is-not-admin .stage {
  width: 100vw;
  height: var(--app-height, 100vh);
  padding: 24px 0;
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  /* display: flex;
  align-items: center;
  justify-content: center; */
  overflow: hidden;
  background: #3c2415;
  /* Darker outer background for contrast */
}

body.is-not-admin #game-root {
  position: relative;
  width: auto;
  height: 100%;
  max-width: calc(100vw - 40px);
  aspect-ratio: 760 / 1112;
  border: 10px solid #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, #f7d79a 0%, #a55d28 100%);
  /* background: linear-gradient(180deg, #f7d79a 0%, #a55d28 100%); */
  /* Perfect match with court */
  /* margin: auto; */
}

@media (max-width: 767px) {
  body.is-not-admin .stage {
    position: relative;
    padding: 0;
    /* background: linear-gradient(180deg, #F7D79A 0%, #F7D79A 50%, #A55D28 50%, #A55D28 100%); */
    background: linear-gradient(180deg, #f7d79a 0%, #a55d28 100%)
  }

  body.is-not-admin #game-root {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: var(--mobile-game-root-top, 0px);
    width: var(--mobile-game-root-width, 100vw);
    max-width: none;
    height: var(--mobile-game-root-height, var(--app-height, 100vh));
    min-height: 0;
    max-height: var(--mobile-game-root-height, var(--app-height, 100vh));
    aspect-ratio: auto;
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
    padding-top: 50px;
    padding-bottom: 70px;
  }

  body.is-not-admin #game-root canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: 0 auto;
  }

  /* When white frame is removed, expand top HUD panels to near full width */
  body.is-not-admin #training-mode-indicator,
  body.is-not-admin .match-scoreboard {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box;
  }
}

body.is-not-admin #game-root canvas {
  width: 100% !important;
  /* height: auto !important; */
  height: 100% !important;
  max-height: 100%;
  object-fit: contain;
  /* position:relative;
  top:0;
  left: */
}

@media (min-width: 768px) {
  body.is-not-admin #game-root canvas {
    height: 100% !important;
  }
}

.sidebar,
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  padding: 28px 32px 32px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.sidebar h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.96;
}

.intro {
  margin-top: 16px;
  font-size: 1rem;
  line-height: 1.7;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.score-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.score-card.wide {
  grid-column: span 2;
}

.label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(27, 26, 24, 0.56);
}

.score-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
  line-height: 1.3;
}

.panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel h2 {
  margin-bottom: 0px;
  font-size: 1rem;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  margin: 0;
  width: auto;
}

.panel p+p {
  margin-top: 10px;
}

.modal-preview-panel {
  margin-bottom: 18px;
}

.modal-preview-help {
  margin: 0 0 10px;
  font-size: 0.9rem;
  opacity: 0.9;
}

.modal-preview-ad-toggle {
  margin-bottom: 10px;
}

.modal-preview-subtitle {
  margin: 10px 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-2);
}

.modal-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.modal-preview-grid button,
#modal-preview-close {
  width: 100%;
}

.modal-preview-form {
  margin-bottom: 10px;
}

.modal-preview-form label {
  display: block;
  margin: 0 0 8px;
}

.modal-preview-form input[type="text"] {
  width: 100%;
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(27, 26, 24, 0.18);
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
}

.modal-preview-ad {
  margin-top: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: rgba(255, 248, 234, 0.92);
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

.panel label {
  display: inline-block;
  margin-right: 10px;
  font-weight: 600;
}

.panel label small {
  display: block;
  font-weight: normal;
  font-size: 0.74rem;
  color: var(--accent-2);
  margin-top: 2px;
}

.panel input[type="range"] {
  width: 150px;
  vertical-align: middle;
}

.panel input[type="number"] {
  width: 80px;
  margin-left: 8px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid rgba(27, 26, 24, 0.18);
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
}

.move-cost-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.move-cost-grid input[type="number"] {
  width: 56px;
  margin-left: 0;
  justify-self: start;
}

kbd {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(27, 26, 24, 0.14);
  background: rgba(255, 255, 255, 0.86);
  font: inherit;
  font-size: 0.9rem;
}

.stage {
  position: relative;
  padding: 18px;
}

.status-pill {
  position: absolute;
  top: 40px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.is-hidden {
  display: none !important;
}

.status-pill-left {
  left: 50%;
  transform: translateX(calc(-100% - 1.5rem));
}

.status-pill-mode {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  font-size: 0.88rem;
  padding: 10px 14px;
}

.match-scoreboard {
  position: absolute;
  top: 4px; /* 데스크탑: 최상단 밀착 — 코트 가림 방지 (2026-07-14 user) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
}

.match-scoreboard.is-visible {
  display: inline-flex;
}

.pause-game-button {
  position: fixed;
  top: 40px;
  left: 12px;
  z-index: 9;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(8, 8, 8, 0.92);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
}

.pause-game-button.in-scoreboard {
  position: static;
  top: auto;
  left: auto;
  z-index: auto;
  flex: 0 0 auto;
  margin-right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: none;
  border: none;
  background: transparent;
  opacity: 1;
  pointer-events: auto;
}

.pause-game-button.in-scoreboard i {
  font-size: 13px;
}

.pause-game-button i {
  font-size: 16px;
  line-height: 1;
}

.pause-game-button.is-paused {
  background: rgba(32, 32, 32, 0.95);
}

.pause-game-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.match-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 68px;
  line-height: 1;
}

#match-player-left,
#match-player-right {
  display: inline-block;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-player-right {
  justify-content: center;
}

.match-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-sizing: border-box;
}

.match-dot-red {
  background: #c62828;
}

.match-dot-blue {
  background: #1d4f91;
}

.match-score-current {
  min-width: 14px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}

.match-score-set {
  min-width: 14px;
  text-align: center;
  font-size: 1rem;
  color: #ffd54a;
  line-height: 1;
}

.match-vs {
  padding: 0 2px;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1;
}

.match-set-info {
  display: inline-flex;
  align-items: center;
  margin-right: 10px;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  line-height: 1;
}

.status-pill-combined {
  gap: 12px;
  padding: 10px 18px;
}

#training-mode-indicator {
  padding-top: 0;
  padding-bottom: 0;
}

.status-pill-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 246, 232, 0.35);
}

#receive-streak,
#level-indicator {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.restart-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: none;
  min-width: 210px;
  padding: 16px 24px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #c7502e, #8f2d17);
  color: #fff7ef;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 30px rgba(92, 32, 17, 0.28);
}

.restart-button.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-index-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 6;
  display: none;
  min-width: 190px;
  padding: 12px 18px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #3a3127, #1f1a13);
  color: #fff7ef;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.mobile-index-button.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.match-home-link {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 8;
  display: none;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(10, 10, 10, 0.78);
  color: #fff7ef;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.match-home-link.is-visible {
  display: none;
}

.modal-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff7ef;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

body.is-match-mode .sidebar .back-link {
  display: none;
}

.movement-ui-panel {
  /* fixed = anchored to the viewport, so the modal stays on screen and the court page
     behind it never scrolls (the scoreboard stays put — see its raised z-index). */
  position: fixed;
  left: 50%;
  /* Centre inside the MEASURED visual viewport (iOS Chrome mis-sizes dvh/fixed% while its
     toolbars animate, shoving the modal under the scoreboard / off the bottom). The
     --srt-vv* vars come from the visualViewport watcher in game.php; dvh is the fallback. */
  top: calc(var(--srt-vv-top, 0px) + var(--srt-vvh, 100dvh) / 2);
  transform: translate(-50%, -50%);
  z-index: 6;
  display: none;
  min-width: 260px;
  max-width: 84%;
  padding: 16px 18px;
  /* Bottom safe-area so the Start button clears the iOS home bar / Safari toolbar. */
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px;
  background: rgba(12, 12, 12, 0.9);
  color: #fff8ea;
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  /* Never exceed the screen; scroll INSIDE the modal when the content is taller. The top
     gap clears the scoreboard so the modal box does not sit over it. */
  max-height: calc(100vh - 84px);
  max-height: calc(100dvh - 84px);
  max-height: calc(var(--srt-vvh, 100dvh) - 84px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.movement-start-panel,
.movement-level-overlay {
  width: min(504px, 94%);
  max-width: min(504px, 94%);
}

.movement-ui-panel.is-visible {
  display: block;
}

.movement-ui-panel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.movement-ui-panel p {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.movement-level-overlay-stats {
  white-space: pre-line;
  font-size: 0.88rem;
  color: #f6f2e8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
}

.movement-level-overlay-summary-grid {
  border: 1px solid rgba(197, 146, 52, 0.7);
  border-radius: 14px;
  padding: 12px 10px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.movement-level-overlay-summary-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.movement-level-overlay-summary-value {
  margin-top: 4px;
  font-size: 4.1rem;
  font-weight: 800;
  line-height: 1.05;
  color: #f4bb44;
}

.movement-level-overlay-summary-record-title {
  margin-top: 6px;
  font-size: 1.18rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.78);
}

.movement-level-overlay-records {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.movement-level-overlay-record-chip {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 4px 10px;
  min-width: 74px;
  font-size: 1.08rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
}

.movement-level-overlay-tip,
.movement-level-overlay-next {
  white-space: pre-line;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 10px;
}

.movement-level-overlay-tip {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.movement-level-overlay-next {
  background: rgba(217, 48, 37, 0.16);
  border: 1px solid rgba(217, 48, 37, 0.48);
}

.movement-level-overlay #movement-level-overlay-button {
  margin-top: 8px;
}

.movement-level-desc-highlight {
  background: rgba(217, 48, 37, 0.18);
  border: 1px solid rgba(217, 48, 37, 0.55);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
}

.movement-level-next-guide {
  white-space: pre-line;
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #fdf2e9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
}

.movement-ui-panel label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 248, 234, 0.75);
}

.movement-ui-panel select,
.movement-ui-panel button {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff8ea;
  padding: 9px 10px;
  font: inherit;
}

.movement-ui-panel select {
  background: rgba(255, 255, 255, 0.95);
  color: #1b1a18;
  border-color: rgba(0, 0, 0, 0.24);
}

.movement-ui-panel select option {
  color: #1b1a18;
  background: #ffffff;
}

/* Custom two-line level dropdown (replaces the native <select>): row 1 = "Level N" left
   + lock/done mark right, row 2 = level title. */
.td-levelsel {
  width: 100%;
  margin-top: 4px;
}

/* Hide whichever screen (main / level-select) is inactive. */
[data-td-main][hidden],
[data-td-levelscreen][hidden] {
  display: none;
}

/* Trigger (current selection) — white box + dark text. The .movement-ui-panel prefix
   raises specificity so the panel's light button colour does not bleed in (was unreadable). */
.movement-ui-panel .td-levelsel-trigger {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 9px 36px 9px 13px;
  min-height: 48px;
  justify-content: center;
  background: rgba(255, 255, 255, 0.96);
  color: #1b1a18;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  cursor: pointer;
}

.movement-ui-panel .td-levelsel-trigger:hover {
  background: #fff;
}

.movement-ui-panel .td-levelsel-trigger .td-lvl-title {
  color: #555;
}

.td-levelsel-trigger::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #777;
  border-bottom: 2px solid #777;
  transform: translateY(-70%) rotate(45deg);
}

/* Level-select SCREEN list — on the dark modal, so LIGHT text for contrast. */
.td-levelsel-list {
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin: 6px 0 12px;
}

.movement-ui-panel .td-levelsel-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #f3f1ea;
  padding: 11px 10px;
  /* kill the panel's generic `button { margin-top: 8px }` so the highlight has no gap above it */
  margin: 0;
  border-radius: 0;
  cursor: pointer;
}

.movement-ui-panel .td-levelsel-item:last-child {
  border-bottom: 0;
}

.movement-ui-panel .td-levelsel-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.movement-ui-panel .td-levelsel-item.is-selected {
  background: rgba(217, 48, 37, 0.28);
}

.movement-ui-panel .td-levelsel-item.is-disabled {
  color: #8b8b8b;
  cursor: default;
}

.movement-ui-panel .td-levelsel-item.is-disabled:hover {
  background: transparent;
}

.td-lvl-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.td-lvl-tag {
  font-weight: 700;
  font-size: 14px;
}

/* Picker badges — [Feed|Rally][Shots N] pills, RIGHT-aligned on the tag row (user, 2026-07-12).
   Colours match the routine & drill list pages; the lock mark keeps the right edge. */
.td-lvl-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
}

.td-lvl-type {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: #0d6efd;
}

.td-lvl-type.is-feed {
  background: #198754;
}

.td-lvl-type.td-lvl-shots {
  background: #6c757d;
}

.td-lvl-mark {
  font-size: 13px;
  flex: 0 0 auto;
}

.td-lvl-title {
  font-size: 12.5px;
  opacity: 0.78;
  line-height: 1.25;
}

.movement-ui-panel .td-levelsel-back {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: #2a3245;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.movement-ui-panel .td-levelsel-back:hover {
  background: #38415a;
}

.movement-ui-panel button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.movement-ui-panel button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.movement-start-panel.adj-start-preview {
  width: min(500px, 94%);
  max-width: min(500px, 94%);
  border-radius: 22px;
}

.movement-start-panel.adj-start-preview .adj-start-badge {
  display: inline-block;
  margin: 0 auto 0.6rem;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(197, 146, 52, 0.8);
  color: #f4bb44;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

.movement-start-panel.adj-start-preview .adj-start-title {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.1;
  color: #fff;
}

.movement-start-panel.adj-start-preview .adj-start-subtitle {
  font-size: 1.08rem;
  margin: 0.4rem 0 1rem;
  color: rgba(255, 255, 255, 0.78);
}

.movement-start-panel.adj-start-preview .adj-start-card {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.75rem;
}

.movement-start-panel.adj-start-preview #movement-start-goal-card {
  border-color: rgba(217, 48, 37, 0.6);
  background: rgba(217, 48, 37, 0.15);
}

.movement-start-panel.adj-start-preview #movement-start-goal-card .adj-start-card-icon {
  background: rgba(217, 48, 37, 0.25);
}

.movement-start-panel.adj-start-preview .adj-start-card-icon {
  width: 2.8rem;
  height: 2.8rem;
  min-width: 2.8rem;
  border-radius: 999px;
  background: rgba(197, 146, 52, 0.22);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.movement-start-panel.adj-start-preview .adj-start-card-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
  color: #f4bb44;
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.movement-start-panel.adj-start-preview .adj-start-card-text {
  margin: 0;
  color: rgba(255, 255, 255, 0.93);
  font-size: 0.8rem;
  line-height: 1.3;
}

.movement-start-panel.adj-start-preview .adj-start-label {
  display: block;
  text-align: left;
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  color: rgba(255, 248, 234, 0.82);
  letter-spacing: 0.02em;
}

.movement-start-panel.adj-start-preview .adj-start-cta {
  background: rgb(217, 48, 37) !important;
  border-color: rgb(217, 48, 37) !important;
  color: #fff !important;
  font-weight: 800;
}

.movement-start-panel.adj-start-preview .adj-start-index {
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.movement-level-overlay.adj-level-preview {
  width: min(500px, 94%);
  max-width: min(500px, 94%);
  border-radius: 22px;
}

.movement-level-overlay.adj-level-preview .adj-levelup-badge {
  display: inline-block;
  margin: 0 auto 0.6rem;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(197, 146, 52, 0.8);
  color: #f4bb44;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

.movement-level-overlay.adj-level-preview #movement-level-overlay-title {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.1;
  color: #fff;
  font-weight: 800;
}

.movement-level-overlay.adj-level-preview #movement-level-overlay-text {
  font-size: 1.05rem;
  margin: 0.4rem 0 1rem;
  color: rgba(255, 255, 255, 0.78);
}

.movement-level-overlay.adj-level-preview .adj-level-card {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

.movement-level-overlay.adj-level-preview .adj-level-summary {
  border: 1px solid rgba(197, 146, 52, 0.7);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1rem 1rem 0.9rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.movement-level-overlay.adj-level-preview .adj-level-summary-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 0.15rem;
}

.movement-level-overlay.adj-level-preview .adj-level-summary-value {
  display: block;
  font-size: 1.84rem;
  line-height: 1;
  font-weight: 800;
  color: #f4bb44;
  padding: 0.5rem 0;
  margin-bottom: 0.35rem;
}

.movement-level-overlay.adj-level-preview .adj-level-summary-record {
  display: block;
  font-size: 0.98rem;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 0.55rem;
  font-weight: 700;
}

.movement-level-overlay.adj-level-preview .adj-level-summary-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.5rem;
}

.movement-level-overlay.adj-level-preview .adj-level-summary-chip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  min-width: 3.8rem;
  padding: 0.22rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.movement-level-overlay.adj-level-preview .adj-level-card-icon {
  width: 2.8rem;
  height: 2.8rem;
  min-width: 2.8rem;
  border-radius: 999px;
  background: rgba(197, 146, 52, 0.22);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.movement-level-overlay.adj-level-preview .adj-level-card-copy {
  flex: 1;
  min-width: 0;
}

.movement-level-overlay.adj-level-preview .adj-level-card-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
  color: #f4bb44;
  margin-bottom: 0.2rem;
  line-height: 1.15;
}

.movement-level-overlay.adj-level-preview .adj-level-card-text {
  margin: 0;
  color: rgba(255, 255, 255, 0.93);
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: pre-line;
}

.movement-level-overlay.adj-level-preview #movement-level-overlay-next {
  border-color: rgba(217, 48, 37, 0.6);
  background: rgba(217, 48, 37, 0.15);
}

.movement-level-overlay.adj-level-preview #movement-level-overlay-button {
  background: rgb(217, 48, 37) !important;
  border-color: rgb(217, 48, 37) !important;
  color: #fff !important;
  font-weight: 800;
  margin-top: 0.75rem;
}

#movement-fail-panel.adj-fail-preview {
  width: min(500px, 94%);
  max-width: min(500px, 94%);
  border-radius: 22px;
}

#movement-fail-panel.adj-fail-preview .adj-fail-badge {
  display: inline-block;
  margin: 0 auto 0.6rem;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 48, 37, 0.85);
  color: #ff8a7f;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

#movement-fail-panel.adj-fail-preview .adj-fail-title {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.1;
  color: #fff;
  font-weight: 800;
}

#movement-fail-panel.adj-fail-preview .adj-fail-title.has-gap {
  margin-bottom: 1rem;
}

#movement-fail-panel.adj-fail-preview .adj-fail-subtitle {
  font-size: 1.02rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

#movement-fail-panel.adj-fail-preview .adj-fail-summaries {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary {
  border: 1px solid rgba(197, 146, 52, 0.7);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1rem 1rem 0.9rem;
  margin-bottom: 0;
  text-align: center;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 0.15rem;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary-value {
  display: block;
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 800;
  color: #f4bb44;
  padding: 0.5rem 0;
  margin-bottom: 0.35rem;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary-record {
  display: block;
  font-size: 0.98rem;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 0.55rem;
  font-weight: 700;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.5rem;
}

#movement-fail-panel.adj-fail-preview .adj-level-summary-chip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  min-width: 3.8rem;
  padding: 0.22rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

#movement-fail-panel.adj-fail-preview #movement-fail-stats:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  min-height: 0 !important;
}

#movement-fail-panel.adj-fail-preview #movement-retry-button {
  background: rgb(217, 48, 37) !important;
  border-color: rgb(217, 48, 37) !important;
  color: #fff !important;
  font-weight: 800;
  margin-top: 0.2rem;
}

#movement-fail-panel.adj-fail-preview #movement-level-down-button,
#movement-fail-panel.adj-fail-preview #movement-level-up-button,
#movement-fail-panel.adj-fail-preview #movement-level-select-button {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
}

#movement-fail-panel.adj-fail-preview .adj-fail-index {
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
  margin-top: 0.6rem !important;
}

.match-setup-panel {
  width: min(504px, 94%);
  max-width: min(504px, 94%);
}

.training-name-modal {
  z-index: 9;
  min-width: 340px;
  max-width: min(560px, 94%);
  max-height: 92dvh;
  overflow-y: auto;
}

.training-record-line { display: block; font-weight: 800; font-size: 1.05rem; color: #ffd98a; margin-bottom: 8px; }
.training-record-ask { display: block; margin-top: 10px; color: #cdd6e4; font-size: 0.92rem; }
.training-record-summary { display: flex; flex-direction: column; gap: 8px; margin: 6px auto 4px; max-width: 440px; }
.training-record-card { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px; padding: 10px 12px; text-align: center; }
.training-record-card .adj-level-summary-label { display: block; font-size: 0.78rem; color: #9fb0c8; letter-spacing: 0.3px; }
.training-record-card .adj-level-summary-value { display: block; font-size: 1.45rem; font-weight: 800; color: #f4bb44; line-height: 1.1; padding: 2px 0; }
.training-record-card .adj-level-summary-record, .training-record-card .adj-level-summary-chips { font-size: 0.8rem; color: #cdd6e4; }

.training-rank-highlight {
  color: #f4bb44;
  font-size: 2em;
  font-weight: 900;
  line-height: 1;
  display: inline-block;
}

.training-name-trophy {
  width: 150px;
  height: 150px;
  object-fit: contain;
  display: block;
  margin: 2px auto 10px;
}

.training-name-modal input {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.95);
  color: #1b1a18;
  padding: 9px 10px;
  font: inherit;
}

.training-name-error {
  min-height: 1.2em;
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: #ffc8c8;
}

.training-name-success {
  margin: 10px 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: #f4bb44;
}

.training-name-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.training-name-actions button {
  flex: 1;
  margin-top: 0;
}

.match-result-modal {
  z-index: 10;
  min-width: 300px;
  max-width: min(460px, 90%);
}

.pause-game-modal {
  z-index: 12;
  width: min(360px, 92%);
}

.match-result-winner {
  margin: 8px 0 4px;
  font-size: 1.02rem;
  font-weight: 700;
  color: #ffe4c2;
}

.match-result-summary {
  margin: 8px 0 10px;
  text-align: left;
}

.match-result-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  font-size: 0.96rem;
}

.match-result-summary-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff8ea;
}

.match-result-summary-scores {
  display: inline-flex;
  gap: 6px;
}

.match-result-summary-score {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  color: #fff8ea;
}

.match-result-summary-score.is-win {
  background: #d93025;
  color: #fff;
}

.match-result-note {
  margin: 8px 0;
  font-size: 0.85rem;
  color: #ffe9c0;
}

#match-result-record-button {
  width: 100%;
  margin-top: 2px;
}

.match-setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

#match-difficulty-buttons {
  align-items: stretch;
}

#match-difficulty-label {
  grid-column: 1 / -1;
  text-align: left;
  margin: 0 0 4px;
}

#match-set-count-label {
  text-align: left;
}

#match-set-count-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#match-online-host-buttons button,
.modal-home-link,
#match-setup-back-button,
#match-setup-start-button {
  white-space: nowrap;
}

.match-online-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: rgba(255, 248, 234, 0.78);
  line-height: 1.45;
}

.match-online-box {
  margin-top: 10px;
  text-align: left;
}

.match-online-box label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: rgba(255, 248, 234, 0.86);
}

.match-online-box input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.95);
  color: #1b1a18;
  padding: 9px 10px;
  font: inherit;
}

.match-online-marker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: rgba(255, 248, 234, 0.9);
}

.match-online-marker-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.match-online-status {
  margin-top: 12px;
  padding-top: 4px;
  margin-bottom: 0;
  min-height: 2.8em;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(255, 248, 234, 0.88);
}

.match-setup-panel button.is-selected {
  background: rgba(255, 223, 77, 0.28);
  border-color: rgba(255, 223, 77, 0.68);
}

#event-call-overlay.event-call-overlay {
  position: absolute;
  left: 50%;
  top: calc(50% + 20px);
  transform: translate(-50%, -50%);
  z-index: 7;
  display: none;
  width: 98%;
  max-width: 767px;
  padding: clamp(10px, 2.6vw, 14px) clamp(14px, 4vw, 24px);
  border-radius: 16px;
  background: #ffffff;
  border: 6px solid #b13622;
  color: #b13622;
  font-family: "Trebuchet MS", sans-serif;
  font-size: clamp(15px, 3.8vw, 24px);
  line-height: 1.24;
  font-weight: 900;
  text-align: center;
  text-shadow: none;
  pointer-events: none;
}

#event-call-overlay.event-call-overlay.is-visible {
  display: block;
}

#event-call-overlay.event-call-overlay.quickstart-ko {
  font-size: clamp(12px, 2.7vw, 18px);
  line-height: 1.16;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

#movement-level-down-button,
#movement-level-up-button {
  display: none;
}

#game-root {
  position: relative;
  width: 100%;
  aspect-ratio: 0.684;
  border-radius: 24px;
  overflow: hidden;
  /* background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.08)),
    linear-gradient(180deg, #d39a4f 0%, #a55d28 100%); */
}

#game-root canvas {
  position: relative;
  z-index: 1;
  display: block;
  /* width: 100%; */
  /* height: 100%; */
}

.court-logo {
  position: absolute;
  z-index: 2;
  left: var(--logo-left, 50%);
  top: var(--logo-top, 16%);
  width: var(--logo-width, 34%);
  max-width: none;
  transform: translateX(-50%);
  opacity: 0.92;
  pointer-events: none;
  user-select: none;
}

.mobile-orientation-lock {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 8, 8, 0.92);
  color: #fff8ea;
  text-align: center;
}

.mobile-orientation-lock__inner {
  max-width: 360px;
}

.mobile-orientation-lock__inner h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.mobile-orientation-lock__inner p {
  margin: 0;
  line-height: 1.5;
  color: rgba(255, 248, 234, 0.88);
}

@media (max-width: 1120px) {
  .menu-hero {
    grid-template-columns: 1fr;
  }

  .menu-logo-panel {
    min-height: 170px;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .training-guide {
    grid-template-columns: 1fr;
  }

  .guide-card p {
    min-height: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 16px 0 20px;
  }

  .sidebar {
    padding: 24px;
  }
}

@media (max-width: 767px) {
  body[data-page="menu"] {
    overflow: auto;
  }

  body[data-page="game"] {
    background-color: #A55C28;
  }

  .menu-shell {
    width: min(100%, calc(100% - 24px));
    padding: 16px 0 24px;
  }

  .menu-hero,
  .mode-card {
    border-radius: 22px;
  }

  .menu-hero {
    padding: 20px;
    gap: 14px;
  }

  .menu-logo-panel {
    min-height: 130px;
    padding: 10px;
  }

  .menu-intro {
    font-size: 0.95rem;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .guide-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .guide-actions {
    width: 100%;
  }

  .guide-help,
  .guide-go {
    width: 100%;
    justify-content: center;
  }

  .mode-help-panel,
  .movement-ui-panel,
  .match-setup-panel,
  .training-name-modal,
  .match-result-modal,
  .pause-game-modal {
    left: 0 !important;
    top: 0 !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    /* Fit the DYNAMIC viewport (dvh tracks the iOS toolbar) so the modal bottom is never
       behind the Safari toolbar; vh is the fallback for old browsers. */
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: 0 !important;
    /* Modal fills the screen; ONLY its content scrolls (the page behind never scrolls). */
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    /* Generous bottom space + home-bar safe area so the last button always clears the toolbar. */
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body[data-page="game"] {
    height: var(--app-height, 100vh);
    min-height: var(--app-height, 100vh);
    max-height: var(--app-height, 100vh);
    overflow: hidden;
  }

  .online-room-list {
    padding: 14px;
  }

  #online-room-list {
    padding-left: 14px;
  }

  body[data-page="game"] .layout {
    width: 100vw;
    /* height: var(--app-height, 100vh); */
    /* min-height: var(--app-height, 100vh); */
    /* max-height: var(--app-height, 100vh); */
    padding: 0;
    margin: 0;
    gap: 0;
    overflow: hidden;
  }

  body[data-page="game"] .sidebar {
    display: none;
  }

  body[data-page="game-adj"] .sidebar {
    display: block;
  }

  body[data-page="game"] .stage {
    width: 100vw;
    /* height: var(--app-height, 100vh); */
    /* min-height: var(--app-height, 100vh); */
    /* max-height: var(--app-height, 100vh); */
    padding: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    overflow: hidden;
    /* background: linear-gradient(180deg, #F7D79A 0%, #F7D79A 50%, #A55D28 50%, #A55D28 100%); */
  }

  .movement-ui-panel {
    padding: 20px 16px;
    display: none;
  }

  /* block flow (NOT grid+center) so overflowing content scrolls top→bottom and the
     bottom buttons (Restart / Back to Index) are reachable. */
  .movement-ui-panel.is-visible {
    display: block;
  }

  .restart-button {
    min-width: 210px;
    padding: 18px 24px;
    font-size: 1.02rem;
  }

  .mobile-index-button {
    bottom: 14px;
    min-width: 172px;
    padding: 11px 16px;
    font-size: 0.9rem;
  }

  .status-pill {
    top: 14px;
    font-size: 0.92rem;
    padding: 10px 14px;
  }

  .status-pill-left {
    left: 50%;
    transform: translateX(calc(-100% - 1.5rem));
  }

  .status-pill-combined {
    gap: 10px;
    padding: 10px 14px;
  }

  #training-mode-indicator {
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    font-size: 0.78rem;
    padding: 9px 46px; /* clears the edge-pinned pause/sound buttons */
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }
  /* Mobile scoreboard: pause left / sound right pinned to the EDGES so the centered flex row
     shows Shot n/N | Level(Drill) exactly in the middle of the bar. (user request) */
  #training-mode-indicator .pause-game-button.in-scoreboard {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    margin: 0;
  }
  #training-mode-indicator #sound-toggle-button.in-scoreboard {
    left: auto;
    right: 8px;
  }

  #event-call-overlay.event-call-overlay {
    width: 98%;
    max-width: 98vw;
    padding: 11px 14px;
    border-width: 4px;
    border-radius: 14px;
    font-size: clamp(14px, 5vw, 20px);
    line-height: 1.22;
  }

  #event-call-overlay.event-call-overlay.quickstart-ko {
    font-size: clamp(10px, 3.2vw, 14px);
    line-height: 1.14;
    white-space: nowrap;
    letter-spacing: -0.02em;
  }

  .match-scoreboard {
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    gap: 8px;
    padding: 9px 12px;
    font-size: 0.82rem;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }

  .match-player {
    min-width: 50px;
    gap: 6px;
  }

  #match-player-left,
  #match-player-right {
    display: inline-block;
    max-width: 48px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }

  .match-dot {
    width: 11px;
    height: 11px;
  }

  .match-score-current {
    font-size: 0.9rem;
  }

  .match-score-set {
    font-size: 0.9rem;
  }

  .pause-game-button {
    width: 34px;
    height: 34px;
  }

  #game-root {
    width: var(--mobile-game-root-width, 100vw);
    height: var(--mobile-game-root-height, var(--app-height, 100vh));
    aspect-ratio: auto;
    border-radius: 0;
  }
}

@media (hover: none) and (pointer: coarse) and (max-width: 1024px) and (orientation: landscape) {
  body[data-page="game"] .mobile-orientation-lock {
    display: flex;
  }

  body[data-page="game"] .layout {
    visibility: hidden;
    pointer-events: none;
  }
}

body[data-page="game-adj"].is-not-admin .layout {
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 380px minmax(320px, 880px);
  gap: 24px;
  align-items: center;
  padding: 24px 0;
}

body[data-page="game-adj"].is-not-admin .sidebar {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

/* Sound toggle: parked at the RIGHT end of the scoreboard/pill (flex push). */
#sound-toggle-button.in-scoreboard { margin-left: auto; margin-right: 0; }

/* Level list: muted ball-count next to the level title. */
.td-lvl-balls { color: #9aa3ad; font-size: .85em; font-weight: 400; }
