 :root{
  --bg:#0b1220;
  --text:#e9eefb;
  --muted:#a7b4d6;
  --line:rgba(255,255,255,.10);
  --shadow: 0 10px 30px rgba(0,0,0,.30);

  --run-bg: rgba(76, 175, 80, .16);
  --pass-bg: rgba(33, 150, 243, .16);
  --st-bg: rgba(255, 193, 7, .16);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color:var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(88, 139, 255,.25), transparent 55%),
              radial-gradient(900px 500px at 80% 0%, rgba(255, 88, 175,.15), transparent 50%),
              var(--bg);
}
.app{ max-width: 1200px; margin: 18px auto 50px; padding: 0 14px; }

/* dropdown readability */
select{
  background:#000 !important;
  color:#fff !important;
  border:1px solid rgba(255,255,255,.18) !important;
}
select option{ background:#000 !important; color:#fff !important; }

.site-banner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-weight: 950;
}
.site-banner .right{ display:flex; align-items:center; gap:10px; }
.site-banner .name{ font-weight: 950; }
.site-banner .ver{ font-size: 12px; color: var(--muted); font-weight: 900; }
.demo-pill{
  font-size: 11px;
  font-weight: 950;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,80,80,.14);
  border: 1px solid rgba(255,80,80,.30);
}

