/* Global Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dark theme palette (Landing Scoreboard) */
  --navy:       #0b1620;
  --navy-2:     #11202d;
  --navy-3:     #17293a;
  --line:       #1e3448;
  --line-2:     #2b4a66;
  --amber:      #f6b233;
  --amber-soft: #ffd27a;
  --cream:      #f4ead3;
  --red:        #e23b3b;
  --green:      #4fd18b;
  --dim:        #7b93aa;
  --text:       #e9efe8;

  /* Game accent colours (kept for chart colour stops) */
  --primary-color:    #002D72;
  --secondary-color:  #E31837;
  --accent-color:     #CBD2D9;
  --card-shadow:      0 4px 8px rgba(0,0,0,0.35);
  --transition-speed: 0.3s;
  --border-radius:    8px;
}

html, body {
  background: var(--navy);
  color: var(--text);
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  min-height: 100%;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Stadium background: radial flood-lights + subtle grid */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(246,178,51,0.10), transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 10%, rgba(246,178,51,0.08), transparent 60%),
    linear-gradient(180deg, #0b1620 0%, #0a141d 100%);
  z-index: -2;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, black, transparent 80%);
  z-index: -1;
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Page grid ───────────────────────────────── */
.container {
  display: grid;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "nav"
    "main"
    "footer";
}

main {
  grid-area: main;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.container1 {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  box-sizing: border-box;
}

/* ── Top bar ─────────────────────────────────── */
.topbar {
  grid-area: nav;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,22,32,0.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
  width: 100%;
  box-sizing: border-box;
}

.brand {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none;
}

.brand-mark {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--red);
  display: grid; place-items: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 4px 14px rgba(226,59,59,0.35);
}
.brand-mark::after {
  content: ''; width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  background:
    linear-gradient(transparent 49%, rgba(255,255,255,0.9) 49%, rgba(255,255,255,0.9) 51%, transparent 51%),
    linear-gradient(90deg, transparent 49%, rgba(255,255,255,0.9) 49%, rgba(255,255,255,0.9) 51%, transparent 51%);
}

.brand-text {
  font-family: 'Anton', sans-serif;
  font-size: 20px; letter-spacing: 0.08em;
  line-height: 1;
  color: var(--text);
}
.brand-text small {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--amber);
  letter-spacing: 0.3em;
  margin-top: 3px;
}

.topbar-right {
  display: flex; gap: 10px; align-items: center;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--navy-2);
  display: grid; place-items: center;
  transition: all 0.2s;
  color: var(--text);
}
.icon-btn:hover { border-color: var(--amber); color: var(--amber); }

/* ── Footer ──────────────────────────────────── */
footer {
  grid-area: footer;
  padding: 40px 28px 30px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 40px;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}
footer .legal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--dim);
  line-height: 1.7;
  max-width: 720px;
}
footer .legal a {
  color: var(--amber-soft);
  margin-right: 16px;
  text-decoration: none;
}
footer .legal a:hover { color: var(--amber); }
footer .sign {
  font-family: 'Anton', sans-serif;
  font-size: 36px;
  letter-spacing: 0.08em;
  color: var(--line-2);
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Guesses Left ────────────────────────────── */
#guesses-left {
  margin: 0.75rem auto;
  text-align: center;
  max-width: 400px;
  font-weight: 600;
  color: var(--amber);
  transition: all var(--transition-speed);
  font-size: 1.2rem;
}

/* ── Section headings ────────────────────────── */
h1 {
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 1rem 0;
  font-weight: 600;
  text-align: center;
}

h2 {
  font-size: 0.85rem;
  color: var(--dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1rem 0 0.5rem 0;
  text-align: left;
}

h4 {
  font-size: 0.8rem;
  color: var(--dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.5rem 0;
  text-align: left;
}

/* ── Main Content Cards ──────────────────────── */
.pitching-stats-card,
.batting-stats-card {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
  box-shadow: var(--card-shadow);
}

/* Key section headings — centered */
.pitching-stats-card > h2,
.batting-stats-card > h2,
.pitching-stats-card > .pitching-stats-grid,
.batting-stats-card > .stats-container {
  text-align: center;
}

.pitching-stats-card > h2,
.batting-stats-card > h2 {
  text-align: center;
}

/* Advanced charts — constrained width, centered */
.advanced-chart-wrap {
  max-width: 560px;
  margin: 0 auto;
}

/* ── Stat Cards Grid ─────────────────────────── */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(120px, 45%), 140px));
  justify-content: center;
  gap: 10px;
  margin: 0.75rem 0;
}

