/* Baseball Century - JS/HTML/CSS version */
:root {
  --bg-main: #9CBC3D;
  --bg-sidebar: #E9AF27;
  --bg-content: #fff;
  --text-dark: #333;
  --font-main: Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-main);
  font-family: var(--font-main);
  color: var(--text-dark);
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 8px;
}

.banner {
  text-align: center;
  padding: 0 0 8px;
}
.banner img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.main-layout {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: center;
}

.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-sidebar);
  padding: 8px;
  font-size: 12px;
}
.sidebar .panel {
  background: #fff;
  padding: 8px;
  margin-bottom: 12px;
  width: 180px;
}
.sidebar .panel h3 {
  margin: 0 0 6px;
  font-size: 13px;
}
.sidebar table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}
.sidebar td {
  padding: 2px 4px;
}
.sidebar-empty {
  margin: 0;
  font-size: 12px;
  color: #888;
  font-style: italic;
}
.sidebar-min {
  font-size: 11px;
  color: #666;
  font-weight: normal;
}

.content {
  flex: 0 0 600px;
  width: 600px;
  min-width: 0;
  background: var(--bg-content);
  padding: 12px 16px;
  max-width: 600px;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 12px;
  min-height: 50px;
}
.header-bar .team-name { font-size: 1.2em; font-weight: bold; }
.header-bar .sub { font-size: 0.85em; opacity: 0.9; }

