/* ============================================
   stichzettel.de — Mobile-First CSS
   ============================================ */

:root {
  --c-bg:           #F6F1EA;
  --c-surface:      #FFFFFF;
  --c-primary:      #1B4332;
  --c-primary-h:    #2D6A4F;
  --c-accent:       #D4A017;
  --c-success:      #2D9E65;
  --c-danger:       #C0392B;
  --c-text:         #1A1A1A;
  --c-text-muted:   #6B6B6B;
  --c-border:       #DDD6CA;
  --c-shadow:       0 2px 8px rgba(0,0,0,0.08);
  --c-shadow-lg:    0 4px 20px rgba(0,0,0,0.12);
  --radius:         12px;
  --radius-sm:      8px;
  --radius-pill:    999px;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --max-w:          640px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

img { display: block; max-width: 100%; }

/* ---- Layout ---- */

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Site Header ---- */

.site-header {
  background: var(--c-primary);
  color: #fff;
  padding: 16px 0 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo span { opacity: 0.7; font-weight: 400; font-size: 0.9rem; margin-left: 4px; }

.header-back {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-back::before { content: '←'; }

/* ---- Search ---- */

.search-wrap {
  margin: 20px 0 12px;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--c-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 14px center;
  outline: none;
  transition: border-color .15s;
}

.search-input:focus { border-color: var(--c-primary); }

/* ---- Filter Tabs ---- */

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 7px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-pill);
  background: var(--c-surface);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  color: var(--c-text-muted);
  transition: all .15s;
}

.filter-btn.active, .filter-btn:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: rgba(27,67,50,0.05);
}

.filter-btn.active {
  background: var(--c-primary);
  color: #fff;
}

/* ---- Games Grid ---- */

.games-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-bottom: 32px;
}

.game-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  box-shadow: var(--c-shadow);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 2px solid transparent;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}

.game-card--live {
  cursor: pointer;
}

.game-card--live:hover, .game-card--live:active {
  border-color: var(--c-primary);
  transform: translateY(-1px);
  box-shadow: var(--c-shadow-lg);
}

.game-card--soon {
  opacity: 0.6;
  cursor: default;
}

.game-emoji {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 4px;
}

.game-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

.game-players {
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-top: 6px;
}

.badge--live {
  background: rgba(45,158,101,0.15);
  color: var(--c-success);
}

.badge--soon {
  background: rgba(107,107,107,0.12);
  color: var(--c-text-muted);
}

/* ---- Game Page: App Shell ---- */

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px 40px;
  min-height: calc(100dvh - 60px);
}

/* ---- Setup Screen ---- */

.setup-screen {
  padding-top: 24px;
}

.setup-screen h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.setup-screen .subtitle {
  color: var(--c-text-muted);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--c-surface);
  outline: none;
  transition: border-color .15s;
}

.player-input:focus { border-color: var(--c-primary); }

.btn-icon {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}

.btn-icon--remove {
  background: rgba(192,57,43,0.1);
  color: var(--c-danger);
}

.btn-icon--remove:hover { background: rgba(192,57,43,0.2); }

.btn-add-player {
  width: 100%;
  padding: 11px;
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--c-text-muted);
  font-family: var(--font);
  transition: all .15s;
}

.btn-add-player:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

/* ---- Buttons ---- */

.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}

.btn--primary {
  background: var(--c-primary);
  color: #fff;
}

.btn--primary:hover { background: var(--c-primary-h); }
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--secondary {
  background: transparent;
  color: var(--c-primary);
  border: 2px solid var(--c-primary);
}

.btn--secondary:hover { background: rgba(27,67,50,0.06); }

.btn--danger {
  background: transparent;
  color: var(--c-danger);
  border: 2px solid transparent;
  font-size: 0.875rem;
  padding: 10px;
}

.btn--small {
  width: auto;
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .btn { flex: 1; }

/* ---- Round Header / Score Summary ---- */

.round-header {
  background: var(--c-primary);
  color: #fff;
  margin: 0 -16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.round-header .round-info { font-weight: 700; font-size: 1rem; }
.round-header .round-meta { opacity: 0.75; font-size: 0.82rem; }

/* ---- Score Leaderboard ---- */

.leaderboard {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--c-shadow);
  overflow: hidden;
  margin-top: 16px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}

.leaderboard-row:last-child { border-bottom: none; }

.leaderboard-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-text-muted);
  flex-shrink: 0;
}

