/* =========================================================================
   Casino Web – Stylesheet
   Aufbau: Grundlagen, Layout, Navigation, Bausteine, Seiten, Breakpoints
   Mobile first. Ab 900px schaltet die Oberfläche auf Desktop-Layout um.
   ========================================================================= */

:root {
  --bg: #eef2f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #b45309;
  --radius: 20px;
  --radius-sm: 14px;
  --gap: 16px;
  --shell: 620px;
  --nav-height: 0px;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(170deg, #f8fafc 0%, #eaf1fe 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

h1, h2, h3 { line-height: 1.15; }

a { color: var(--blue); }

img, svg { max-width: 100%; }

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

.app-shell {
  width: min(100%, var(--shell));
  margin-inline: auto;
  padding: 20px 16px calc(104px + env(safe-area-inset-bottom));
}

.columns { display: grid; gap: var(--gap); align-items: start; }

.hero { text-align: center; padding: 12px 4px 22px; }
.hero.compact { text-align: left; padding: 4px 0 18px; }
.hero h1 { font-size: clamp(28px, 7vw, 40px); margin: 0 0 8px; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0; }

.logo {
  width: 64px; height: 64px; margin-inline: auto;
  border-radius: 19px;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  display: grid; place-items: center;
  color: #fff; font-size: 34px;
  box-shadow: 0 14px 30px rgba(37, 99, 235, .28);
}

.eyebrow {
  font-size: 11px; letter-spacing: .18em; font-weight: 800;
  color: var(--blue); margin: 14px 0 6px;
}
.hero.compact .eyebrow { margin-top: 6px; }

.back {
  display: inline-block; margin-bottom: 6px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.back:hover { color: var(--ink); }

/* -------------------------------------------------------------- Navigation */

.topbar { display: none; }

.bottom-nav {
  position: fixed; z-index: 30; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 26px rgba(15, 23, 42, .07);
}
.bottom-nav a {
  text-decoration: none; color: #475569; text-align: center;
  font-size: 19px; padding: 4px 0; border-radius: 12px;
}
.bottom-nav a:active { background: #f1f5f9; }
.bottom-nav span { display: block; font-size: 11px; margin-top: 2px; font-weight: 600; }

/* ---------------------------------------------------------------- Bausteine */

.card, .balance-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: var(--gap);
}
.columns > .card { margin-bottom: 0; }

.balance-card { background: linear-gradient(150deg, #0f172a, #1e293b); color: #fff; }
.balance-card span, .balance-card small { display: block; color: #94a3b8; }
.balance-card strong { display: block; font-size: 32px; margin: 4px 0 6px; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.section-title h2, .card h2 { font-size: 18px; margin: 0; }
.section-title > span, .section-title > a {
  font-size: 13px; font-weight: 700; color: var(--blue); text-decoration: none;
}

.live-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--green) !important; }
.live-badge::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.hint { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.hint code { background: #e2e8f0; padding: 2px 5px; border-radius: 5px; }

.empty {
  padding: 22px; text-align: center;
  border: 1px dashed #cbd5e1; border-radius: var(--radius-sm); color: var(--muted);
}

.list { display: grid; gap: 8px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: #f8fafc; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.list-row span { display: flex; flex-direction: column; min-width: 0; }
.list-row small { color: var(--muted); margin-top: 2px; }
a.list-row:hover { border-color: #93c5fd; background: #f1f6ff; }

.red { color: var(--red); }
.green { color: var(--green); }

/* ------------------------------------------------------- Formular-Elemente */

input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
  background: #fff;
  color: var(--ink);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .45);
  outline-offset: 2px;
}

button { border: 0; font: inherit; cursor: pointer; }

.primary, .success, .danger {
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  min-height: 46px;
  color: #fff; font-weight: 700; font-size: 15px;
  white-space: nowrap;
}
.primary { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.success { background: linear-gradient(135deg, #059669, #10b981); }
.danger  { background: linear-gradient(135deg, #dc2626, #ef4444); }
.primary:hover, .success:hover, .danger:hover { filter: brightness(1.06); }
.full { width: 100%; min-height: 52px; }
button:disabled { opacity: .45; cursor: not-allowed; }

.ghost-button, .ghost {
  border-radius: var(--radius-sm); padding: 12px 16px; min-height: 46px;
  background: #f1f5f9; color: #334155; font-weight: 700; font-size: 14px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.ghost:hover, .ghost-button:hover { background: #e2e8f0; }

.icon-button {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fee2e2; color: var(--red); font-size: 22px; line-height: 1;
}
.icon-button:hover { background: #fecaca; }

.scan-form, .stack-form { display: grid; gap: 10px; }

.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.grid-form { display: grid; gap: 12px; }
.grid-form label, .field { display: grid; gap: 5px; min-width: 0; }
.grid-form label > span, .field > span {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}

.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); }

.toolbar { margin-bottom: 12px; }

/* ------------------------------------------------------------- Toasts */

.toast-stack { display: grid; gap: 8px; }
.toast-stack:not(:empty) { margin-bottom: 14px; }
.toast { padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; }
.toast.success { background: #d1fae5; color: #065f46; }
.toast.error { background: #fee2e2; color: #991b1b; }

.update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: #fef3c7; color: var(--amber); font-weight: 600;
}
.update-banner[hidden] { display: none; }

/* ----------------------------------------------------------- Stationsgrid */

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}
.station-tile {
  text-decoration: none; color: var(--ink);
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center;
  transition: transform .15s ease, border-color .15s ease;
}
.station-tile:hover { transform: translateY(-2px); border-color: #93c5fd; }
.station-tile strong { display: block; font-size: 24px; line-height: 1.1; }
.station-tile small, .station-tile em {
  display: block; color: var(--muted); font-size: 11px; font-style: normal;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-tile { border-color: rgba(245, 158, 11, .5); background: linear-gradient(150deg, #fff7ed, #ffedd5); }
.bar-tile strong { font-size: 22px; }

/* --------------------------------------------------------------- Admin-Hub */

.menu-grid {
  display: grid; gap: 12px; margin-bottom: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.menu-card {
  display: grid; gap: 3px; align-content: start;
  padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  transition: transform .15s ease, border-color .15s ease;
}
.menu-card:hover { transform: translateY(-2px); border-color: #93c5fd; }
.menu-card b { font-size: 17px; }
.menu-card small { color: var(--muted); }
.menu-card em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--blue); margin-top: 6px; }
.menu-icon { font-size: 26px; line-height: 1; margin-bottom: 6px; }

/* ------------------------------------------------ Admin-Listen (Zeilen) */

.admin-list { display: grid; gap: 12px; }

.admin-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #f8fafc; padding: 14px;
  display: grid; gap: 12px;
}
.admin-row.is-inactive { opacity: .62; background: #f1f5f9; }

.admin-row-form { display: grid; gap: 10px; }
.admin-row-form button { align-self: end; }

.admin-row-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 10px;
  font-size: 13px; color: var(--muted);
}
.admin-row-actions { display: flex; align-items: center; gap: 8px; }
.admin-row-actions .ghost { padding: 8px 14px; min-height: 40px; }

.admin-actions { display: grid; gap: 10px; }

.danger-zone {
  margin-top: 16px; padding: 16px;
  border: 1px solid #fecaca; border-radius: var(--radius-sm); background: #fff5f5;
}
.danger-zone b { color: #991b1b; }
.danger-zone .inline-form { margin-top: 10px; }

/* -------------------------------------------------------------- Rangliste */

.leaderboard { display: grid; gap: 8px; }
.leader-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: #f8fafc; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.leader-row:hover { border-color: #93c5fd; background: #f1f6ff; }
.leader-row .rank { width: 34px; font-size: 20px; font-weight: 800; text-align: center; flex: none; }
.leader-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.leader-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-row strong { font-size: 19px; font-variant-numeric: tabular-nums; }

.value-up { animation: flash-up .9s ease; }
.value-down { animation: flash-down .9s ease; }
@keyframes flash-up { 0% { color: var(--green); transform: scale(1.12); } 100% { color: inherit; transform: none; } }
@keyframes flash-down { 0% { color: var(--red); transform: scale(1.12); } 100% { color: inherit; transform: none; } }

/* ------------------------------------------------------ Punkte & Einsätze */

.score-player { padding: 14px 0; border-top: 1px solid var(--line); }
.score-player:first-of-type { border-top: 0; }
.score-player > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.score-player small { color: var(--muted); }

.direct-score { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.direct-score input { text-align: center; font-weight: 800; padding: 10px 4px; }
.score-step { min-height: 46px; border-radius: 12px; font-weight: 800; font-size: 14px; }
.score-step.negative { background: #fef2f2; color: #b91c1c; }
.score-step.positive { background: #ecfdf5; color: #047857; }

.casino-player .direct-score { grid-template-columns: repeat(3, 1fr); }
.casino-player .direct-score input { grid-column: 1 / -1; order: -1; }

.fixed-stake-box {
  margin: 14px 0 18px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f8fafc;
}
.fixed-stake-box small { display: block; margin-top: 3px; color: var(--muted); }
.fixed-stake-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.fixed-stake-controls input { grid-column: 1 / -1; }

.mode-switch-form { display: grid; gap: 10px; }
.mode-option, .winner-option {
  display: flex; align-items: center; gap: 12px;
  padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.mode-option:hover, .winner-option:hover { border-color: #93c5fd; }
.mode-option input, .winner-option input { width: 22px; height: 22px; flex: none; accent-color: var(--blue); }
.mode-option span, .winner-option span { display: grid; gap: 2px; }
.mode-option small, .winner-option small { color: var(--muted); }

.winner-card { display: grid; gap: 10px; }
.winner-card[hidden] { display: none; }
.station-winner { border-style: dashed; }

.pot-counter {
  position: sticky; bottom: 92px; z-index: 20;
  margin: 16px 0 0; padding: 14px 16px;
  border-radius: var(--radius); background: rgba(15, 23, 42, .96); color: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .3);
  display: grid; gap: 8px; backdrop-filter: blur(14px);
}
.pot-counter > span { font-size: 13px; opacity: .75; }
.pot-counter strong { font-size: 22px; }

/* -------------------------------------------------------------------- Bar */

.bar-player-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.bar-player-head h2 { margin: 0 0 2px; }
.bar-player-head span { color: var(--muted); font-weight: 700; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.product-button {
  width: 100%; min-height: 74px; padding: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, #fff7ed, #ffedd5);
  border: 1px solid #fed7aa; color: #9a3412;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  text-align: left; gap: 8px;
}
.product-button span { font-weight: 800; }
.product-button strong { font-size: 18px; }
.product-button:disabled { filter: grayscale(.4); }

/* ================================================== Breakpoint: Tablet */

@media (min-width: 640px) {
  .inline-form, .admin-actions { grid-template-columns: 1fr 1fr; }
  .inline-form { grid-template-columns: 1fr auto; }
  .grid-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
  .grid-form > label { flex: 1 1 190px; }
  .grid-form > button { flex: 0 0 auto; margin-left: auto; }
  .direct-score { grid-template-columns: repeat(5, 1fr); }
  .casino-player .direct-score {
    grid-template-columns: repeat(3, minmax(46px, 1fr)) 84px repeat(3, minmax(46px, 1fr));
  }
  .casino-player .direct-score input { grid-column: auto; order: 0; }
  .fixed-stake-controls { grid-template-columns: minmax(120px, 1fr) auto auto; }
  .fixed-stake-controls input { grid-column: auto; }
  .pot-counter { grid-template-columns: 1fr auto; align-items: center; }
  .pot-counter > span { grid-column: 1; }
  .pot-counter strong { grid-column: 1; grid-row: 2; }
  .pot-counter button { grid-column: 2; grid-row: 1 / span 2; }
  .admin-row-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
  .admin-row-form .field-name { flex: 1 1 170px; }
  .admin-row-form .field-num { flex: 0 1 104px; }
  .admin-row-form .check { flex: 0 0 auto; padding-bottom: 11px; }
  .admin-row-form > button { flex: 0 0 auto; margin-left: auto; }
}

/* ================================================= Breakpoint: Desktop */

@media (min-width: 900px) {
  :root { --shell: 1140px; --gap: 20px; }

  .bottom-nav { display: none; }

  .topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px;
    padding: 12px 28px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
  }
  .topbar-brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none;
  }
  .topbar-mark {
    width: 34px; height: 34px; border-radius: 11px;
    background: linear-gradient(135deg, #0f172a, #2563eb);
    color: #fff; display: grid; place-items: center; font-size: 18px;
  }
  .topbar-nav { display: flex; gap: 4px; }
  .topbar-nav a {
    padding: 9px 15px; border-radius: 11px;
    color: #475569; text-decoration: none; font-weight: 600; font-size: 15px;
  }
  .topbar-nav a:hover { background: #eef2ff; color: var(--blue); }

  .app-shell { padding: 28px 28px 56px; }
  .app-shell.shell-narrow { --shell: 840px; }

  .hero { text-align: left; padding: 8px 0 24px; }
  .logo { margin-inline: 0; }
  .hero .eyebrow { margin-top: 16px; }

  .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell-split .columns { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }

  .card, .balance-card { padding: 22px; }

  .station-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }

  .admin-row { padding: 16px; }

  .pot-counter { bottom: 20px; }

}

@media (min-width: 1200px) {
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------- NFC und Live */

.nfc-box {
  margin: 12px 0 4px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.nfc-box[hidden] { display: none; }
.nfc-box .hint { margin-top: 8px; }

/* Neu hinzugekommene Zeilen kurz hervorheben. */
.row-new { animation: row-in .9s ease-out; }
@keyframes row-in {
  0%   { background: rgba(5, 150, 105, .18); transform: translateY(-4px); }
  100% { background: transparent; transform: none; }
}

/* ------------------------------------------------- Einklappbare Bereiche */

.collapse-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 0; margin: 0;
  background: none; border: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
  min-height: 30px;
}
.collapse-head h2 { font-size: 18px; margin: 0; }
.collapse-icon {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: #eef2f9; color: var(--muted);
  display: grid; place-items: center;
  transition: transform .2s ease;
}
.collapse-icon::before { content: "\2013"; font-weight: 900; line-height: 1; }
.collapsible.is-collapsed .collapse-icon::before { content: "\002B"; }
.collapse-head:hover .collapse-icon { background: #e2e8f0; color: var(--ink); }
.collapse-body { margin-top: 12px; }
.collapse-body[hidden] { display: none; }

/* Einsatz der Station im Casino-Modus */

.station-stake {
  border-top: 0;
  margin-bottom: 4px; padding: 12px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.station-stake b::before { content: "\2660"; margin-right: 6px; color: var(--blue); }

/* Kleiner Zuruecksetzen-Knopf neben dem Punktestand */

.score-meta { display: inline-flex; align-items: center; gap: 8px; }
.reset-chip {
  font: inherit; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #f1f5f9; color: var(--muted);
  cursor: pointer;
}
.reset-chip:hover { background: #e2e8f0; color: var(--ink); }
.reset-chip[hidden] { display: none; }
