/* iPad-friendly, simple & clean */
:root{
  --card-custom: var(--card);
  --card2-custom: var(--card2);
  --border-custom: var(--border);

  --table-bg: rgba(59,130,246,.18);
  --table-bg-10: rgba(59,130,246,.10);
  --table-bg-12: rgba(59,130,246,.12);
  --table-accent: #3b82f6;
  --table-accent-10: rgba(59,130,246,.10);
  --table-accent-12: rgba(59,130,246,.12);

  --bg:#0b1220;
  --card:#111a2e;
  --card2:#0f172a;
  --text:#e8eefc;
  --muted:#9fb0d0;
  --border:rgba(255,255,255,.10);
  --accent:#6ee7b7;
  --danger:#fb7185;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% 0%, #172554 0%, var(--bg) 55%);
  color:var(--text);
}

.app-header{
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: linear-gradient(to bottom, rgba(11,18,32,.92), rgba(11,18,32,.55));
  border-bottom:1px solid var(--border);
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
.title h1{margin:0;font-size:22px;letter-spacing:.2px}
.subtitle{margin:2px 0 0;color:var(--muted);font-size:12px}

.header-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.btn{
  border:1px solid var(--border);
  background: linear-gradient(to bottom, rgba(110,231,183,.18), rgba(110,231,183,.08));
  color:var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 14px;
  box-shadow: var(--shadow);
  cursor:pointer;
  touch-action: manipulation;
}
.btn:active{transform: translateY(1px)}
.btn-ghost{
  background: rgba(255,255,255,.06);
  box-shadow:none;
}

.container{
  max-width: 100%;
  margin: 14px auto 60px;
  padding: 0 14px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.card{
  background: linear-gradient(to bottom, rgba(17,26,46,.98), rgba(17,26,46,.88));
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card h2{margin:0 0 12px;font-size:16px;color:var(--text)}
.hint{margin:10px 0 0;color:var(--muted);font-size:12px}

.grid-4{
  display:grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .grid-4{grid-template-columns: 1fr 1fr}
}

.field span{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin:0 0 6px;
}
.field input{
  width:100%;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color:var(--text);
  padding: 12px 12px;
  border-radius: 14px;
  font-size: 16px;
  outline:none;
}
.field input:focus{border-color: rgba(110,231,183,.55)}

.sheet{display:flex;flex-direction:column;gap:10px}
.sheet-header,.sheet-footer{
  display:grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr .9fr;
  gap: 8px;
  padding: 8px 6px;
  color: var(--muted);
  font-size: 12px;
}
.sheet-body{
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.row{
  display:grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr .9fr;
  gap: 8px;
  align-items:center;
  padding: 8px 6px;
  border:1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
}
.row.round{
  background: rgba(110,231,183,.09);
  border-color: rgba(110,231,183,.25);
}
.row.total{
  background: rgba(255,255,255,.08);
}
.cell-label{font-weight:650;font-size:14px}
.num{
  width:100%;
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
  color:var(--text);
  padding: 10px 10px;
  border-radius: 12px;
  font-size: 16px;
  text-align:center;
}
.readonly{
  border:none;
  background: transparent;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sum{
  text-align:right;
  padding-right: 6px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-grid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .result-grid{grid-template-columns: 1fr 1fr}
}
.result-box{
  border:1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0,0,0,.18);
}
.result-box .k{color:var(--muted);font-size:12px;margin-bottom:8px}
.result-box .v{font-size:20px;font-weight:800}

.footer{
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(11,18,32,.72);
  color: var(--muted);
  text-align:center;
  backdrop-filter: blur(10px);
}

.export{display:none; background:#fff; color:#111; box-shadow:none; border:none}
.export h2{margin:0 0 6px}
.export-header{border-bottom:1px solid #ddd; padding-bottom:10px; margin-bottom:12px}
.export table{width:100%; border-collapse:collapse; font-size:12px}
.export th,.export td{border:1px solid #ddd; padding:6px 8px; text-align:center}
.export th:first-child,.export td:first-child{text-align:left}
.export-summary{margin-top:12px; font-size:12px}


.quick-buttons{
  display:flex;
  gap:4px;
  justify-content:center;
  margin-top:4px;
}
.quick-buttons button{
  font-size:12px;
  padding:4px 6px;
  border-radius:8px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.08);
  color:var(--text);
}
.quick-buttons button:active{
  transform:translateY(1px);
}


.player-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 820px){
  .player-grid{grid-template-columns: 1fr}
}

.player-card{
  border:1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0,0,0,.18);
}
.player-name{
  font-weight: 850;
  font-size: 16px;
  margin-bottom: 10px;
}
.player-metrics{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.player-metrics span{
  display:block;
  color:var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.player-metrics strong{
  font-size: 18px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.overall-grid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .overall-grid{grid-template-columns: 1fr 1fr}
}

/* input cell to allow buttons under each player's number */
.cell{
  display:flex;
  flex-direction:column;
  align-items:stretch;
}


/* Plus / Minus visual distinction */
.round-section.plus .row{
  background: rgba(110,231,183,.12);
  border-color: rgba(110,231,183,.35);
}
.round-section.plus .row.round{
  background: rgba(110,231,183,.22);
}

.round-section.minus .row{
  background: rgba(251,113,133,.12);
  border-color: rgba(251,113,133,.35);
}
.round-section.minus .row.round{
  background: rgba(251,113,133,.22);
}


/* Sticky name header (below app header) */
.sticky-names{
  position: sticky;
  top: 72px; /* height of app header */
  z-index: 9;
}

/* Sticky results footer */
.sticky-results{
  position: sticky;
  bottom: 14px;
  z-index: 9;
}


/* 5-column input grid */
.grid-5{
  display:grid;
  grid-template-columns: 1.2fr .9fr 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .grid-5{grid-template-columns: 1fr 1fr}
}

/* Bigger +/- buttons for touch */
.quick-buttons{
  gap:6px;
  margin-top:6px;
}
.quick-buttons button{
  font-size:14px;
  padding:10px 10px;
  min-width:54px;
  border-radius:12px;
  font-weight:800;
}


body{padding-bottom: 90px;}

.sum.invalid{
  color: var(--danger);
  text-shadow: 0 0 10px rgba(251,113,133,.25);
}
.sum.valid{
  color: var(--accent);
  text-shadow: 0 0 10px rgba(110,231,183,.25);
}

/* Sticky areas should be opaque */
.sticky-names, .sticky-results{
  background: var(--card);
}

/* Larger typography for iPad */
body{ font-size: 18px; }
.title h1{ font-size: 26px; }
.subtitle{ font-size: 14px; }

.card h2{ font-size: 18px; }

.field span{ font-size: 13px; }
.field input{ font-size: 18px; padding: 14px 14px; }

.cell-label{ font-size: 16px; }
.num{ font-size: 18px; padding: 12px 10px; }
.sum{ font-size: 16px; }

.player-metrics strong{ font-size: 20px; }
.quick-buttons button{ font-size: 16px; min-width: 60px; padding: 12px 10px; }

.btn{ font-size: 16px; padding: 12px 16px; }


/* -------- PDF Export styling (pretty) -------- */
.export.pretty{
  display:none;
  background:#ffffff;
  color:#0f172a;
  box-shadow:none;
  border:none;
  border-radius: 0;
  padding: 18px;
}

.export.pretty .export-header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 16px;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.export.pretty .export-header h2{
  margin:0;
  font-size: 18px;
  letter-spacing: .2px;
}
.export.pretty .export-header p{
  margin:0;
  font-size: 11px;
  color:#475569;
}

.export.pretty table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size: 11px;
  overflow:hidden;
  border:1px solid #e5e7eb;
  border-radius: 12px;
}
.export.pretty th{
  background:#0f172a;
  color:#ffffff;
  font-weight:800;
  padding: 8px 8px;
  text-align:center;
  border-bottom:1px solid #0b1220;
}
.export.pretty th:first-child{ text-align:left; }
.export.pretty td{
  padding: 7px 8px;
  border-bottom:1px solid #e5e7eb;
  text-align:center;
}
.export.pretty td:first-child{ text-align:left; font-weight:700; }
.export.pretty tr:last-child td{ border-bottom:none; }

/* colored sections */
.export.pretty tr.plus td{ background: rgba(16,185,129,.10); }
.export.pretty tr.minus td{ background: rgba(244,63,94,.10); }

/* highlight subtotal/total rows */
.export.pretty tr.subtotal td{
  background:#f1f5f9;
  font-weight:900;
}
.export.pretty tr.totalplus td{
  background: rgba(16,185,129,.16);
  font-weight:900;
}
.export.pretty tr.totalminus td{
  background: rgba(244,63,94,.16);
  font-weight:900;
}
.export.pretty tr.end td{
  background: var(--table-bg-12);
  font-weight:900;
}
.export.pretty tr.euro td{
  background:#0f172a;
  color:#ffffff;
  font-weight:900;
}

/* nice summary chips */
.export.pretty .export-summary{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 12px;
}
.export.pretty .export-chip{
  border:1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  background:#f8fafc;
}
.export.pretty .export-chip .k{ color:#475569; font-size:11px; margin-bottom:6px; }
.export.pretty .export-chip .v{ font-size:16px; font-weight:900; }
.export.pretty .export-chip.good{ background: rgba(16,185,129,.10); }
.export.pretty .export-chip.bad{ background: rgba(244,63,94,.10); }
.export.pretty .export-chip.blue{ background: var(--table-bg-10); }


/* -------- A4 one-page PDF compaction -------- */
.export.pretty{
  padding: 12px;
}
.export.pretty .export-header{
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.export.pretty .export-header h2{
  font-size: 16px;
}
.export.pretty table{
  font-size: 10px;
}
.export.pretty th,
.export.pretty td{
  padding: 5px 6px;
}
.export.pretty .export-summary{
  margin-top: 8px;
  gap: 6px;
}
.export.pretty .export-chip{
  padding: 6px 8px;
}
.export.pretty .export-chip .v{
  font-size: 13px;
}

/* Avoid page breaks inside table */
.export.pretty table,
.export.pretty tr,
.export.pretty td,
.export.pretty th{
  page-break-inside: avoid;
}

/* Spieler & Faktor should NOT be sticky */
.sticky-names{
  position: static !important;
}

/* Center player names in column headers */
.sheet-header .sum{
  text-align: center;
}


/* Keep top title bar sticky and opaque */
.app-header{
  background: var(--bg);
  backdrop-filter: none;
}

/* Center numbers in summary rows (round + total rows) */
.row.round .sum,
.row.total .sum{
  text-align: center;
  padding-right: 0;
}

/* ---------- PDF Export v2: one-page A4 + nicer header ---------- */
.export.pretty{
  padding: 10px;
  background: #ffffff;
}
.export.pretty .export-header{
  border-bottom: none;
  margin-bottom: 8px;
  padding-bottom: 0;
}
.export.pretty .export-header{
  display:block;
}
.export.pretty .export-titlebar{
  border-radius: 12px;
  padding: 10px 12px;
  background: #0f172a;
  color:#ffffff;
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap: 10px;
  margin-bottom: 8px;
}
.export.pretty .export-titlebar h2{
  margin:0;
  font-size: 15px;
  letter-spacing:.2px;
}
.export.pretty .export-titlebar p{
  margin:0;
  font-size: 10px;
  opacity:.9;
}

/* tighter table */
.export.pretty table{ font-size: 9.5px; border-radius: 10px; }
.export.pretty th{ padding: 6px 6px; font-size: 9.5px; }
.export.pretty td{ padding: 4px 6px; }

/* 4 chips in one row */
.export.pretty .export-summary{
  margin-top: 6px;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  font-size: 10px;
}
.export.pretty .export-chip{
  padding: 6px 8px;
}
.export.pretty .export-chip .k{ font-size: 9px; margin-bottom: 4px; }
.export.pretty .export-chip .v{ font-size: 11.5px; }

/* Strongly discourage page breaks */
@media print{
  .export.pretty{ page-break-after: avoid; }
}

/* Always-visible top header */
.app-header{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  width: 100%;
}

/* Add top offset so content isn't hidden behind fixed header */
.container{
  margin-top: 92px;
}


/* -------- PDF Export: back to v9 look (no bottom summary) -------- */
.export.pretty .export-titlebar{ display:none !important; } /* in case leftover */
.export.pretty .export-summary{ display:none !important; }  /* remove 'Summen ganz unten' */

.export.pretty{
  padding: 18px !important;
}
.export.pretty .export-header{
  display:flex !important;
  align-items:flex-end !important;
  justify-content:space-between !important;
  gap: 16px !important;
  border-bottom: 2px solid #e5e7eb !important;
  padding-bottom: 12px !important;
  margin-bottom: 14px !important;
}
.export.pretty .export-header h2{
  margin:0 !important;
  font-size: 18px !important;
  letter-spacing: .2px !important;
}
.export.pretty .export-header p{
  margin:0 !important;
  font-size: 11px !important;
  color:#475569 !important;
}

/* v9 table sizing */
.export.pretty table{
  font-size: 11px !important;
}
.export.pretty th,
.export.pretty td{
  padding: 7px 8px !important;
}


/* --- PDF export: ensure nothing is cut off on the left --- */
.export.pretty{
  /* A4 width is 210mm. With margins 8mm each side => 194mm content */
  width: 194mm;
  max-width: 194mm;
  margin: 0 auto;
  padding-left: 6mm !important;
  padding-right: 6mm !important;
}
.export.pretty table{
  width: 100%;
  table-layout: fixed;
}
.export.pretty th, .export.pretty td{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* PDF export safety: keep within page width */
.export.pretty{
  box-sizing: border-box;
  width: 190mm;
  max-width: 190mm;
  margin: 0;
}


/* Center-align rightmost Summe column */
.sheet-header > :last-child,
.row > :last-child{
  text-align: center;
  padding-right: 0;
}


/* --- Summe column: perfect vertical alignment + visual separation --- */
.sheet-header > :last-child,
.row > :last-child{
  text-align: center;
  font-variant-numeric: tabular-nums; /* align digits vertically */
}

/* Subtle background + divider for Summe column */
.row > :last-child{
  background: rgba(255,255,255,0.06);
  border-left: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
}

/* Stronger emphasis for round/total rows */
.row.round > :last-child,
.row.total > :last-child{
  background: rgba(255,255,255,0.12);
  font-weight: 900;
}


/* --- Sticky column header (player names) --- */
.sheet-header{
  position: sticky;
  top: 92px; /* below fixed app header */
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-top: 10px;
  padding-bottom: 10px;
}


/* ---- Larger typography (v20) ---- */
body{ font-size: 20px; }
.title h1{ font-size: 30px; }
.card h2{ font-size: 20px; }

.sheet-header{ font-size: 16px; }
.cell-label{ font-size: 18px; }
.num{ font-size: 20px; }
.sum{ font-size: 18px; }

.player-name{ font-size: 18px; }
.player-metrics strong{ font-size: 22px; }

.btn{ font-size: 18px; }
.quick-buttons button{ font-size: 18px; }


/* ---- Theme customization ---- */
:root{
  --bg-custom: var(--bg);
  --text-custom: var(--text);
}

body{
  background: var(--bg-custom);
  color: var(--text-custom);
}

:root{
  --font-scale: 1;
}


.select{
  width:100%;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color:var(--text-custom, var(--text));
  padding: 12px 12px;
  border-radius: 14px;
  font-size: 18px;
  outline:none;
}
.select:focus{border-color: rgba(110,231,183,.55)}

input[type="range"]{
  width:100%;
}

.field.actions{
  display:flex;
  flex-direction:column;
}
.field.actions button{
  width:100%;
}

/* Scale typography with --font-scale (overrides) */
body{ font-size: calc(20px * var(--font-scale)); }
.title h1{ font-size: calc(30px * var(--font-scale)); }
.card h2{ font-size: calc(20px * var(--font-scale)); }

.sheet-header{ font-size: calc(16px * var(--font-scale)); }
.cell-label{ font-size: calc(18px * var(--font-scale)); }
.num{ font-size: calc(20px * var(--font-scale)); }
.sum{ font-size: calc(18px * var(--font-scale)); }

.player-name{ font-size: calc(18px * var(--font-scale)); }
.player-metrics strong{ font-size: calc(22px * var(--font-scale)); }

.btn{ font-size: calc(18px * var(--font-scale)); }
.quick-buttons button{ font-size: calc(18px * var(--font-scale)); }


/* Collapsible theme/settings panel */
.theme-panel{
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1.2fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .theme-panel{ grid-template-columns: 1fr 1fr; }
}


/* Top input grid (Spieler & Faktor) */
.grid-top{
  display:grid;
  grid-template-columns: 1.3fr .9fr 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .grid-top{grid-template-columns: 1fr 1fr}
}

.design-row{
  margin-top: 10px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Collapsible theme/settings panel (fixed) */
.theme-panel{
  margin-top: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}


/* Header dropdown for design settings */
.theme-dropdown{
  position: fixed;
  top: 60px; /* below header */
  left: 0;
  right: 0;
  z-index: 60;
  padding: 10px 14px;
}
.theme-dropdown-inner{
  max-width: 1100px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px;
}
.theme-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 820px){
  .theme-grid{grid-template-columns: 1fr}
}

/* Settings: top row (Layout | Spieler | Standard) */
.theme-toprow{
  grid-column: 1 / -1;
  display:flex;
  gap: 10px;
  align-items: flex-start;
}
.theme-toprow .toprow-item{
  flex: 1;
  min-width: 220px;
}
.theme-toprow .toprow-actions{
  flex: 0 0 auto;
  display:flex;
  align-items: flex-end;
}

/* Row: background + text color next to font slider */
.color-row{
  display:flex;
  gap: 10px;
}
.color-row .field{flex: 1; min-width: 0;}

/* Names all next to each other */
.name-row{
  grid-column: 1 / -1;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 820px){
  .name-row{grid-template-columns: 1fr 1fr;}
}
.theme-actions{
  margin-top: 10px;
  display:flex;
  justify-content:flex-end;
}


/* Use configurable table background for the names header row */
.sheet-header{
  background: var(--table-bg-12) !important;
}


/* Themeable surfaces */
.card{
  background: var(--card-custom) !important;
  border-color: var(--border-custom) !important;
}
/* some elements use --card directly; force key sticky/headers to use custom surfaces */
.sticky-results,
.theme-dropdown-inner{
  background: var(--card-custom) !important;
}


/* Design popout should always use standard colors */
.theme-dropdown-inner{
  background: var(--card) !important;
  color: var(--text) !important;
}
.theme-dropdown-inner .select,
.theme-dropdown-inner input{
  color: var(--text) !important;
}


/* Apply chosen text color ONLY to the scoring table (not header/result/settings) */
#sheet .sheet-header,
#sheet .sheet-body,
#sheet .sheet-footer,
#sheet .sheet-header *,
#sheet .sheet-body *,
#sheet .sheet-footer *{
  color: var(--text-custom) !important;
}

#sheet input,
#sheet select,
#sheet textarea{
  caret-color: var(--text-custom);
}

/* Score inputs: look like text, no caret */
input.score{
  caret-color: transparent;
}


/* ===== PDF Export: high contrast, minimal color (v38) ===== */
.export.pretty table{
  border: 1px solid #111827 !important;
  border-radius: 10px !important;
}
.export.pretty th{
  background:#111827 !important;
  color:#ffffff !important;
  border-bottom: 1px solid #111827 !important;
}
.export.pretty td{
  color:#0f172a !important;
  background:#ffffff !important;
  border-bottom: 1px solid #cbd5e1 !important;
}
/* No colored fills for normal rows */
.export.pretty tr.plus td,
.export.pretty tr.minus td{
  background:#ffffff !important;
}
/* Only "header-like" rows get subtle tints */
.export.pretty tr.subtotal td{
  background:#e2e8f0 !important;
  font-weight: 900 !important;
}
.export.pretty tr.totalplus td{
  background:#dcfce7 !important;
  font-weight: 900 !important;
}
.export.pretty tr.totalminus td{
  background:#ffe4e6 !important;
  font-weight: 900 !important;
}
.export.pretty tr.end td{
  background:#dbeafe !important;
  font-weight: 900 !important;
}
.export.pretty tr.euro td{
  background:#111827 !important;
  color:#ffffff !important;
  font-weight: 900 !important;
  border-bottom: none !important;
}


/* ===== PDF Export: remove dark blue frame (v40) ===== */
.export.pretty table{
  border: 1px solid #cbd5e1 !important; /* light gray instead of dark blue */
}
.export.pretty th{
  border-bottom: 1px solid #cbd5e1 !important;
}


/* ===== PDF Export: remove dark blue backgrounds completely (v41) ===== */
.export.pretty th,
.export.pretty tr.euro td{
  background:#ffffff !important;
  color:#0f172a !important;
}


/* ===== PDF Export: grayscale everywhere, color only for Total+/Total- (v42) ===== */
.export.pretty th{
  background: #f1f5f9 !important;  /* light gray */
  color: #0f172a !important;
  border-bottom: 1px solid #cbd5e1 !important;
}
.export.pretty td{
  background: #ffffff !important;
  color: #0f172a !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

/* Header-like rows in grayscale */
.export.pretty tr.subtotal td{
  background:#e2e8f0 !important; /* gray */
  font-weight: 900 !important;
}
.export.pretty tr.end td{
  background:#e5e7eb !important; /* gray */
  font-weight: 900 !important;
}
.export.pretty tr.euro td{
  background:#f1f5f9 !important; /* gray */
  color:#0f172a !important;
  font-weight: 900 !important;
}

/* Keep ONLY these two rows as colored accents */
.export.pretty tr.totalplus td{
  background:#dcfce7 !important; /* green accent */
  font-weight: 900 !important;
}
.export.pretty tr.totalminus td{
  background:#ffe4e6 !important; /* red accent */
  font-weight: 900 !important;
}

/* Ensure no other colored fills survive */
.export.pretty tr.plus td,
.export.pretty tr.minus td{
  background:#ffffff !important;
}


/* Score cells are display-only (no keyboard) */
.score-display{
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}


/* Locked rows: buttons disabled */
.quick-buttons.locked button{
  opacity: .35;
}
.cell.locked .score-display{
  opacity: .7;
}





/* ===== iPhone layout (portrait, one-hand friendly) ===== */
body.layout-iphone{
  --font-scale: 1.10;
}

/* No sticky/fixed areas on iPhone */
body.layout-iphone header,
body.layout-iphone .sheet-header,
body.layout-iphone .sticky-results,
body.layout-iphone .theme-dropdown{
  position: static !important;
  top: auto !important;
  bottom: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

/* Full-width, vertical stacking */
body.layout-iphone .container{
  width: 100%;
  max-width: 100%;
  padding: 10px 10px 18px;
}
body.layout-iphone .card{
  border-radius: 18px;
  padding: 12px;
}
body.layout-iphone h1{
  font-size: calc(20px * var(--font-scale));
  line-height: 1.1;
}
body.layout-iphone h2{
  font-size: calc(17px * var(--font-scale));
}

/* Header buttons bigger + wrap */
body.layout-iphone .header-actions{
  gap: 8px;
  flex-wrap: wrap;
}
body.layout-iphone .btn{
  padding: 12px 14px;
  font-size: calc(15px * var(--font-scale));
}
body.layout-iphone .btn.btn-ghost{
  border-radius: 14px;
}

/* Design popout becomes in-flow section */
body.layout-iphone .theme-dropdown-inner{
  max-width: 100%;
  border-radius: 18px;
}
body.layout-iphone .theme-grid{
  grid-template-columns: 1fr 1fr;
}

/* Top grid (player/factor) more vertical */
body.layout-iphone .grid-top{
  grid-template-columns: 1fr;
}
body.layout-iphone .grid-top .field input{
  font-size: calc(17px * var(--font-scale));
}

/* Table: horizontal scroll with momentum; columns tighter */
body.layout-iphone #sheet{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
}
body.layout-iphone table{
  min-width: 620px; /* smaller than iPad version for portrait */
}
body.layout-iphone th,
body.layout-iphone td{
  padding: 8px 8px;
  font-size: calc(15px * var(--font-scale));
  white-space: nowrap;
}
body.layout-iphone .col-sum{
  min-width: 64px;
}

/* Score display and +/- controls: bigger touch targets, 2x2 grid */
body.layout-iphone .score-display{
  font-size: calc(18px * var(--font-scale));
  min-width: 2.2em;
}
body.layout-iphone .quick-buttons{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
body.layout-iphone .quick-buttons button{
  padding: 12px 0;
  font-size: calc(16px * var(--font-scale));
  border-radius: 14px;
}

/* Locked state still readable */
body.layout-iphone .quick-buttons.locked button{
  opacity: .25;
}


/* 4-player mode toggles */
.player4-only{ display:none; }
body.players-4 .player4-only{ display:block; }

/* Sitout (4 players): show dash and hide buttons */
.score-display.sitout{ opacity:.55; font-weight:800; }
.cell.sitout .quick-buttons{ display:none !important; }


/* 4 Spieler: keine Summenspalte (letzte Spalte ist Spieler 4) */
body.players-4 .sheet-header,
body.players-4 .sheet-footer,
body.players-4 .row{
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
}


/* Summe-Chip (nur bei 4 Spielern, statt eigener Summenspalte) */
.row-sum-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-left: 10px;
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
}
.row-sum-chip.valid{
  background: rgba(34,197,94,.16);
  border-color: rgba(34,197,94,.28);
}
.row-sum-chip.invalid{
  background: rgba(239,68,68,.16);
  border-color: rgba(239,68,68,.28);
}


/* 4 Spieler: die letzte Spalte ist ein Spieler, nicht die Summe -> entferne Summe-Hervorhebung */
body.players-4 .sheet-header > :last-child,
body.players-4 .row > :last-child{
  background: transparent !important;
  border-left: none !important;
  border-radius: 0 !important;
  font-weight: 900 !important;
}

.head-cell{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 10px 10px;
  font-weight: 900;
  text-align:center;
}
.head-cell.head-sum{
  background: rgba(255,255,255,0.06);
  border-left: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
}

.row.subtotal .sum,
.row.total .sum,
.row.totalplus .sum,
.row.totalminus .sum,
.row.end .sum,
.row.euro .sum{
  text-align:center;
  padding-right:0;
}


/* 3 Spieler: 1 Label + 3 Spieler-Spalten (Summe im Label) */
body.players-3 .row{
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
}

/* Summe-Badge im Label */
.row-sum-badge{
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .2px;
}
.row-sum-badge.ok{
  background: rgba(22, 163, 74, .18);
  color: rgba(22, 163, 74, 1);
  border: 1px solid rgba(22, 163, 74, .35);
}
.row-sum-badge.bad{
  background: rgba(220, 38, 38, .16);
  color: rgba(220, 38, 38, 1);
  border: 1px solid rgba(220, 38, 38, .35);
}

/* Header cells for players */
.sheet-header .head-cell{
  justify-content: center;
}

/* Header alignment for 3/4 players */
body.players-3 .sheet-header{
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
}
body.players-4 .sheet-header{
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
}
/* Bold + centered header names */
.sheet-header .head-cell{
  font-weight: 900 !important;
  justify-content: center;
  text-align: center;
}

/* Settings panel sections */
.theme-divider{
  grid-column: 1 / -1;
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 6px 0;
}
.theme-section-title{
  grid-column: 1 / -1;
  font-weight: 900;
  letter-spacing: .2px;
  opacity: .95;
  padding-top: 2px;
}
header .icon{
  margin-right: 6px;
}


/* ---------- PDF/Export: higher contrast, clean look ---------- */
#exportArea{
  background: #ffffff;
  color: #0b0f19;
}

#exportArea table{
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.2;
}

#exportArea th, #exportArea td{
  border: 1px solid #1f2937;
  padding: 4px 6px;
  color: #0b0f19;
}

#exportArea thead th{
  background: #0b3a6a; /* strong blue */
  color: #ffffff;
  font-weight: 900;
  text-align: center;
}

#exportArea tbody td:first-child{
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

#exportArea tbody td{
  text-align: center;
}

/* Subtotal / Total highlighting in grayscale */
#exportArea tr.subtotal td{
  background: #f3f4f6;
  font-weight: 900;
}
#exportArea tr.end td,
#exportArea tr.euro td{
  background: #f9fafb;
  font-weight: 900;
}