.intro-callout {
  background: linear-gradient(135deg, #f8f6e8 0%, #fff 100%);
  border-left: 4px solid var(--bg-sidebar);
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 0 6px 6px 0;
}
.intro-lead {
  font-size: 1.25em;
  font-weight: bold;
  margin: 0 0 4px;
  color: #1a1a1a;
  letter-spacing: 0.02em;
}
.intro-sub {
  margin: 0;
  font-size: 1em;
  color: #444;
  line-height: 1.4;
}

.manager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.manager-form { margin: 0; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  margin: 4px 4px 4px 0;
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #999;
  background: #f0f0f0;
  border-radius: 4px;
  touch-action: manipulation;
}
.btn:hover { background: #e0e0e0; }
.btn-primary { background: #E9AF27; border-color: #c99a20; }

/* Allow horizontal scroll on small screens when table is wide */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
}

.encyclopedia-section {
  margin-bottom: 0.75em;
}
.encyclopedia-section h3 {
  margin: 0 0 4px;
  font-size: 14px;
}
.encyclopedia-section .table-wrap {
  margin: 4px 0 8px;
}
.encyclopedia-section table.data th,
.encyclopedia-section table.data td {
  padding: 3px 6px;
}
.encyclopedia-section p {
  margin: 2px 0 6px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 6px 8px;
  text-align: left;
  border: 1px solid #ddd;
}
table.data th { background: #f5f5f5; }
table.data .num { text-align: right; }
table.data thead.batters { background-color: #C4E2FC; }
table.data thead.pitchers { background-color: #FFFE61; }
table.data tbody.batters tr:nth-child(odd) { background-color: #E8F4FC; }
table.data tbody.batters tr:nth-child(even) { background-color: #fff; }
table.data tbody.pitchers tr:nth-child(odd) { background-color: #FFFDE0; }
table.data tbody.pitchers tr:nth-child(even) { background-color: #fff; }

.teams-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.teams-pick section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  text-align: center;
}
.teams-pick label {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.teams-pick input[type=radio] { margin-right: 8px; }

.spring-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}
.spring-card {
  width: 110px;
  border: 1px solid #999;
  border-radius: 4px;
  padding: 6px;
  background: #fff;
  box-shadow: 2px 2px 0 #ccc;
}
.spring-card .card-head {
  padding: 6px 4px;
  margin: -6px -6px 6px -6px;
  border-radius: 4px 4px 0 0;
  font-weight: bold;
  font-size: 12px;
}
.spring-card .card-head.batter { background-color: #C4E2FC; }
.spring-card .card-head.pitcher { background-color: #FFFE61; }
.spring-card .name { font-weight: bold; font-size: 12px; }
.spring-card .pos { font-style: italic; font-size: 11px; color: #333; }
.spring-card .stats { font-size: 11px; margin-top: 4px; }
.spring-card .overall {
  font-weight: bold;
  text-align: center;
  padding: 4px;
  margin: 6px -6px -6px -6px;
  border-radius: 0 0 4px 4px;
}
.spring-card .overall.batter { background-color: #C4E2FC; }
.spring-card .overall.pitcher { background-color: #FFFE61; }
.spring-card .overall .rating-change {
  font-weight: normal;
  opacity: 0.75;
}
.spring-card[data-playerkey]:not(.selected) {
  opacity: 0.65;
  border-color: #ccc;
}
.spring-card[data-playerkey]:not(.selected):hover {
  opacity: 0.85;
}
.spring-card.selected {
  position: relative;
  border: 3px solid var(--team-color1, #c99a20);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--team-color1, #E9AF27), 0 4px 12px rgba(0,0,0,0.2);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--team-color1, #E9AF27) 12%, transparent), transparent 30%);
  opacity: 1;
  transform: scale(1.02);
}
.spring-card input[type=checkbox] { margin: 4px 0; }
.spring-card[data-playerkey] {
  touch-action: manipulation;
}

.roster-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.roster-row .row-label {
  width: 100%;
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 4px;
  padding: 4px 6px;
  border-radius: 4px;
}
.roster-row .row-label.batters { background-color: #C4E2FC; }
.roster-row .row-label.pitchers { background-color: #FFFE61; }

.standings-columns {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.standings-col {
  flex: 1;
  min-width: 180px;
}
.standings-table { margin: 0; }
.standings-table td.num { text-align: right; }
.standings-columns .standings-table { margin-bottom: 0; }
.world-series { margin: 16px 0; padding: 12px; background: #f8f8f8; border-radius: 4px; }

.champions-banner {
  margin-top: 20px;
  padding: 24px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
  border: 3px solid #d4af37;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
}
.champions-trophy {
  font-size: 64px;
  margin-bottom: 8px;
  animation: trophy-glow 2s ease-in-out infinite;
}
@keyframes trophy-glow {
  0%, 100% { filter: drop-shadow(0 0 8px #d4af37); }
  50% { filter: drop-shadow(0 0 20px #ffd700); }
}
.champions-text {
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 4px;
}
.champions-title {
  font-size: 22px;
  font-weight: bold;
  color: #d4af37;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.champions-congrats {
  margin-top: 12px;
  font-size: 16px;
  color: #90ee90;
  font-style: italic;
}
.my-team-champs {
  background: linear-gradient(135deg, #0f3d0f 0%, #1a4d1a 50%, #0f3d0f 100%);
  border-color: #ffd700;
  box-shadow: 0 4px 30px rgba(255, 215, 0, 0.4);
}
.my-team-champs .champions-trophy {
  animation: trophy-bounce 1s ease-in-out infinite, trophy-glow 2s ease-in-out infinite;
}
@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.world-series .ws-results-wrap { margin: 6px 0; }
.world-series table.ws-results { font-size: 12px; width: auto; }
.world-series table.ws-results th,
.world-series table.ws-results td { padding: 3px 10px; }

.manager-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 32px;
  margin: 8px 0;
}
.manager-col {
  min-width: 140px;
}
.manager-col label {
  display: block;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}

.footer {
  text-align: center;
  font-size: 12px;
  padding: 16px 0;
  color: #555;
}
.footer a { color: #333; }
.footer .btn-newgame { margin-bottom: 8px; }

.skills {
  font-size: 0.85em;
  color: #666;
  font-style: italic;
}

#year { font-weight: bold; }

/* --- Mobile / small screens --- */
@media (max-width: 768px) {
  /* Slightly larger base font for readability; layout widths unchanged */
  html {
    font-size: 17px;
  }

  .wrap {
    padding: 0 12px;
  }

  .main-layout {
    flex-direction: column;
    gap: 12px;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    order: 2;
    font-size: 13px;
  }
  .sidebar .panel {
    width: 100%;
    max-width: 100%;
  }
  .sidebar .panel h3 {
    font-size: 14px;
  }
  .sidebar table {
    font-size: 12px;
  }

  .content {
    max-width: 100%;
    order: 1;
    padding: 12px;
  }

  .header-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    min-height: auto;
  }
  .header-bar .team-name {
    font-size: 1.15em;
  }
  .header-bar .sub {
    font-size: 0.85em;
  }

  .teams-pick {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .spring-cards {
    gap: 8px;
    margin: 10px 0;
  }
  .spring-card {
    width: calc(50% - 4px);
    min-width: 0;
    padding: 4px;
  }
  .spring-card .card-head {
    padding: 4px 3px;
    margin: -4px -4px 4px -4px;
    font-size: 12px;
  }
  .spring-card .name {
    font-size: 12px;
  }
  .spring-card .pos {
    font-size: 11px;
  }
  .spring-card .stats {
    font-size: 11px;
    margin-top: 2px;
  }
  .spring-card .overall {
    padding: 3px;
    margin: 4px -4px -4px -4px;
    font-size: 18px;
  }

  table.data {
    font-size: 13px;
  }
  table.data th,
  table.data td {
    padding: 6px 4px;
  }
  .encyclopedia-section h3 {
    font-size: 15px;
  }

  .btn {
    padding: 10px 18px;
    min-height: 44px;
    font-size: 15px;
  }

  .footer {
    padding: 12px 0;
    font-size: 12px;
  }
  .roster-row .row-label {
    font-size: 14px;
  }
  .teams-pick section h3 {
    font-size: 15px;
  }
  .teams-pick label {
    font-size: 14px;
  }

  .champions-banner {
    padding: 16px;
  }
  .champions-trophy {
    font-size: 48px;
  }
  .champions-text {
    font-size: 22px;
  }
  .champions-title {
    font-size: 16px;
    letter-spacing: 1px;
  }
  .champions-congrats {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 16px;
  }
  .wrap {
    padding: 0 8px;
  }

  .banner img {
    max-width: 100%;
  }

  .spring-card {
    width: calc(50% - 4px);
    padding: 3px;
  }
  .spring-card .card-head {
    padding: 3px 2px;
    margin: -3px -3px 3px -3px;
    font-size: 11px;
  }
  .spring-card .name {
    font-size: 11px;
  }
  .spring-card .pos {
    font-size: 10px;
  }
  .spring-card .stats {
    font-size: 10px;
    margin-top: 2px;
  }
  .spring-card .overall {
    padding: 2px;
    margin: 3px -3px -3px -3px;
    font-size: 18px;
  }

  table.data {
    font-size: 12px;
  }
  table.data th,
  table.data td {
    padding: 4px 3px;
  }

  .roster-row .row-label {
    font-size: 13px;
  }

  .champions-banner {
    padding: 12px;
    margin-top: 16px;
  }
  .champions-trophy {
    font-size: 40px;
    margin-bottom: 4px;
  }
  .champions-text {
    font-size: 18px;
  }
  .champions-title {
    font-size: 14px;
    letter-spacing: 0.5px;
  }
  .champions-congrats {
    font-size: 12px;
    margin-top: 8px;
  }
}

/* Narrow viewport: allow content to shrink so layout doesn't overflow */
@media (max-width: 820px) {
  .content {
    flex: 1;
    width: auto;
    max-width: none;
  }
}

/* Scrollable tables on mobile */
@media (max-width: 768px) {
  .standings-table,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
  }
}
