:root{
  --board:#3E2A1E;
  --board-dark:#2A1B10;
  --parchment:#FFF4DC;
  --parchment-shadow:#E8C77A;
  --parchment-dark:#F4DFA0;
  --ink:#3E2A1E;
  --teal:#2F4F4A;
  --rust:#C0392B;
  --gold:#D9A73B;
  --gold-bright:#F4C430;
  --rope:#8B6F3F;
  --bunting-1:#C0392B;
  --bunting-2:#F4C430;
  --bunting-3:#2F4F4A;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  padding:40px 20px 80px;
  background:
    repeating-linear-gradient(45deg, rgba(192,57,43,0.05) 0px, rgba(192,57,43,0.05) 22px, transparent 22px, transparent 44px),
    radial-gradient(ellipse at center, #4A3320 0%, var(--board) 55%, var(--board-dark) 100%);
  font-family:'Nunito', sans-serif;
  color:var(--ink);
  min-height:100vh;
}
body.compact{padding-top:16px;}
.frame{max-width:1180px; margin:0 auto;}
a{color:inherit;}

/* ---- bunting strip ---- */
.predella{
  height:40px;
  margin:0 auto 28px;
  max-width:1180px;
  display:flex;
  align-items:flex-start;
  overflow:hidden;
}
.predella svg{display:block; height:100%; width:100%;}

/* ---- title plaque + nav ---- */
.title-wrap{text-align:center; margin-bottom:34px;}
.title-plaque{
  display:inline-block;
  padding:14px 46px;
  background:linear-gradient(var(--gold-bright), var(--gold));
  border:3px solid var(--parchment);
  border-radius:10px;
  box-shadow:0 8px 18px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(43,29,20,0.25);
  transform:rotate(-0.6deg);
}
.title-plaque h1{
  margin:0;
  font-family:'Fredoka', sans-serif;
  font-weight:700;
  font-size:36px;
  color:var(--ink);
  letter-spacing:0.5px;
  text-shadow:0 2px 0 rgba(255,255,255,0.35);
}
.signpost-row{
  display:flex;
  justify-content:center;
  gap:18px;
  margin-top:16px;
  flex-wrap:wrap;
}
.signpost-row-compact{margin-top:0; margin-bottom:14px;}
.signpost{
  font-family:'Baloo 2', sans-serif;
  font-weight:600;
  letter-spacing:0.5px;
  font-size:13px;
  text-decoration:none;
  color:var(--parchment);
  background:linear-gradient(#5a4128, #3E2A1E);
  border:2px solid var(--gold);
  padding:9px 20px;
  border-radius:20px;
  box-shadow:0 5px 10px rgba(0,0,0,0.4);
  transition:transform 0.15s ease, box-shadow 0.15s ease;
}
.signpost:hover{transform:translateY(-2px); box-shadow:0 8px 14px rgba(0,0,0,0.5);}
.signpost-small{opacity:0.75; font-size:12px;}
.signpost.active{
  background:linear-gradient(var(--gold-bright), var(--gold));
  color:var(--ink);
}

/* ---- pinned card base ---- */
.pin-card{
  position:relative;
  background:var(--parchment);
  border-radius:12px;
  background-image:radial-gradient(circle at 20% 30%, rgba(139,111,63,0.10) 0, transparent 45%),
                    radial-gradient(circle at 80% 70%, rgba(139,111,63,0.08) 0, transparent 40%);
  border:1px solid rgba(43,29,20,0.25);
  box-shadow:0 10px 20px rgba(0,0,0,0.45);
  padding:16px 16px 14px;
}
.pin-card::before{
  content:'';
  position:absolute;
  top:-9px; left:50%;
  transform:translateX(-50%);
  width:16px; height:16px;
  border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #d65a4a, var(--rust) 70%);
  box-shadow:0 3px 4px rgba(0,0,0,0.6);
}
.pin-card h2{
  font-family:'Baloo 2', sans-serif;
  font-size:15px;
  letter-spacing:1px;
  color:var(--rust);
  text-align:center;
  margin:2px 0 14px;
  border-bottom:1px solid var(--gold);
  padding-bottom:8px;
}

/* ---- team scroll ---- */
.team-list{clip-path:polygon(0% 1%,3% 0%,97% 0%,100% 2%,99% 98%,96% 100%,4% 100%,1% 97%);}
.team-item{
  font-size:16px;
  padding:6px 4px;
  border-bottom:1px dotted rgba(43,29,20,0.25);
}
.team-item.current{
  color:var(--rust);
  font-weight:600;
  text-decoration:underline;
  text-decoration-color:var(--gold);
}
.rope-divider{
  margin:16px -16px 10px;
  height:14px;
  background-image:repeating-linear-gradient(100deg, var(--rope) 0 6px, transparent 6px 9px);
  border-top:1px solid rgba(43,29,20,0.3);
  border-bottom:1px solid rgba(43,29,20,0.3);
}
.done-label{
  text-align:center;
  font-family:'Baloo 2', sans-serif;
  font-size:12px;
  letter-spacing:2px;
  color:var(--gold);
  margin-bottom:8px;
}
.team-item.done{
  color:var(--parchment-shadow);
  font-style:italic;
  filter:sepia(0.3);
  opacity:0.65;
}

/* ---- selection page layout ---- */
.board{
  display:grid;
  grid-template-columns:230px 1fr;
  gap:36px;
  align-items:start;
}
.pick-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding:8px 0;
  border-bottom:1px dotted rgba(43,29,20,0.2);
  flex-wrap:wrap;
}
.pick-team-name{
  width:110px;
  font-family:'Baloo 2', sans-serif;
  font-size:15px;
}
.pick-seals{display:flex; gap:6px;}
.pick-seals .seal{width:36px; height:36px; font-size:8px;}
.pick-tickets{display:flex; gap:10px; flex:1; min-width:220px; flex-wrap:wrap;}
.ticket-flat{
  min-height:auto !important;
  padding:6px 12px;
  transform:none !important;
  clip-path:none;
  border-radius:4px;
  box-shadow:0 2px 4px rgba(0,0,0,0.25);
}
.ticket-flat::before{display:none;}
.ticket-flat .ko{margin-bottom:2px;}
.ticket-flat .fixture{font-size:14px; line-height:1.25;}

/* ---- seals (WIN/LOSE/DRAW) ---- */
.seal-row{display:flex; align-items:center; gap:10px; margin-bottom:14px;}
.seal-team{width:78px; font-family:'Baloo 2', sans-serif; font-size:14px; text-align:right;}
.seal{
  width:44px; height:44px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-family:'IBM Plex Mono', monospace;
  font-size:10px; font-weight:600; letter-spacing:0.5px;
  border:2px solid var(--gold);
  background:radial-gradient(circle at 35% 30%, #efe3c0, var(--parchment-shadow) 75%);
  color:var(--ink);
  box-shadow:0 3px 5px rgba(0,0,0,0.35);
  cursor:pointer;
}
.seal.win-active{background:radial-gradient(circle at 35% 30%, #4a8f7d, var(--teal) 75%); color:var(--parchment); border-color:var(--gold-bright); box-shadow:0 0 0 2px var(--gold-bright), 0 3px 6px rgba(0,0,0,0.5);}
.seal.lose-active{background:radial-gradient(circle at 35% 30%, #a5453a, var(--rust) 75%); color:var(--parchment); border-color:var(--gold-bright); box-shadow:0 0 0 2px var(--gold-bright), 0 3px 6px rgba(0,0,0,0.5);}
.seal.draw-active{background:radial-gradient(circle at 35% 30%, #c99a3f, var(--gold) 75%); color:var(--ink); border-color:var(--gold-bright); box-shadow:0 0 0 2px var(--gold-bright), 0 3px 6px rgba(0,0,0,0.5);}
.seal.disabled{opacity:0.3; filter:grayscale(0.6); cursor:not-allowed; pointer-events:none;}
.pick-row.locked .seal, .pick-row.locked .ticket{pointer-events:none; opacity:0.55; cursor:not-allowed;}
.ticket.single{cursor:default;}
.result-mark{
  font-size:28px;
  font-weight:700;
  line-height:1;
  width:34px;
  text-align:center;
}
.result-correct{color:#2e7d4f;}
.result-wrong{color:#a5453a;}

.nav-row{
  display:flex;
  gap:16px;
  justify-content:center;
  margin-bottom:18px;
  flex-wrap:wrap;
}
.nav-chip{
  font-family:'Baloo 2', sans-serif;
  font-size:20px;
  letter-spacing:1px;
  color:var(--rust);
  background:var(--parchment-dark);
  border:1px solid var(--gold);
  border-radius:3px;
  padding:8px 16px;
  display:inline-flex;
  align-items:center;
  gap:14px;
}
.nav-chip a{
  color:var(--rust);
  font-weight:700;
  font-size:26px;
  line-height:1;
  text-decoration:none;
}
.nav-chip a:hover{color:var(--gold-bright);}
.nav-arrow-disabled{
  color:var(--parchment-shadow);
  font-size:26px;
  line-height:1;
  opacity:0.5;
}

/* ---- match tickets ---- */
.ticket{
  position:relative;
  background:var(--parchment);
  clip-path:polygon(2% 0%,98% 1%,100% 20%,97% 40%,100% 60%,98% 80%,100% 100%,0% 99%,3% 78%,0% 58%,3% 38%,0% 18%);
  padding:16px 14px 14px;
  min-height:150px;
  border:1px solid rgba(43,29,20,0.2);
  box-shadow:0 8px 16px rgba(0,0,0,0.4);
  transform:rotate(-0.4deg);
  cursor:pointer;
}
.ticket:nth-child(even){transform:rotate(0.5deg);}
.ticket::before{
  content:'';
  position:absolute; top:-8px; left:50%; transform:translateX(-50%);
  width:14px; height:14px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #d65a4a, var(--rust) 70%);
  box-shadow:0 3px 4px rgba(0,0,0,0.6);
}
.ticket.selected{background:var(--gold-bright); background-image:radial-gradient(circle at 30% 20%, rgba(255,255,255,0.35), transparent 50%);}
.ticket .ko{font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--rust); margin-bottom:8px; letter-spacing:0.5px;}
.ticket.selected .ko{color:var(--ink);}
.ticket .fixture{font-family:'Baloo 2', sans-serif; font-size:19px; line-height:1.35;}
.ticket .fixture .active-team{color:var(--rust); font-weight:600;}
.ticket.selected .fixture .active-team{color:var(--ink);}
.ticket .score{margin-top:10px; font-family:'IBM Plex Mono', monospace; font-size:13px; color:var(--teal);}
.ticket.empty{opacity:0.35; cursor:default;}
.ticket.locked{cursor:not-allowed;}

/* ---- generic plaque / button ---- */
.plaque-wrap{text-align:center; margin:36px 0 6px;}
.plaque-btn{
  display:inline-block;
  font-family:'Baloo 2', sans-serif;
  font-weight:600;
  letter-spacing:0.5px; font-size:15px;
  padding:12px 34px;
  background:linear-gradient(var(--gold-bright), var(--gold));
  border:2px solid var(--parchment);
  border-radius:24px;
  box-shadow:0 8px 16px rgba(0,0,0,0.45);
  color:var(--ink);
  cursor:pointer;
}
.plaque-btn:disabled{opacity:0.4; cursor:not-allowed;}

/* ---- form elements on parchment ---- */
.pin-card label{font-family:'Baloo 2', sans-serif; font-size:14px; display:block; margin-bottom:4px;}
.pin-card input[type=text], .pin-card input[type=password], .pin-card textarea{
  width:100%;
  font-family:'IBM Plex Mono', monospace;
  font-size:14px;
  padding:8px 10px;
  border:1px solid var(--gold);
  border-radius:3px;
  background:#fbf6e6;
  color:var(--ink);
  margin-bottom:14px;
}
.error-text{color:var(--rust); font-family:'Baloo 2', sans-serif; font-style:italic; font-size:14px;}

/* ---- player initials disk ---- */
.disk{
  width:30px; height:30px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  font-family:'IBM Plex Mono', monospace; font-size:11px; font-weight:600;
  background:radial-gradient(circle at 35% 30%, #efe3c0, var(--parchment-shadow) 75%);
  border:1.5px solid var(--gold);
  color:var(--ink);
}
.disk.win{background:radial-gradient(circle at 35% 30%, #4a8f7d, var(--teal) 75%); color:var(--parchment); border-color:var(--gold-bright);}
.disk.lose{background:radial-gradient(circle at 35% 30%, #a5453a, var(--rust) 75%); color:var(--parchment); border-color:var(--gold-bright);}
.disk.draw{background:radial-gradient(circle at 35% 30%, #c99a3f, var(--gold) 75%); color:var(--ink); border-color:var(--gold-bright);}
.disk.correct{box-shadow:0 0 0 2px var(--gold-bright);}

/* ---- week view ledger table ---- */
.matchup-table{
  width:100%;
  border-collapse:collapse;
  margin-bottom:14px;
  background:var(--parchment);
  box-shadow:0 6px 14px rgba(0,0,0,0.3);
}
.matchup-table th, .matchup-table td{
  border:1px solid var(--ink);
  padding:6px 8px;
}
.matchup-table th{
  font-family:'Baloo 2', sans-serif;
  font-size:17px;
  letter-spacing:1px;
  color:var(--rust);
  background:var(--parchment-dark);
  text-align:center;
}
.fixture-cell{
  width:200px;
  vertical-align:top;
  background:var(--parchment-dark);
}
.ko-line{
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  color:var(--rust);
  margin-bottom:4px;
}
.fixture-names{
  font-family:'Baloo 2', sans-serif;
  font-size:15px;
  line-height:1.3;
}
.outcome-cell{
  text-align:center;
  vertical-align:middle;
  min-width:90px;
}
.outcome-cell .disk{margin:3px;}
.outcome-cell.cell-correct{background:#f0d97a;}
.outcome-cell.cell-wrong{background:#e9b8ae;}

.team-label{
  font-family:'Baloo 2', sans-serif;
  font-size:19px;
  background:var(--parchment-dark);
  text-align:left;
  width:170px;
}
.team-label-header{
  background:var(--parchment-dark);
  width:170px;
  text-align:left;
  font-family:'Baloo 2', sans-serif;
  font-size:16px;
  letter-spacing:normal;
  color:var(--rust);
}

.legend{
  max-width:1180px; margin:30px auto 0; text-align:center;
  font-family:'Baloo 2', sans-serif; font-style:italic; font-size:13px;
  color:var(--parchment-shadow);
}

/* =====================================================================
   Mobile
   ===================================================================== */
@media (max-width: 640px) {
  body{padding:14px 8px 50px;}
  body.compact{padding-top:8px;}

  .title-plaque{padding:10px 22px;}
  .title-plaque h1{font-size:26px;}
  .signpost-row{gap:8px;}
  .signpost{padding:7px 12px; font-size:11px;}

  .pin-card{padding:12px 10px 10px;}

  /* Selection page: stack team list above picks instead of side by side */
  .board{grid-template-columns:1fr; gap:16px;}

  .pick-row{gap:8px; padding:7px 0;}
  .pick-team-name{width:auto; flex:1 1 90px; font-size:14px;}
  .pick-seals .seal{width:34px; height:34px; font-size:8px;}
  .pick-seals{gap:6px;}
  .pick-tickets{min-width:100%; gap:8px;}
  .ticket-flat{padding:5px 10px;}
  .ticket-flat .fixture{font-size:13px;}
  .ticket-flat .ko{font-size:10px;}
  .result-mark{font-size:22px; width:26px;}

  /* Week View ledger table: narrower columns so it fits without horizontal scroll */
  .nav-chip{font-size:16px; padding:6px 10px; gap:8px;}
  .nav-chip a{font-size:24px;}
  .nav-arrow-disabled{font-size:24px;}

  .team-label, .team-label-header{width:100px; font-size:14px; padding:5px 6px;}
  .matchup-table th{font-size:13px; padding:5px 3px;}
  .matchup-table td{padding:5px 3px;}
  .outcome-cell{min-width:56px;}
  .disk{width:26px; height:26px; font-size:9px; margin:2px;}

  .legend{font-size:11px; padding:0 6px;}
}

@media (max-width: 380px) {
  .team-label, .team-label-header{width:86px; font-size:12px;}
  .outcome-cell{min-width:48px;}
  .disk{width:23px; height:23px; font-size:8px;}
  .seal{width:36px; height:36px;}
}

/* =====================================================================
   Bottom nav (Home / Pred-In / My Circle)
   ===================================================================== */
.bottom-nav-fixed{
  position:sticky;
  bottom:0;
  z-index:100;
  background:var(--board);
  border-top:2px solid var(--gold);
  box-shadow:0 -6px 16px rgba(0,0,0,0.5);
}

.bottom-gameweek-bar{
  display:flex;
  justify-content:center;
  gap:14px;
  padding:8px 10px;
  border-bottom:1px solid rgba(184,134,59,0.4);
  flex-wrap:wrap;
}
.gw-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-family:'Baloo 2', sans-serif;
  font-size:15px;
  color:var(--parchment);
  background:rgba(239,227,192,0.08);
  border:1px solid var(--gold);
  border-radius:4px;
  padding:4px 10px;
}
.gw-arrow{
  font-size:22px;
  font-weight:700;
  color:var(--gold-bright);
  text-decoration:none;
  line-height:1;
  padding:2px 6px;
}
.gw-arrow-disabled{color:rgba(239,227,192,0.25);}
.gw-label{min-width:60px; text-align:center;}

.bottom-tab-bar{
  display:flex;
  justify-content:space-around;
  align-items:center;
  padding:6px 2px 8px;
}
.tab{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
  color:var(--parchment-shadow);
  text-decoration:none;
  font-family:'Baloo 2', sans-serif;
  font-size:11px;
  flex:1;
  padding:4px 2px;
}
.tab svg{width:24px; height:24px;}
.tab-active{color:var(--gold-bright);}
.tab-disabled{opacity:0.35; cursor:default;}

@media (max-width: 400px) {
  .gw-chip{font-size:13px; padding:3px 7px; gap:5px;}
  .gw-arrow{font-size:19px; padding:2px 4px;}
  .gw-label{min-width:50px;}
  .tab{font-size:10px;}
  .tab svg{width:21px; height:21px;}
}

/* =====================================================================
   Home page - shut the box team rail
   ===================================================================== */
.rail{
  display:flex;
  margin-top:14px;
}
.rail-track{
  position:relative;
  flex:0 0 30px;
  width:30px;
}
.rail-track::before{
  content:'';
  position:absolute;
  top:0; bottom:0; left:50%;
  transform:translateX(-50%);
  width:2px;
  background:repeating-linear-gradient(0deg, rgba(43,29,20,0.18) 0 4px, transparent 4px 9px);
}
.rail-rod{
  position:absolute;
  top:0; left:50%;
  transform:translateX(-50%);
  width:7px;
  height:0;
  border-radius:4px;
  background:linear-gradient(90deg, #4a4a4a 0%, #d8d8d8 45%, #8a8a8a 60%, #4a4a4a 100%);
  box-shadow:inset 0 0 2px rgba(255,255,255,0.7), 0 2px 5px rgba(0,0,0,0.5);
  transition:height 0.5s ease;
}
.rail-rod::before{
  content:'';
  position:absolute;
  top:-7px; left:50%;
  transform:translateX(-50%);
  width:14px; height:14px;
  border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #e8e8e8, #7a7a7a 75%);
  box-shadow:0 2px 3px rgba(0,0,0,0.5);
}
.rail-rod-knob{
  position:absolute;
  bottom:-8px; left:50%;
  transform:translateX(-50%);
  width:18px; height:18px;
  border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #d65a4a, var(--rust) 75%);
  box-shadow:0 3px 5px rgba(0,0,0,0.6), 0 0 0 2px var(--gold-bright);
}
.rail-rows{flex:1; min-width:0;}
.rail-row{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-height:42px;
  padding:6px 4px 6px 14px;
  border-bottom:1px dotted rgba(43,29,20,0.2);
}
.rail-name{
  font-family:'Baloo 2', sans-serif;
  font-size:16px;
}
.rail-row.shut{opacity:0.5;}
.rail-row.shut .rail-name{
  text-decoration:line-through;
  text-decoration-color:var(--rust);
  color:var(--parchment-shadow);
}
.rail-row.current{
  background:rgba(212,160,23,0.14);
  border-radius:4px;
}
.rail-row.current .rail-name{
  color:var(--rust);
  font-weight:600;
}
.rail-badge{
  width:22px; height:22px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700;
  background:var(--parchment);
  border:2px solid;
  flex:0 0 auto;
}
.rail-current-tag{
  font-family:'IBM Plex Mono', monospace;
  font-size:10px;
  letter-spacing:1px;
  color:var(--rust);
  border:1px solid var(--rust);
  border-radius:3px;
  padding:2px 6px;
  flex:0 0 auto;
}
.badge-correct{color:#2e7d4f; border-color:#2e7d4f;}
.badge-wrong{color:#a5453a; border-color:#a5453a;}

@media (max-width: 400px) {
  .rail-track{flex:0 0 24px; width:24px;}
  .rail-name{font-size:14px;}
  .rail-row{min-height:38px; padding:5px 4px 5px 10px;}
  .rail-badge{width:19px; height:19px; font-size:11px;}
  .rail-current-tag{font-size:9px; padding:2px 5px;}
}

/* =====================================================================
   Derby Track - landscape-only race view
   ===================================================================== */
.rotate-guard{
  display:none;
  position:fixed;
  inset:0;
  z-index:500;
  background:var(--board);
  color:var(--parchment);
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:24px;
}
.rotate-guard-inner{max-width:280px;}
.rotate-icon{font-size:48px; margin-bottom:14px; color:var(--gold-bright);}
.derby-wrap{display:block; padding:0 0 10px;}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-guard{display:flex;}
  .derby-wrap{display:none;}
}

.derby-board{
  background:linear-gradient(#e8c67a, #d9a94f 12%, #c9973c 12%, #c9973c 100%);
  border:4px solid #5a3a1e;
  border-radius:12px;
  padding:0 0 14px;
  max-width:100%;
  overflow-x:auto;
  box-shadow:0 6px 18px rgba(0,0,0,0.5);
}
.derby-title-bar{
  display:flex;
  align-items:baseline;
  gap:10px;
  justify-content:flex-start;
  background:linear-gradient(#4a2e17, #2B1D14);
  color:#f5d97a;
  padding:2px 14px;
  border-bottom:3px solid #5a3a1e;
  font-family:'Fredoka', sans-serif;
}
.derby-title-sub{
  font-family:'IBM Plex Mono', monospace;
  font-size:10px;
  color:#e8c67a;
  letter-spacing:0.5px;
}
.derby-track{display:flex; flex-direction:column; gap:4px; padding:10px 10px 0;}
.derby-lane{display:flex; align-items:center; gap:6px; border-radius:6px; padding:3px 4px;}
.derby-lane-a{background:rgba(255,255,255,0.12);}
.derby-lane-b{background:rgba(0,0,0,0.08);}
.derby-lane-me{outline:2px solid var(--gold-bright); box-shadow:0 0 0 2px rgba(212,160,23,0.4);}
.derby-lane-label{
  flex:0 0 62px;
  display:flex;
  align-items:center;
  gap:4px;
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  color:#2B1D14;
  font-weight:600;
}
.lane-name{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.lane-finished{font-size:14px;}
.derby-not-shuffled{
  font-family:'Nunito', sans-serif;
  font-style:italic;
  font-size:12px;
  color:#5a4128;
  opacity:0.75;
}
.derby-cells{display:flex; align-items:center; gap:3px;}
.derby-cell-outer{position:relative; display:flex; align-items:center; flex:0 0 auto;}
.derby-horse{
  position:absolute;
  bottom:100%; left:50%;
  transform:translateX(-50%);
  z-index:5;
  margin-bottom:-10px; /* pulls the donkey down so its shadow sits just above the box */
  filter:drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}
.derby-horse-icon{height:34px; width:auto; display:block;}
.derby-finish-line-outer{position:relative; display:flex; align-items:center; flex:0 0 auto;}
.derby-cell{
  flex:0 0 auto;
  width:36px; height:32px;
  display:flex; align-items:center; justify-content:center;
  font-family:'IBM Plex Mono', monospace;
  font-size:10px; font-weight:700;
  border-radius:5px;
  border:2px solid rgba(43,29,20,0.4);
  box-shadow:0 2px 0 rgba(43,29,20,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.derby-cell-blank{
  width:12px; height:32px;
  border:none;
  box-shadow:none;
  background:repeating-linear-gradient(45deg, rgba(43,29,20,0.08) 0 3px, transparent 3px 6px);
}
.derby-cell-wide{width:74px;}
.derby-cell-done-earlier{background:#1f5c37; color:#ffffff; border-color:#123a22;}
.derby-cell-done-this{background:#8fce9e; color:#173b20; border-color:#4f9c62;}
.derby-cell-wrong{background:#7a2e1f; color:#fbeceb; border-color:#4d1a10;}
.derby-cell-predicted{background:#d4a017; color:#3E2A1E; border-color:#a97c0f;}
.derby-cell-waiting{background:#f2e6b8; color:#5a4128; border-color:#cbb87a;}
.derby-cell-clickable{cursor:pointer;}
.derby-cell-clickable:active{transform:scale(0.95);}
.derby-popup{
  display:none;
  position:fixed;
  transform:translateX(-50%);
  z-index:50;
  background:#2B1D14;
  color:#fff;
  font-family:'Nunito', sans-serif;
  font-size:11px;
  line-height:1.4;
  padding:8px 10px;
  border-radius:8px;
  border:1px solid var(--gold);
  box-shadow:0 6px 14px rgba(0,0,0,0.5);
  max-width:320px;
  text-align:left;
  white-space:normal;
}
.derby-popup-table{
  border-collapse:collapse;
  width:100%;
}
.derby-popup-table th{
  font-family:'Baloo 2', sans-serif;
  font-size:9px;
  color:#F4C430;
  text-align:left;
  padding:2px 6px;
  border-bottom:1px solid rgba(244,196,48,0.4);
}
.derby-popup-table td{
  font-family:'IBM Plex Mono', monospace;
  font-size:10px;
  padding:3px 6px;
  border-bottom:1px solid rgba(255,255,255,0.08);
  white-space:nowrap;
}
.derby-popup-table tr:last-child td{border-bottom:none;}
.derby-finish-line{
  flex:0 0 auto;
  width:16px; height:32px;
  border-radius:3px;
  background-image:
    linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%),
    linear-gradient(45deg, #111 25%, #fff 25%, #fff 75%, #111 75%);
  background-size:6px 6px;
  background-position:0 0, 3px 3px;
  border:1px solid #111;
  position:relative;
}
.derby-finish-line span{
  position:absolute;
  left:50%; top:50%;
  transform:translate(-50%,-50%) rotate(-90deg);
  white-space:nowrap;
  background:#111;
  color:#fff;
  font-family:'IBM Plex Mono', monospace;
  font-size:8px;
  font-weight:700;
  letter-spacing:1px;
  padding:1px 4px;
  border-radius:2px;
}
.derby-legend{
  display:flex;
  flex-wrap:wrap;
  gap:10px 16px;
  margin:12px 14px 0;
  padding-top:10px;
  border-top:1px dotted rgba(43,29,20,0.3);
  font-family:'Nunito', sans-serif;
  font-size:12px;
  color:#2B1D14;
}
.legend-swatch{
  display:inline-block;
  width:12px; height:12px;
  border-radius:2px;
  margin-right:5px;
  vertical-align:middle;
  border:1px solid rgba(43,29,20,0.3);
}

.pick-missed{
  font-family:'Nunito', sans-serif;
  font-style:italic;
  font-size:12px;
  color:var(--rust);
  opacity:0.85;
  padding:6px 4px;
}

/* On wide screens, the board otherwise renders at its fixed small pixel size
   regardless of available space. Scale it up with zoom (reflows properly,
   unlike transform:scale) and let the surrounding frame widen to give it room. */
body:has(.derby-wrap) .frame{max-width:none; padding-left:24px; padding-right:24px;}

@media (min-width: 900px) and (orientation: landscape) {
  .derby-board{zoom:2.55;}
}

/* =====================================================================
   Pred-In — club card grid (replaces the old vertical pick-row list)
   ===================================================================== */
.predin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  max-width: 1040px;
  margin: 0 auto;
}
.predin-card {
  display: block;
  padding: 0;
  border-bottom: none;
  background: #FFFBF2;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.predin-card.locked { opacity: 0.6; }
.predin-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
}
.predin-badge-slot {
  flex: 0 0 auto; background: rgba(255,255,255,0.35); border: 2px dashed rgba(255,255,255,0.7);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.predin-badge-slot img { width: 100%; height: 100%; object-fit: contain; }
.predin-badge-lg { width: 44px; height: 44px; }
.predin-badge-sm { width: 30px; height: 30px; border-radius: 6px; }
.predin-header h3 { margin: 0; font-family: 'Baloo 2', sans-serif; font-size: 16px; color: #fff; }

.predin-matches { display: flex; gap: 10px; padding: 12px 14px 4px; flex-wrap: wrap; }
.predin-match {
  flex: 1; min-width: 130px; display: flex; align-items: flex-start; gap: 8px; cursor: default;
  /* neutralize the torn-paper .ticket look this element also carries, for JS compatibility */
  clip-path: none; transform: none; border: none; box-shadow: none; padding: 0; min-height: 0;
  background: rgba(43,29,20,0.05); border-radius: 8px; padding: 8px;
}
.predin-match::before { display: none; }
.ticket.predin-match { transform: none; clip-path: none; box-shadow: none; }
.predin-match.multi { cursor: pointer; }
.predin-match.selected { background: rgba(212,160,23,0.25); }
.predin-radio {
  flex: 0 0 16px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #3E2A1E; background: #fff; margin-top: 3px;
}
.predin-match.selected .predin-radio { background: #3E2A1E; box-shadow: inset 0 0 0 3px #fff; }
.predin-match-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.predin-opponent { font-size: 12px; font-weight: 700; color: #3E2A1E; }
.predin-match-main { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.predin-venue-stack { display: flex; flex-direction: column; gap: 1px; }
.predin-venue { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 15px; color: #1D5FA8; }
.predin-weekday { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 12px; color: #8a2e2e; }
.predin-opponent-badge { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 6px; }
.predin-when { font-size: 10px; color: #3E2A1E; font-family: 'IBM Plex Mono', monospace; }

.predin-picks { display: flex; gap: 8px; padding: 12px 14px 16px; justify-content: center; }
.predin-missed {
  padding: 10px 14px 16px; font-family: 'Nunito', sans-serif; font-style: italic;
  font-size: 12px; color: var(--rust); opacity: 0.85; text-align: center;
}
@media (max-width: 640px) {
  .predin-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   Home page — two-column layout (team rail + donkey generator)
   ===================================================================== */
.home-columns {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 980px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.home-rail-card, .home-donkey-card {
  flex: 1 1 320px;
  min-width: 300px;
}
.home-donkey-card h2 { text-align: center; }

.donkey-hero {
  display: flex; align-items: center; justify-content: center;
  background: rgba(43,29,20,0.06);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  min-height: 140px;
}
.donkey-hero img { max-height: 130px; max-width: 100%; }

.donkey-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-bottom: 16px;
}
.donkey-gallery-form { display: contents; }
.donkey-thumb {
  width: 52px; height: 52px; padding: 4px; border-radius: 8px;
  background: rgba(43,29,20,0.06); border: 2px solid transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.donkey-thumb.active { border-color: var(--gold-bright); background: rgba(212,160,23,0.18); }
.donkey-thumb img { max-width: 100%; max-height: 100%; }

.donkey-generate-form { border-top: 1px dotted rgba(43,29,20,0.25); padding-top: 14px; }
.donkey-label {
  display: block; font-family: 'Baloo 2', sans-serif; font-size: 13px; color: var(--ink);
  margin-bottom: 10px;
}
.donkey-label input {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px;
  border-radius: 8px; border: 1px solid rgba(43,29,20,0.3);
  font-family: 'Nunito', sans-serif; font-size: 14px; box-sizing: border-box;
}
.donkey-hint {
  text-align: center; font-size: 11px; color: var(--ink); opacity: 0.7;
  font-family: 'Nunito', sans-serif; margin: 4px 0 0;
}

@media (max-width: 720px) {
  .home-columns { flex-direction: column; }
  .home-rail-card, .home-donkey-card { width: 100%; min-width: 0; }
}

/* Derby race switcher tabs */
.derby-race-tabs{
  display:flex; flex-wrap:wrap; gap:6px;
  padding:8px 10px 0;
}
.derby-race-tab{
  display:inline-block;
  padding:5px 12px;
  border-radius:14px;
  background:rgba(43,29,20,0.15);
  color:#3E2A1E;
  font-family:'Baloo 2', sans-serif;
  font-size:11px;
  font-weight:600;
  text-decoration:none;
  border:1px solid rgba(43,29,20,0.3);
}
.derby-race-tab.mine{border-color:var(--gold-bright);}
.derby-race-tab.active{background:#3E2A1E; color:#F4C430;}

.locked-cell{
  font-family:'Nunito', sans-serif;
  font-style:italic;
  font-size:11px;
  color:var(--rust);
  text-align:center;
  vertical-align:middle;
}

.derby-popup-upcoming{color:#F4C430; font-weight:700;}