/* Accent only for Total Plus / Total Minus */
#exportArea tr.totalplus td{
  background: #eaf7ee;
  font-weight: 900;
}
#exportArea tr.totalminus td{
  background: #fdecec;
  font-weight: 900;
}

/* Make the export area itself compact to fit on one page */
#exportArea .export-header,
#exportArea #exportMeta,
#exportArea #exportSummary{
  display: none !important;
}

/* Export PDF header */
.export-pdf-header{
  font-weight: 900;
  font-size: 14px;
  color: #111827;
  margin: 0 0 8px 0;
  padding: 6px 8px;
  border: 1px solid #111827;
  background: #f3f4f6;
}

.cloud-status{
  grid-column: 1 / -1;
  font-weight: 800;
  opacity: .95;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.08);
}
.cloud-status.ok{ background: rgba(22,163,74,.14); color: rgba(22,163,74,1); }
.cloud-status.bad{ background: rgba(220,38,38,.14); color: rgba(220,38,38,1); }

.cloud-list{
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-bottom: 6px;
}
.cloud-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.06);
}
.cloud-item strong{ font-weight: 900; }
.cloud-item .meta{ opacity: .9; font-size: 12px; }
.cloud-item .actions{ display:flex; gap: 8px; }

/* Cloud stats + fixed-size history items */
.cloud-stats{
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.06);
}
.cloud-stats h3{
  margin: 0 0 8px 0;
  font-weight: 900;
  font-size: 14px;
}
.cloud-stats .row{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-top: 1px solid rgba(0,0,0,.08);
}
.cloud-stats .row:first-of-type{ border-top: none; }
.cloud-stats .name{ font-weight: 900; }
.cloud-stats .val{ font-variant-numeric: tabular-nums; font-weight: 800; }