.leaderboard-rank--1 { background: #FFD700; color: #7A5800; }
.leaderboard-rank--2 { background: #C0C0C0; color: #444; }
.leaderboard-rank--3 { background: #CD7F32; color: #fff; }

.leaderboard-name { flex: 1; font-weight: 600; }
.leaderboard-dealer { font-size: 0.75rem; color: var(--c-accent); font-weight: 600; }

.leaderboard-score {
  font-size: 1.2rem;
  font-weight: 800;
  min-width: 48px;
  text-align: right;
}

.score-delta {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

.score-delta--pos { color: var(--c-success); }
.score-delta--neg { color: var(--c-danger); }
.score-delta--zero { color: var(--c-text-muted); }

/* ---- Stepper ---- */

.player-input-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.player-input-row {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--c-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-input-row .name {
  flex: 1;
  font-weight: 600;
}

.player-input-row .hint {
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper__btn {
  width: 44px; height: 44px;
  border: none;
  background: var(--c-bg);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
  flex-shrink: 0;
  font-weight: 300;
}

.stepper__btn:hover { background: var(--c-border); }
.stepper__btn:active { background: var(--c-primary); color: #fff; }
.stepper__btn:disabled { opacity: 0.35; cursor: not-allowed; }

.stepper__val {
  width: 44px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
  padding: 0 4px;
  line-height: 44px;
}

/* ---- Phase indicator ---- */

.phase-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--c-shadow);
  margin-top: 16px;
  text-align: center;
}

.phase-card h2 { font-size: 1.1rem; margin-bottom: 4px; }
.phase-card p { color: var(--c-text-muted); font-size: 0.875rem; }

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-muted);
  margin: 20px 0 8px;
}

/* ---- Kniffel Scoresheet ---- */

.score-sheet {
  margin-top: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  box-shadow: var(--c-shadow);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-surface);
  font-size: 0.875rem;
  min-width: 260px;
}

.score-table th {
  background: var(--c-primary);
  color: #fff;
  padding: 10px 12px;
  text-align: center;
  font-size: 0.8rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.score-table th:first-child {
  text-align: left;
  min-width: 140px;
  position: sticky;
  left: 0;
  background: var(--c-primary);
  z-index: 2;
}

.score-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--c-border);
  text-align: center;
  vertical-align: middle;
}

.score-table td:first-child {
  text-align: left;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  background: var(--c-surface);
  position: sticky;
  left: 0;
  border-right: 2px solid var(--c-border);
}

.score-table tr.section-row td {
  background: #F0EDE6;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
  padding: 6px 12px;
}

.score-table tr.total-row td {
  background: var(--c-primary);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  border-bottom: none;
}

.score-table tr.total-row td:first-child {
  background: var(--c-primary);
  color: #fff;
}

.score-table tr.bonus-row td {
  background: rgba(212,160,23,0.1);
  font-weight: 600;
}

.score-cell {
  cursor: pointer;
  min-width: 56px;
  height: 40px;
  font-weight: 600;
  transition: background .1s;
  border-radius: 4px;
}

.score-cell:hover { background: rgba(27,67,50,0.06); }

.score-cell--filled {
  color: var(--c-primary);
  cursor: pointer;
  position: relative;
}

.score-cell--filled::after {
  content: '✎';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: .6rem;
  opacity: 0;
  transition: opacity .15s;
}

.score-cell--filled:hover::after { opacity: 0.4; }

.score-cell--empty { color: var(--c-border); }

.score-cell--active { background: rgba(27,67,50,0.08); }

/* ---- Modal / Score entry ---- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: var(--max-w);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  animation: slide-up .2s ease;
}

@keyframes slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal h3 { font-size: 1rem; margin-bottom: 4px; }
.modal .modal-hint { color: var(--c-text-muted); font-size: 0.85rem; margin-bottom: 16px; }

.num-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.num-btn {
  flex: 1 1 calc(25% - 8px);
  min-width: 60px;
  padding: 14px 8px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .1s;
  font-family: var(--font);
  text-align: center;
}

.num-btn:hover, .num-btn.selected {
  border-color: var(--c-primary);
  background: var(--c-primary);
  color: #fff;
}

.num-btn--strich {
  border-color: var(--c-danger);
  color: var(--c-danger);
}

.num-btn--strich:hover {
  background: var(--c-danger);
  color: #fff;
}

/* ---- Results Screen ---- */

.results-screen {
  padding-top: 24px;
  text-align: center;
}

.winner-badge {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.results-screen h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.results-screen .winner-name {
  color: var(--c-primary);
}

.results-screen .sub {
  color: var(--c-text-muted);
  margin-bottom: 24px;
  font-size: 0.875rem;
}

/* ---- History Table ---- */

.history-section {
  margin-top: 24px;
  text-align: left;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: var(--c-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--c-shadow);
}

.history-table th {
  background: #EDE9E2;
  padding: 8px 10px;
  font-weight: 700;
  color: var(--c-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  text-align: center;
}

.history-table td:first-child { text-align: left; font-weight: 600; }
.history-table tr:last-child td { border-bottom: none; }

/* ---- Legal disclaimer ---- */

.legal-note {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  padding: 16px 0 8px;
  text-align: center;
  line-height: 1.5;
}

/* ---- Site Footer ---- */

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 20px 0;
  margin-top: 40px;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

.site-footer a:hover { color: var(--c-primary); }

/* ---- Toast notification ---- */

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.15); opacity: .7; }
}

