: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;
}

/* top site banner line */
.site-banner{
  width: 100%;
  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;
  letter-spacing: .2px;
}

/* Top bar */
.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}
.brand{ flex:1; min-width:0; }
.brand-spacer{ height: 1px; }

/* buttons */
.actions{
  display:flex;
  align-items:flex-start;
  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;
  user-select:none;
}
.btn:hover{ filter: brightness(1.1); }
.btn:active{ transform: translateY(1px); }
.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;
  white-space:nowrap;
}
.logo-upload input{ color: var(--muted); font-size: 12px; max-width: 220px; }
.check{ display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none; }

/* Sheet Manager */
.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;
}

.ver{ font-size: 12px; color: var(--muted); font-weight: 900; margin-left: 6px; }

/* 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;
  letter-spacing:.2px;
  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;
}

/* locked logo */
.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;
  -webkit-user-drag: none;
  user-select:none;
}
.logo-placeholder{
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-align:center;
  line-height:1.1;
}

/* Layout */
.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;
}
.sheet-header{ align-items:center; }
.panel-title{ margin:0; font-size: 14px; font-weight: 900; }
.panel-sub{ margin: 0; font-size: 12px; color: var(--muted); }

/* Library controls */
.library-controls{
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.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;
}

.group-row{ display:flex; gap: 8px; align-items:center; padding: 0 0 10px; }
.group-chips{ display:flex; gap: 6px; flex-wrap:wrap; min-width:0; flex:1; }
.chip{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  cursor:pointer;
  font-size: 11px;
  font-weight: 900;
}
.chip.active{ background: rgba(88,139,255,.18); border-color: rgba(88,139,255,.45); }

.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); }

.filters{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-bottom: 10px;
}

/* Library scroll */
.library-body{
  padding: 8px;
  height: 520px;
  overflow:auto;
}
@media (max-width:980px){ .library-body{ height: 320px; } }

/* Library: compact rows */
.play-card{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px 7px;
  background: rgba(10, 18, 35, .32);
  margin-bottom: 5px;
}
.play-top{ display:flex; flex-direction:column; gap: 2px; }
.play-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
  width:100%;
}
.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); }

.inline-item.form{
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.inline-item.key{
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.1;
  white-space: normal;
}

/* edit button on each play row */
.play-actions{
  display:flex;
  gap:6px;
  flex:0 0 auto;
}
.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;
}
.smallbtn:hover{ filter: brightness(1.1); }

/* 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-left{ display:flex; align-items:center; gap:8px; min-width:0; }

.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 */
.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 row */
.dropped-play{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:6px;
  padding: 3px 5px;

  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 1px solid rgba(255,255,255,.14);
  border-radius: 0;

  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); }

.dropped-left{
  display:flex;
  gap:5px;
  min-width:0;
  align-items:center;
  flex:1;
}

.reorder-handle{
  width: 16px;
  height: 16px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  display:grid;
  place-items:center;
  font-weight: 900;
  cursor: grab;
  user-select:none;
  flex:0 0 auto;
  margin-top: 2px;
  font-size: 10px;
}

.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;
  flex:0 0 auto;
  font-size: 12px;
  line-height: 1;
}

/* MORE ROOM for play name (single line) */
.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;
}

/* Opponent notes bottom */
.cat-note{
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}
.cat-note textarea{
  width: 100%;
  min-height: 44px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  outline:none;
}

/* Main 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 (optional) */
.script-wrap{ margin-top: 10px; }
.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 */
@media print{
  body{ background:#fff; color:#000; }
  .no-print, .grid, .topbar, .game-header { display:none !important; }
  #printView{ display:block !important; }
  .app{ margin:0; padding:0; }
  #printView{ padding-bottom: 28px !important; }

  .print-list li{
    padding: 2px 4px;
    border-bottom: 1px solid #000;
  }
  .print-li-run{ background: #dff5e2; }
  .print-li-pass{ background: #dbeeff; }
  .print-li-st{ background: #fff3cd; }
}

#printView{
  display:none;
  padding: 18px;
  font-family: Arial, Helvetica, sans-serif;
  color:#000;
  position: relative;
  min-height: 10in;
}
.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{
  page-break-inside: avoid;
  break-inside: avoid;
  border: 2px solid #000;
  padding: 8px;
  background: #f3f5f7;
}
.print-box h3{
  margin: 0 0 4px;
  font-size: 13px;
  padding: 5px 6px;
  border: 2px solid #000;
  background: #e6ebf2;
}

.print-oppnote{
  margin: 0 0 6px;
  font-size: 11px;
  font-style: italic;
}

.print-grid{ display:grid; gap: 10px; }
.print-columns{ display:flex; gap: 10px; align-items:flex-start; }
.print-col{ flex: 1; display:flex; flex-direction:column; gap: 10px; min-width: 0; }

/* print row split: Play | Formation */
.print-list{ display:block; margin:0; padding-left: 18px; }
.print-list li{
  margin: 3px 0;
  font-size: 11px;
  line-height: 1.2;

  display:flex;
  justify-content:space-between;
  align-items:center;
  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-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 pinned to bottom */
.print-footer{ display:none; }
@media print{
  .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);
    letter-spacing: .2px;
  }
}

/* Preview modal */
.preview-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 9999;
}
.preview-overlay.open{ display:flex; }

.preview-modal{
  width: min(1100px, 100%);
  height: min(90vh, 900px);
  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;
  display:flex;
  flex-direction:column;
}
.preview-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
}
.preview-meta{ color: var(--muted); font-size: 12px; font-weight: 700; }
.preview-actions{ display:flex; gap: 8px; }

.preview-canvas{
  background: #111;
  padding: 12px;
  overflow:auto;
  flex: 1;
}
.preview-page{
  background: #fff;
  color:#000;
  margin: 0 auto 14px;
  box-shadow: 0 10px 35px rgba(0,0,0,.35);
  border-radius: 8px;
  overflow:hidden;
  padding: 18px;
}
.preview-page.portrait3{ width: 8.5in; }
.preview-page.landscape6{ width: 11in; }
.preview-page.wristband{ width: 8.5in; }
@media (max-width: 900px){
  .preview-page.portrait3,
  .preview-page.landscape6,
  .preview-page.wristband{ width: 100%; }
}

/* PLAY 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(640px, 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 b{ font-size: 14px; }
.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,
.pm-field textarea{
  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;
}
.pm-field textarea{
  grid-column: 1 / -1;
  min-height: 80px;
  resize: vertical;
}

.pm-groups{
  grid-column: 1 / -1;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.03);
}
.pm-groups .title{
  font-size: 12px;
  font-weight: 950;
  color: var(--muted);
  margin-bottom: 8px;
}
.pm-groups .list{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
}
.pm-check{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  padding: 6px 10px;
  border-radius: 999px;
  cursor:pointer;
  user-select:none;
  font-size: 12px;
  font-weight: 800;
}

.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;
  flex-wrap:wrap;
}
