:root {
  --felt: #173a22; --felt2: #0f2916; --card: #f4ead2; --ink: #2a2118; --red: #b3262e; --gold: #d9a82b; --blue: #2e6fd0;
  --line: #c9b98f; --muted: #8e8468;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--felt2); color: var(--card); font: 15px/1.4 "Trebuchet MS", system-ui, sans-serif; }
body { min-height: 100vh; background: radial-gradient(circle at 50% -10%, #245a35, var(--felt2) 70%) fixed; }
.hidden { display: none !important; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 2px solid #0a1c10; background: rgba(0,0,0,.25); }
h1 { margin: 0; font: 700 22px Georgia, serif; letter-spacing: .5px; }
h1 em { color: var(--gold); font-style: italic; }
.logo { font-size: 20px; }
h2 { font: 700 26px Georgia, serif; margin: 0 0 6px; color: var(--gold); }
button { font: inherit; cursor: pointer; border: 2px solid var(--ink); background: var(--card); color: var(--ink); padding: 7px 12px; border-radius: 6px; font-weight: 700; box-shadow: 0 2px 0 rgba(0,0,0,.4); }
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); box-shadow: none; }
button.primary { background: var(--red); color: #fff; border-color: #5d1015; }
button.ghost { background: transparent; color: var(--card); border-color: #4c7a58; }
button.sel { outline: 3px solid var(--gold); }
button:disabled { opacity: .45; cursor: default; }
select { font: inherit; padding: 6px; border-radius: 6px; border: 2px solid var(--ink); background: var(--card); color: var(--ink); width: 100%; }
.panel { background: rgba(244,234,210,.07); border: 1px solid #3e6a4a; border-radius: 10px; padding: 12px; }
.screen { max-width: 1180px; margin: 0 auto; padding: 14px; }
.hero p { max-width: 70ch; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.menu-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.menu-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.muted { color: #b9c9a8; opacity: .85; } .small { font-size: 13px; margin-top: 12px; }

#game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; grid-template-areas: "board board" "field side" "log log"; }
.board { grid-area: board; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.fieldwrap { grid-area: field; position: relative; }
#field { width: 100%; height: auto; image-rendering: pixelated; border: 3px solid #0a1c10; border-radius: 10px; background: #2b6b32; display: block; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 10px; }
.logwrap { grid-area: log; }
.log { height: 190px; overflow-y: auto; font-size: 14px; }
.log div { padding: 2px 4px; border-bottom: 1px dotted rgba(255,255,255,.08); }
.log .ab { color: #fff; font-weight: 700; margin-top: 4px; } .log .draw { color: #9fd0ff; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.log .hit { color: #8be28b; } .log .big { color: var(--gold); font-weight: 700; } .log .out { color: #ffb3a6; } .log .walk { color: #b5e0ff; }
.log .run { color: #d7f0a0; } .log .dp { color: #ffd27a; font-weight: 700; } .log .err { color: #ff8da1; } .log .strat { color: #d6b5ff; } .log .sys { color: #fff; background: rgba(0,0,0,.3); } .log .dim { color: #99a98a; } .log .final { color: var(--gold); font-weight: 700; font-size: 16px; }

#linescore { border-collapse: collapse; font-family: ui-monospace, Consolas, monospace; }
#linescore th, #linescore td { padding: 3px 7px; text-align: center; border-bottom: 1px solid #3e6a4a; min-width: 26px; }
#linescore td:first-child, #linescore th:first-child { text-align: left; min-width: 120px; font-weight: 700; }
#linescore .cur { background: rgba(217,168,43,.28); }
#linescore .rhe { border-left: 2px solid #3e6a4a; font-weight: 700; }
.status { display: flex; align-items: center; gap: 14px; font: 700 18px Georgia, serif; }
.outs i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold); margin-left: 5px; } .outs i.on { background: var(--red); border-color: var(--red); }

.banner { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); background: rgba(0,0,0,.72); color: #fff; padding: 8px 22px; border: 3px solid var(--gold); border-radius: 8px; font: 700 30px Georgia, serif; letter-spacing: 1px; pointer-events: none; text-align: center; }

.matchup { display: grid; gap: 10px; }
.pcard { background: var(--card); color: var(--ink); border-radius: 8px; padding: 8px 10px; border: 2px solid #8a7b52; }
.pcard h4 { margin: 0; font: 700 15px Georgia, serif; display: flex; justify-content: space-between; gap: 6px; }
.pcard .sub { font-size: 12px; color: #5b4f35; }
.rbar { display: grid; grid-template-columns: repeat(64, 1fr); height: 12px; margin: 6px 0 4px; border: 1px solid #5b4f35; }
.rbar i { display: block; }
.leg { display: flex; flex-wrap: wrap; gap: 3px 8px; font: 11px ui-monospace, Consolas, monospace; }
.leg span b { display: inline-block; width: 9px; height: 9px; margin-right: 3px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.4); }
.rate { font: 12px ui-monospace, Consolas, monospace; color: #3b3220; margin-top: 4px; }
.c-HR { background: #d9a82b; } .c-3B { background: #e08a2b; } .c-2B { background: #7ccf4a; } .c-1B { background: #3f9a3a; } .c-W { background: #4aa3df; } .c-HBP { background: #2d6fa0; } .c-K { background: #c63a3a; } .c-OUT { background: #b9b2a0; } .c-BK { background: #9a6fc8; } .c-WP { background: #9a6fc8; } .c-PB { background: #9a6fc8; }

.facrow { display: flex; gap: 8px; min-height: 76px; align-items: center; flex-wrap: wrap; }
.fac { perspective: 400px; }
.fcard { width: 70px; height: 70px; background: #f8f1dd; color: var(--ink); border: 2px solid #5b4f35; border-radius: 7px; text-align: center; font: 700 13px ui-monospace, Consolas, monospace; display: flex; flex-direction: column; justify-content: center; animation: dealin .35s ease-out both; }
.fcard.flip { transform: rotate(180deg); }
.fcard .pb { font-size: 20px; color: var(--red); } .fcard .rn { font-size: 20px; } .fcard small { font-size: 9px; color: #7a6c48; }
.fcard.flip .inner { transform: none; }
@keyframes dealin { from { opacity: 0; translate: 0 -30px; scale: .7; } to { opacity: 1; translate: 0 0; scale: 1; } }

.controls h3 { margin: 0 0 6px; font: 700 14px Georgia, serif; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.controls .grp { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.controls .big { width: 100%; font-size: 17px; padding: 10px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 12px; }
.sheet { position: relative; background: var(--card); color: var(--ink); border: 3px solid #5b4f35; border-radius: 12px; max-width: 980px; width: 100%; max-height: 90vh; overflow: auto; padding: 16px; }
.sheet h3 { font: 700 20px Georgia, serif; margin: 0 0 8px; }
.sheet .x { position: absolute; right: 10px; top: 8px; font-size: 20px; padding: 0 9px; }
.sheet table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 14px; }
.sheet th, .sheet td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: right; } .sheet th:first-child, .sheet td:first-child { text-align: left; }
.sheet .opt { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sheet p { margin: 6px 0; }
.sheet .tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  #game { grid-template-columns: 1fr; grid-template-areas: "board" "field" "side" "log"; }
  .menu-grid { grid-template-columns: 1fr; }
  .banner { font-size: 20px; }
}

.fcard .pb, .fcard .rn { opacity: .35; font-size: 15px; } .fcard .use { opacity: 1; font-size: 24px; }