.cloud-item{
  height: 58px;              /* fixed height */
  overflow: hidden;
}
.cloud-item > div:first-child{
  min-width: 0;              /* allow ellipsis in flex */
}
.cloud-item strong{
  display:block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cloud-item .meta{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* --- Cloud block: keep same size, no growth --- */
.cloud-status{
  height: 58px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  overflow:hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cloud-stats{
  max-height: 220px;
  overflow: auto;
}
.cloud-list{
  max-height: 260px;
  overflow: auto;
}
.cloud-item{
  height: 58px;
}
.cloud-item .actions .btn{
  padding: 10px 12px;
}
.cloud-item .actions .btn-danger{
  border: 1px solid rgba(220,38,38,.35);
  background: rgba(220,38,38,.14);
  color: rgba(220,38,38,1);
}

/* Popover panels */
.popover{
  position: fixed;
  top: 74px;
  right: 12px;
  z-index: 60;
  width: min(520px, calc(100vw - 24px));
}
.popover-card{
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(18, 24, 40, .96);
  backdrop-filter: blur(10px);
}
.popover-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.popover-title{
  font-weight: 900;
  font-size: 14px;
}
#statsPanel .cloud-stats{
  max-height: 360px;
  overflow: auto;
}


/* Status feedback in header */
.header-actions{ align-items:center; }
.header-status{ min-width: 180px; margin-left: .5rem; font-size: .9em; opacity: .9; }
@media (max-width: 720px){ .header-status{ display:none; } }