.topbar{ display:flex; align-items:flex-start; justify-content:flex-end; margin-bottom: 10px; }
.actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.btn{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor:pointer;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 13px;
}
.btn:hover{ filter: brightness(1.1); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{
  opacity:.45;
  cursor:not-allowed;
  box-shadow:none;
}
.btn-small{ padding: 8px 10px; font-size: 12px; box-shadow:none; }
.btn-danger{
  border-color: rgba(255,80,80,.35) !important;
  background: rgba(255,80,80,.10) !important;
}
.btn-primary{
  border-color: rgba(88,139,255,.45) !important;
  background: rgba(88,139,255,.18) !important;
}

.logo-upload{
  display:flex; align-items:center; gap:8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  padding: 8px 10px;
  border-radius: 12px;
}
.logo-upload label{ font-size: 12px; color: var(--muted); font-weight: 700; }
.logo-upload input{ color: var(--muted); font-size: 12px; max-width: 220px; }

.sheet-manager{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 12px;
  padding: 8px 10px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.sm-title{ font-size: 11px; font-weight: 950; color: var(--muted); }
.sm-row{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
#sheetSelect{
  min-width: 220px;
  max-width: 320px;
  border-radius: 10px;
  padding: 7px 8px;
}

.demo-banner{
  border: 1px solid rgba(255,80,80,.35);
  background: rgba(255,80,80,.12);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  font-size: 12px;
  margin-bottom: 10px;
}

/* Game info header */
.game-header{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow);
}
.game-header-inner{
  display:grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.game-info{
  display:grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  align-items:end;
}
@media (max-width: 980px){
  .game-info{ grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

.field label{
  display:block;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input{
  width:100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
  outline:none;
}

.logo-box{
  width: 120px; height: 60px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  padding: 6px;
  display:flex; align-items:center; justify-content:center;
  box-shadow: var(--shadow);
  pointer-events: none;
  user-select: none;
}
.logo-box img{ max-width: 100%; max-height: 100%; object-fit: contain; display:none; }
.logo-placeholder{ font-size: 11px; color: var(--muted); font-weight: 800; }

.grid{
  display:grid;
  grid-template-columns: 360px 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}
@media (max-width: 980px){ .grid{ grid-template-columns: 1fr; } }

.panel{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.panel-header{
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 10px;
}
.panel-title{ margin:0; font-size: 14px; font-weight: 900; }
.panel-sub{ margin: 0; font-size: 12px; color: var(--muted); }

.lib-mini{
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}

.library-controls{
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.tabs{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom: 10px; }
.tab{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 999px;
  cursor:pointer;
  font-size: 12px;
  font-weight: 900;
}
.tab.active{ background: rgba(88,139,255,.18); border-color: rgba(88,139,255,.45); }
.count{ margin-left: 6px; font-size: 11px; font-weight: 900; color: var(--muted); }

.search-row{ display:flex; gap: 8px; align-items:center; padding-bottom: 10px; }
#playSearch{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--text);
  padding: 9px 10px;
  font-size: 12px;
  outline:none;
}

.filters{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-bottom: 10px;
}

.library-body{
  padding: 8px;
  height: 520px;
  overflow:auto;
}
@media (max-width:980px){ .library-body{ height: 320px; } }

/* compact play rows */
.play-card{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px 7px;
  background: rgba(10, 18, 35, .32);
  margin-bottom: 5px;
}
.play-row{ display:flex; align-items:center; justify-content:space-between; gap: 8px; }
.play-inline{ display:flex; align-items:center; gap: 8px; min-width:0; flex:1; }
.drag-name{
  display:inline-flex; align-items:center;
  cursor: grab;
  user-select:none;
  padding: 3px 5px;
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,.18);
  background: rgba(255,255,255,.04);
  min-width:0;
}
.drag-name span{
  font-size: 12px;
  font-weight: 900;
  max-width: 210px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.pill{
  font-size: 9px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
}
.pill.run{ background: rgba(76,175,80,.18); }
.pill.pass{ background: rgba(33,150,243,.18); }
.pill.st{ background: rgba(255,193,7,.18); }

.form{
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.smallbtn{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 10px;
  cursor:pointer;
  font-weight: 900;
  font-size: 11px;
}

/* Sheet */
.sheet-body{ padding: 10px 10px 12px; }
.sheet-actions{ display:flex; gap:8px; }

.sheet-columns{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width:980px){ .sheet-columns{ grid-template-columns: 1fr; } }

.category{
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow:hidden;
  background: rgba(10, 18, 35, .25);
  min-height: 150px;
  display:flex;
  flex-direction:column;
}
.category-head{
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
}
.cat-title-input{
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  color: #fff;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 950;
  outline:none;
}
.cat-count{ font-size: 11px; font-weight: 900; color: var(--muted); white-space:nowrap; }

.cat-actions{ display:flex; gap:6px; align-items:center; }
.iconbtn{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 10px;
  cursor:pointer;
  display:grid;
  place-items:center;
  font-weight: 900;
}

.dropzone{
  padding: 8px;
  display:flex;
  flex-direction:column;
  gap: 4px;
  min-height: 110px;
}
.dropzone.dragover{
  outline: 2px solid rgba(88,139,255,.65);
  outline-offset: -2px;
  background: rgba(88,139,255,.10);
}

.dropped-play{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:6px;
  padding: 3px 5px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.03);
}
.dropped-play.type-run{ background: var(--run-bg); }
.dropped-play.type-pass{ background: var(--pass-bg); }
.dropped-play.type-st{ background: var(--st-bg); }

.sheet-row{
  display:grid;
  grid-template-columns: 1fr 88px;
  gap: 4px;
  align-items:center;
  min-width:0;
  width:100%;
  font-size: 10px;
  line-height: 1.05;
}
.sheet-name{
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.sheet-form{
  font-size: 9px;
  font-weight: 900;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-align: right;
}
.xbtn{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  width: 18px;
  height: 18px;
  border-radius: 7px;
  cursor:pointer;
  display:grid;
  place-items:center;
  font-weight: 900;
  font-size: 12px;
  line-height: 1;
}

/* notes */
.notes-wrap{
  display:flex;
  flex-direction:column;
  gap:8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 18, 35, .25);
  padding: 10px;
  margin-top: 10px;
}
.notes-wrap label{ font-weight: 900; font-size: 12px; color: var(--muted); }
textarea{
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: #fff;
  padding: 10px;
  font-size: 13px;
  outline:none;
}
.script-toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-top: 10px;
}
.script-toggle .hint{ font-size: 12px; color: var(--muted); font-weight: 800; }

/* print area */
#printView{ display:none; padding: 18px; font-family: Arial, Helvetica, sans-serif; color:#000; position: relative; }
.print-top{ border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; position: relative; min-height: 78px; }
.print-logo-box{ position:absolute; top:0; right:0; width:120px; height:60px; padding:6px; display:flex; align-items:center; justify-content:center; border:none !important; }
.print-logo-box img{ max-width:100%; max-height:100%; object-fit:contain; display:none; }
.print-title{ margin:0; font-size:22px; font-weight:900; }
.print-sub{ margin: 4px 0 0; font-size: 12px; }
.print-game{ margin-top: 8px; display:grid; grid-template-columns: repeat(4, 1fr); gap: 10px; font-size: 12px; }
.print-box{ border: 2px solid #000; padding: 8px; background:#f3f5f7; margin-bottom:10px; }
.print-box h3{ margin:0 0 4px; font-size:13px; padding:5px 6px; border:2px solid #000; background:#e6ebf2; }
.print-list{ margin:0; padding-left: 18px; }
.print-list li{ margin:3px 0; font-size:11px; line-height:1.2; display:flex; justify-content:space-between; gap:10px; }
.print-play-name{ flex:1 1 auto; white-space:nowrap; overflow:hidden; text-overflow:clip; }
.print-play-form{ flex:0 0 120px; text-align:right; white-space:nowrap; overflow:hidden; text-overflow:clip; font-weight:700; }
.print-li-run{ background:#dff5e2; }
.print-li-pass{ background:#dbeeff; }
.print-li-st{ background:#fff3cd; }
.print-notes{ margin-top: 12px; border: 1px solid #000; padding:10px; }
.print-notes h3{ margin:0 0 8px; font-size:14px; border-bottom:1px solid #000; padding-bottom:6px; }
.print-notes p{ margin:0; font-size:12px; white-space:pre-wrap; }
.print-footer{ display:none; }

@media print{
  body{ background:#fff; color:#000; }
  .no-print, .grid, .topbar, .game-header, .demo-banner, .site-banner { display:none !important; }
  #printView{ display:block !important; }
  .print-footer{
    display:block !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 6px;
    text-align: center;
    font-size: 9px;
    color: rgba(0,0,0,.65);
  }
}

/* modal */
.play-modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.70);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 10000;
}
.play-modal-overlay.open{ display:flex; }
.play-modal{
  width: min(520px, 100%);
  background: #0e1730;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  box-shadow: 0 25px 80px rgba(0,0,0,.55);
  overflow: hidden;
}
.play-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
}
.play-modal-head .sub{
  display:block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}
.play-modal-body{
  padding: 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px){ .play-modal-body{ grid-template-columns: 1fr; } }
.pm-field label{
  display:block;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  margin-bottom: 6px;
}
.pm-field input, .pm-field select{
  width:100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.35);
  color: #fff;
  padding: 9px 10px;
  font-size: 13px;
  outline:none;
}
.play-modal-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
}
.pm-actions{ display:flex; gap:8px; }