/* ---- Constraint counter (e.g. Wizard tricks) ---- */

.constraint-banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.constraint-banner--ok    { background: rgba(45,158,101,.12); color: #166534; }
.constraint-banner--warn  { background: rgba(212,160,23,.15); color: #92400e; }
.constraint-banner--error { background: rgba(192,57,43,.12);  color: #991b1b; }

.constraint-banner .cb-num {
  font-size: 1.5rem;
  font-weight: 800;
  min-width: 40px;
  text-align: center;
}

.constraint-banner .cb-label { flex: 1; font-size: .85rem; font-weight: 600; }
.constraint-banner .cb-icon  { font-size: 1.2rem; }

/* ---- Per-player status badge (scoring feedback) ---- */

.status-badge {
  font-size: .78rem;
  font-weight: 700;
  min-width: 52px;
  text-align: center;
  padding: 4px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.status-badge--ok    { background: rgba(45,158,101,.12); color: #166534; }
.status-badge--warn  { background: rgba(212,160,23,.15); color: #92400e; }
.status-badge--error { background: rgba(192,57,43,.12);  color: #991b1b; }
.status-badge--neu   { background: var(--c-bg);          color: var(--c-text-muted); }

/* ---- Step pill ---- */

.step-pill {
  display: inline-block;
  background: rgba(255,255,255,.2);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 600;
  opacity: .9;
}

/* ---- Bid-sum hint ---- */

.bid-sum-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.bid-sum-hint--eq   { background: rgba(45,158,101,.1);  color: #166534; }
.bid-sum-hint--over { background: rgba(212,160,23,.1);  color: #92400e; }
.bid-sum-hint--under{ background: var(--c-bg); color: var(--c-text-muted); }

/* ---- Info / Details accordion ---- */

.game-info {
  margin-top: 8px;
}

.game-info summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 11px 14px;
  background: var(--c-surface);
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  box-shadow: var(--c-shadow);
  user-select: none;
  transition: background .15s;
}

.game-info summary:hover { background: var(--c-bg); }

.game-info summary::after {
  content: '▼';
  font-size: .65rem;
  margin-left: auto;
  transition: transform .2s;
  opacity: .5;
}

.game-info[open] summary {
  border-radius: var(--radius) var(--radius) 0 0;
}

.game-info[open] summary::after { transform: rotate(-180deg); }

.game-info summary::-webkit-details-marker { display: none; }

.game-info .info-body {
  background: var(--c-surface);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px 16px 16px;
  font-size: .875rem;
  line-height: 1.65;
  color: var(--c-text);
  box-shadow: var(--c-shadow);
  border-top: 1px solid var(--c-border);
}

.game-info .info-body h3 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-muted);
  margin: 14px 0 4px;
  font-weight: 700;
}

.game-info .info-body h3:first-child { margin-top: 0; }

.game-info .info-body ul {
  padding-left: 18px;
  margin: 4px 0 6px;
}

.game-info .info-body li { margin-bottom: 4px; }

.game-info .info-body a {
  display: inline-block;
  margin-top: 10px;
  color: var(--c-primary);
  font-weight: 600;
  font-size: .82rem;
  text-decoration: none;
}

.game-info .info-body a:hover { text-decoration: underline; }

/* ---- Hidden helper ---- */
.hidden { display: none !important; }

/* ---- Desktop tweaks ---- */
@media (min-width: 480px) {
  .games-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 640px) {
  .games-grid { grid-template-columns: repeat(4, 1fr); }
  .modal { border-radius: var(--radius); }
}