.stat-card {
  background: var(--navy-3);
  border: 1px solid var(--line);
  border-top: 3px solid var(--card-color, #f6b233);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.stat-card .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--card-color, #f6b233);
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 0.7rem;
  color: var(--dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Chart Containers ────────────────────────── */
.chart-container {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.75rem 0;
}

#additional-stats-chart {
  width: 100% !important;
  margin: 0 auto;
}

.charts-row,
.pitching-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0.75rem 0;
}

.pitching-chart-container {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.pitching-chart-container h2,
.chart-container h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.75rem 0;
  text-align: left;
}

canvas {
  max-height: 260px;
}

@media (max-width: 640px) {
  .charts-row,
  .pitching-charts-row {
    grid-template-columns: 1fr;
  }
}

/* ── Hit Types Display ───────────────────────── */
.hit-types-grid,
.batting-hit-types-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

.hit-type-box {
  background: var(--navy-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.hit-type-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.hit-type-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.hit-type-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--amber);
}

/* Pitching hit type cards */
.hit-type-card {
  background: linear-gradient(145deg, var(--navy-3), var(--navy-2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.hit-type-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.35);
}

.hit-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--amber);
  line-height: 1;
  margin-bottom: 0.2rem;
  position: relative;
  z-index: 1;
}

.hit-label {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  margin-bottom: 0.5rem;
}

.hit-percentage {
  background: var(--line-2);
  color: #000;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

/* Specific hit type colour accents */
.hit-type-card.singles .hit-value { color: #4fd18b; }
.hit-type-card.doubles .hit-value { color: #60a5fa; }
.hit-type-card.triples .hit-value { color: #c084fc; }
.hit-type-card.homers  .hit-value { color: #f87171; }

.hit-type-card.singles .hit-percentage { background: #4fd18b; }
.hit-type-card.doubles .hit-percentage { background: #60a5fa; }
.hit-type-card.triples .hit-percentage { background: #c084fc; }
.hit-type-card.homers  .hit-percentage { background: #f87171; }

/* ── Fielding cards ──────────────────────────── */
.positions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.25rem;
  justify-content: center;
  width: 100%;
  margin: 0 auto;
}

.position-card {
  background: var(--navy-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem;
  width: 150px;
  flex: 0 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  margin: 0.25rem;
}

.position-card .position-title {
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  padding: 0.25rem;
  margin: -0.5rem -0.5rem 0.35rem -0.5rem;
  background: var(--navy-2);
  border-bottom: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
}

.position-card .stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
}

.position-card .stats-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text);
}

.position-card .stats-list li:last-child {
  border-bottom: none;
  color: var(--amber);
  font-weight: 600;
  margin-top: 0.25rem;
  background: var(--navy-2);
  padding: 0.25rem;
  border-radius: 3px;
  text-align: center;
}

@media (min-width: 768px) {
  .positions-grid {
    max-width: fit-content;
    margin: 0 auto;
  }
}

/* ── Search Component ────────────────────────── */
.search-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 600px;
  margin: 1rem auto;
  box-sizing: border-box;
}

.autocomplete {
  position: relative;
  flex: 1;
  max-width: 1500px;
}

.team-search {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s;
  background: var(--navy-3);
  color: var(--text);
}

.team-search::placeholder { color: var(--dim); }

.team-search:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(246,178,51,0.15);
}

.search-button-cta {
  background: var(--red);
  color: white;
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.search-button-cta:hover {
  background: #c82b2b;
}

.autocomplete-items {
  position: absolute;
  border: 1px solid var(--line-2);
  border-bottom: none;
  border-top: none;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--navy-3);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.35);
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-items div {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s;
  color: var(--text);
}

.autocomplete-items div:hover {
  background-color: var(--navy-2);
}

/* ── Hints ───────────────────────────────────── */
.hints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.hint-box {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  transition: all 0.3s ease;
}

.hint-box.hidden {
  opacity: 0.5;
  background: var(--navy-3);
}

.hint-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hint-icon {
  font-size: 1.5rem;
}

.hint-text {
  flex: 1;
}

.hint-label {
  font-size: 0.875rem;
  color: var(--dim);
  margin-bottom: 0.25rem;
}

.hint-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Loader ──────────────────────────────────── */
.loader {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  color: var(--dim);
}

.loader::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid var(--line-2);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.shake-animation { animation: shake 0.5s; }
.shake-animation-red { background-color: red; transition: background-color 0.2s; }

/* ── Popup ───────────────────────────────────── */
.popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 380px);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--navy-2);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  z-index: 1000;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
  text-align: center;
  font-size: 14px;
  color: var(--text);
  padding: 0;
}

.popup-header {
  background: linear-gradient(135deg, #0b1620 0%, #17293a 100%);
  border-bottom: 1px solid var(--line);
  padding: 1.25rem 1.5rem 1rem;
  border-radius: 16px 16px 0 0;
}

.popup-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.3rem;
}

.popup-player-name {
  font-family: 'Anton', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--amber);
  margin: 0;
  line-height: 1.2;
}

.popup-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 1.1rem 0 0.6rem;
}

.popup-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 1.25rem;
}

.popup-stat-item {
  background: var(--navy-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.popup-stat-item .stat-item-figure {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}

.popup-stat-item .stat-item-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.popup-countdown {
  margin: 1.1rem 0 0.5rem;
  padding: 0 1.25rem;
}

.next-in {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  margin-bottom: 4px;
}

#countdownAnchorage {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--amber);
  line-height: 1;
}

.popup .cta-button {
  display: block;
  width: calc(100% - 2.5rem);
  margin: 0.75rem auto 1.25rem;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.popup .cta-button:hover {
  background: #c82b2b;
}

@media (max-width: 400px) {
  .popup-player-name { font-size: 1.2rem; }
  .popup-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 0 1rem;
  }
  .popup-stat-item .stat-item-figure { font-size: 1rem; }
  #countdownAnchorage { font-size: 1.2rem; }
}

/* ── Performance graph ───────────────────────── */
.graph {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.graph-content {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.graph-item {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.attempt-number,
.attempt-skull {
  width: 18px;
  display: flex;
  align-items: center;
  color: var(--dim);
}

.attempt-skull .icon { height: 12px; }

.attempt-stat {
  height: 17px;
  width: 100%;
  font-weight: bold;
  font-size: 14px;
  color: var(--amber);
}

.attempt-bar {
  height: 100%;
  background: #41b845;
  color: rgb(18,17,17);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-weight: bolder;
  font-size: 10px;
  font-weight: 400;
  display: flex;
  box-sizing: border-box;
  padding: 0 6px;
  justify-content: flex-end;
  align-items: center;
  min-width: 28px;
  border-radius: 3px;
}

.best { background: #41b845; }

/* ── Misc ────────────────────────────────────── */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.logos {
  display: flex;
  margin-left: auto;
}

.logos img, .logos a { cursor: pointer; }

.logos a {
  margin-left: 25px;
  display: inline-block;
  position: relative;
  transition: transform 0.3s ease-in-out;
}

.logos a:hover { transform: scale(1.2); }

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  height: 10px;
  width: 10px;
}

/* ── Stats grid legacy ───────────────────────── */
.pitching-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

/* ── MOBILE RESPONSIVE ───────────────────────── */

/* Tablet: ≤768px */
@media (max-width: 768px) {
  .topbar {
    padding: 14px 16px;
  }

  .brand-text { font-size: 16px; }

  footer {
    padding: 28px 20px 24px;
    gap: 24px;
  }

  footer .sign { font-size: 24px; }

  .pitching-stats-card,
  .batting-stats-card {
    padding: 0.875rem 1rem;
    margin: 0.5rem 0;
  }

  .container1 {
    padding: 0.75rem 1rem;
  }

  .charts-row,
  .pitching-charts-row {
    grid-template-columns: 1fr;
  }

  .advanced-chart-wrap {
    max-width: 100%;
  }

  .stat-cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
  }

  .stat-card .stat-value { font-size: 1.2rem; }

  canvas { max-height: 220px; }

  .hit-type-card { padding: 0.75rem 0.5rem; }
  .hit-value { font-size: 1.4rem; }

  .hit-types-grid,
  .batting-hit-types-grid {
    gap: 0.5rem;
    padding: 0.5rem;
    max-width: 100%;
  }

  .positions-grid { gap: 0.5rem; }
  .position-card { width: calc(50% - 0.5rem); }

  h1 { font-size: 0.9rem; }
}

/* Footer single column at ≤900px */
@media (max-width: 900px) {
  footer { grid-template-columns: 1fr; }
  footer .sign { font-size: 20px; }
}

/* Phone: ≤480px */
@media (max-width: 480px) {
  .topbar {
    padding: 12px 14px;
  }

  .brand-text { font-size: 14px; }
  .brand-text small { font-size: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark::after { width: 18px; height: 18px; }

  footer {
    padding: 20px 16px;
  }

  .container1 {
    padding: 0.5rem 0.75rem;
  }

  .pitching-stats-card,
  .batting-stats-card {
    padding: 0.75rem;
    margin: 0.4rem 0;
    border-radius: 6px;
  }

  h1 { font-size: 0.8rem; margin-bottom: 0.5rem; }
  h2, h4 { font-size: 0.75rem; }

  .stat-cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat-card { padding: 8px 6px; border-radius: 6px; }
  .stat-card .stat-value { font-size: 1rem; }
  .stat-card .stat-label { font-size: 0.6rem; }

  .pitching-chart-container,
  .chart-container { padding: 0.6rem; }

  canvas { max-height: 180px; }

  .hit-types-grid { gap: 0.4rem; padding: 0.4rem; }
  .hit-type-card { padding: 0.5rem 0.3rem; border-radius: 6px; }
  .hit-value { font-size: 1.1rem; }
  .hit-label { font-size: 0.55rem; }
  .hit-percentage { font-size: 0.7rem; }

  .batting-hit-types-grid { gap: 0.4rem; padding: 0.4rem; }
  .hit-type-box { padding: 0.4rem; }
  .hit-type-value { font-size: 1rem; }
  .hit-type-label { font-size: 0.55rem; }

  #guesses-left { font-size: 1rem; }

  .search-button-cta {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
  }

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

  .position-card {
    width: calc(50% - 0.4rem);
    min-width: 0;
  }

  .positions-grid { gap: 0.4rem; }
}

/* Very small phones: ≤360px */
@media (max-width: 360px) {
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .stat-card .stat-value { font-size: 0.95rem; }

  .charts-row,
  .pitching-charts-row { gap: 0.4rem; }

  canvas { max-height: 160px; }

  .hit-types-grid,
  .batting-hit-types-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hints-grid { grid-template-columns: 1fr; }
  .position-card { width: 100%; }
}

/* ≤320px — absolute minimum supported size */
@media (max-width: 320px) {
  /* Layout */
  .container1 { padding: 0.35rem 0.5rem; }

  /* Topbar */
  .topbar { padding: 10px 10px; gap: 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 6px; }
  .brand-mark::after { width: 15px; height: 15px; border-width: 1.5px; }
  .brand-text { font-size: 11px; letter-spacing: 0.05em; }
  .brand-text small { display: none; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 12px; height: 12px; }

  /* Cards */
  .pitching-stats-card,
  .batting-stats-card { padding: 0.5rem 0.5rem; margin: 0.3rem 0; border-radius: 6px; }

  /* Stat grid */
  .stat-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .stat-card { padding: 6px 4px; border-radius: 5px; }
  .stat-card .stat-value { font-size: 0.85rem; }
  .stat-card .stat-label { font-size: 0.5rem; letter-spacing: 0; }

  /* Headings */
  h1 { font-size: 0.72rem; margin-bottom: 0.4rem; }
  h2, h4 { font-size: 0.65rem; margin: 0.5rem 0 0.3rem; }

  /* Chart containers */
  .pitching-chart-container,
  .chart-container { padding: 0.4rem; border-radius: 6px; }
  canvas { max-height: 170px; }

  /* Hit type cards (pitching) */
  .hit-types-grid { gap: 0.3rem; padding: 0.3rem; }
  .hit-type-card { padding: 0.4rem 0.25rem; border-radius: 8px; gap: 0.3rem; }
  .hit-value { font-size: 1rem; }
  .hit-label { font-size: 0.5rem; margin-bottom: 0.2rem; }
  .hit-percentage { padding: 0.2rem 0.5rem; font-size: 0.6rem; border-radius: 12px; }

  /* Hit type boxes (batting) */
  .batting-hit-types-grid { gap: 0.3rem; padding: 0.3rem; }
  .hit-type-box { padding: 0.3rem; border-radius: 6px; }
  .hit-type-value { font-size: 0.85rem; }
  .hit-type-label { font-size: 0.5rem; }

  /* Fielding */
  .position-card { width: 100%; margin: 0; }
  .positions-grid { gap: 0.3rem; padding: 0.2rem; }
  .position-card .position-title { font-size: 0.75rem; }
  .position-card .stats-list { font-size: 0.65rem; }

  /* Search */
  .team-search { font-size: 14px; padding: 9px 10px; }
  .search-button-cta { padding: 0.5rem 1rem; font-size: 0.8rem; border-radius: 20px; }
  #guesses-left { font-size: 0.85rem; }

  /* Hints */
  .hints-grid { grid-template-columns: 1fr; gap: 0.4rem; }
  .hint-box { padding: 0.6rem; }
  .hint-label { font-size: 0.75rem; }
  .hint-value { font-size: 0.85rem; }

  /* Popup */
  .popup { border-radius: 12px; }
  .popup-header { padding: 1rem 1rem 0.75rem; border-radius: 12px 12px 0 0; }
  .popup-player-name { font-size: 1.1rem; }
  .popup-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 0 0.75rem; }
  .popup-stat-item { padding: 0.5rem 0.25rem; border-radius: 6px; }
  .popup-stat-item .stat-item-figure { font-size: 0.9rem; }
  .popup-stat-item .stat-item-label { font-size: 0.5rem; }
  #countdownAnchorage { font-size: 1.1rem; }
  .popup .cta-button { font-size: 0.8rem; padding: 0.6rem 0.75rem; }

  /* Footer */
  footer { padding: 16px 10px; }
  footer .sign { font-size: 16px; letter-spacing: 0.05em; }
  footer .legal a { margin-right: 8px; }
}
