:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: #09111f;
  --panel-2: #111c2f;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.24);
  --accent: #22d3ee;
  --accent-2: #facc15;
  --danger: #fb7185;
  --button: #e0f2fe;
  --button-text: #06111f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(34, 211, 238, 0.18), transparent 22rem),
    linear-gradient(180deg, #020617 0%, #07111f 100%);
  background-size: 18px 18px, 18px 18px, auto, auto;
  color: var(--text);
}

button,
input,
select,
a {
  font: inherit;
  touch-action: manipulation;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 8px max(14px, env(safe-area-inset-bottom));
}

.topbar,
.status-row,
.panel-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 10px;
}

.tv-topbar {
  padding: 8px 10px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.92));
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.38);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.05;
  text-transform: uppercase;
}

.app-footer {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 12px 4px 2px;
}

.author-line {
  margin: 0;
  color: #fef3c7;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.reset-copy {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.reset-button {
  min-width: 112px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(251, 113, 133, 0.5);
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.5);
  color: #fecdd3;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

h2 {
  font-size: 22px;
  line-height: 1.15;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.title-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cz-flag {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 17px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 3px;
  background: linear-gradient(180deg, #ffffff 0 50%, #d7141a 50% 100%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.16);
}

.cz-flag::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 56%;
  background: #11457e;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.support-top {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: #bae6fd;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-align: right;
  text-transform: uppercase;
}

.support-button {
  min-width: 84px;
  height: 34px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 8px;
  background: rgba(250, 204, 21, 0.12);
  color: #fef3c7;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.setup-panel,
.game-panel,
.support-panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 17, 31, 0.94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.support-panel {
  margin-bottom: 10px;
}

.brand-hero {
  position: relative;
  min-height: 168px;
  margin: 4px 0 16px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 8px;
  background: #020617;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.brand-hero img {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
  object-position: center;
}

.brand-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.1), rgba(2, 6, 23, 0.74));
  pointer-events: none;
}

.brand-hero-label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  display: grid;
  gap: 2px;
}

.brand-hero-label strong {
  color: #fef3c7;
  font-size: 26px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(250, 204, 21, 0.44);
}

.brand-hero-label span {
  color: #bae6fd;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.add-player-form,
.payment-box {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 8px;
}

.inline-form button,
.primary-action,
.action-row button,
.text-button,
.amount-button,
.file-control {
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 850;
}

.primary-action {
  width: 100%;
  margin-top: 14px;
}

.primary-action:disabled,
.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.setup-list,
.leaderboard {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.setup-player,
.leader-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.leader-row.active {
  border-color: rgba(45, 212, 191, 0.6);
  background: rgba(45, 212, 191, 0.1);
}

.muted,
.message,
.support-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.muted {
  margin-top: 12px;
}

.score-pill {
  display: grid;
  place-items: end;
  min-width: 96px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: #020617;
}

.score-pill span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-pill strong {
  color: #facc15;
  font-size: 31px;
  line-height: 1;
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.45);
}

.tv-status {
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.72);
}

.monitor-board {
  margin-top: 10px;
  padding: 8px;
  border: 2px solid rgba(34, 211, 238, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(14, 165, 233, 0.12), transparent 60px),
    #020617;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 34px rgba(34, 211, 238, 0.12);
  overflow: hidden;
}

.monitor-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.monitor-title strong {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.55);
}

.score-header {
  display: grid;
  grid-template-columns: repeat(10, minmax(22px, 1fr)) 58px;
  margin-bottom: 4px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 6px;
  background: #0c4a6e;
  color: #e0f2fe;
  font-size: clamp(8px, 2.4vw, 11px);
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
}

.score-header span {
  display: grid;
  place-items: center;
  min-height: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.score-header span:last-child {
  border-right: 0;
}

.scoreboard {
  display: grid;
  gap: 5px;
}

.mobile-score-card {
  display: none;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(22px, 1fr)) 58px;
  min-height: 76px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b172a, #07111f);
}

.score-row.active {
  border-color: rgba(250, 204, 21, 0.85);
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.22),
    0 0 22px rgba(250, 204, 21, 0.18);
}

.score-total,
.score-frame {
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.score-frame {
  display: grid;
  grid-template-rows: 20px 30px 26px;
  text-align: center;
  cursor: pointer;
}

.score-frame.current {
  background: rgba(250, 204, 21, 0.1);
}

.score-frame.editable:hover,
.score-frame.editing {
  outline: 2px solid rgba(34, 211, 238, 0.72);
  outline-offset: -2px;
}

.score-frame-number {
  display: grid;
  place-items: center;
  background: rgba(14, 165, 233, 0.12);
  color: #7dd3fc;
  font-size: 9px;
  font-weight: 850;
}

.score-frame-rolls,
.score-frame-total {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0 1px;
  font-weight: 900;
  line-height: 1;
}

.score-frame-rolls {
  color: #ffffff;
  font-size: clamp(12px, 3.2vw, 16px);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

.rolls-vertical {
  display: none;
}

.score-frame-total {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #bae6fd;
  font-size: clamp(12px, 3.2vw, 16px);
}

.score-total {
  display: grid;
  place-items: center;
  border-right: 0;
  background: linear-gradient(180deg, #713f12, #422006);
  color: #fef3c7;
  font-size: clamp(15px, 4.8vw, 23px);
  font-weight: 950;
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.42);
}

.throw-card {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.82);
}

.control-deck {
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.throw-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.quick-entry {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.quick-entry button {
  aspect-ratio: 1 / 0.72;
  border-radius: 8px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(180deg, #1e3a5f, #0f1c32);
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.quick-entry button.special {
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: #271300;
}

.quick-entry button.warn {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #02131f;
}

.quick-entry button:disabled {
  opacity: 0.28;
}

.message {
  min-height: 20px;
  margin-top: 10px;
}

.action-row {
  margin-top: 12px;
}

.action-row button {
  flex: 1;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
}

.result-button {
  border-color: rgba(250, 204, 21, 0.42) !important;
  background: rgba(250, 204, 21, 0.16) !important;
  color: #fef3c7 !important;
}

.result-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
}

.result-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.46);
}

.result-row strong {
  color: #facc15;
  font-size: 22px;
}

.saved-results {
  margin-top: 14px;
}

.setup-saved-results {
  margin-top: 18px;
}

.saved-results h3 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  text-transform: uppercase;
}

.saved-result {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.saved-result span {
  color: var(--muted);
  font-size: 12px;
}

.saved-result strong {
  font-size: 13px;
}

.text-button {
  min-height: 40px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.support-copy {
  margin-top: 8px;
}

.edit-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  padding: 12px;
  background: rgba(2, 6, 23, 0.64);
}

.edit-box {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(34, 211, 238, 0.34);
  border-radius: 8px;
  background: #07111f;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.5);
}

.edit-rolls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.edit-rolls select:disabled {
  opacity: 0.42;
}

.support-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.amount-button.selected {
  background: var(--accent);
  color: #042f2e;
}

.payment-link {
  display: grid;
  min-height: 50px;
  place-items: center;
  text-decoration: none;
}

.support-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.support-panel .payment-box {
  display: none;
}

.qr-slot {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: #f8fafc;
  color: #111827;
  text-align: center;
  overflow: hidden;
}

.qr-slot span {
  display: block;
  font-size: 42px;
  font-weight: 950;
}

.qr-slot img {
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: contain;
}

.file-control {
  display: grid;
  place-items: center;
  min-height: 48px;
  color: var(--button-text);
}

.file-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.link-action {
  display: grid;
  place-items: center;
  min-height: 48px;
  color: var(--button-text);
  text-decoration: none;
}

.hidden {
  display: none;
}

@media (max-width: 9999px) {
  .app-shell {
    padding-left: 3px;
    padding-right: 3px;
  }

  .game-panel {
    padding: 6px;
  }

  .monitor-board {
    padding: 3px 2px;
    overflow: visible;
  }

  .score-header {
    display: none;
  }

  .desktop-score-row {
    display: none;
  }

  .mobile-score-card {
    display: grid;
    gap: 3px;
    padding: 3px;
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 6px;
    background: linear-gradient(180deg, #0b172a, #07111f);
  }

  .mobile-score-card.active {
    border-color: rgba(250, 204, 21, 0.85);
    box-shadow:
      0 0 0 1px rgba(250, 204, 21, 0.22),
      0 0 22px rgba(250, 204, 21, 0.18);
  }

  .mobile-frame-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr)) repeat(3, minmax(0, 1.12fr)) minmax(43px, 1.68fr);
    gap: 1px;
  }

  .mobile-score-frame {
    display: grid;
    grid-template-rows: 18px 38px 28px;
    min-width: 0;
    min-height: 84px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 5px;
    background: #081426;
    color: var(--text);
    overflow: hidden;
    text-align: center;
  }

  .mobile-score-frame.current {
    background: rgba(250, 204, 21, 0.1);
  }

  .mobile-frame-number,
  .mobile-frame-rolls,
  .mobile-frame-score {
    display: grid;
    place-items: center;
    line-height: 1;
  }

  .mobile-frame-number {
    background: rgba(14, 165, 233, 0.12);
    color: #7dd3fc;
    font-size: 8.5px;
    font-weight: 850;
  }

  .mobile-frame-rolls {
    color: #ffffff;
    font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
    font-size: clamp(9.5px, 2.7vw, 11.5px);
    font-weight: 750;
    white-space: nowrap;
  }

  .mobile-frame-score {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #bae6fd;
    font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
    font-size: clamp(10px, 2.9vw, 12px);
    font-weight: 850;
    white-space: nowrap;
  }

  .quick-entry {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .edit-rolls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .monitor-board {
    padding: 3px 2px;
  }

  .mobile-score-card {
    gap: 2px;
    padding: 2px;
  }

  .mobile-frame-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) repeat(3, minmax(0, 1.16fr)) minmax(42px, 1.85fr);
    gap: 1px;
  }

  .mobile-score-frame {
    grid-template-rows: 17px 36px 26px;
    min-height: 79px;
    border-radius: 5px;
  }

  .mobile-frame-rolls {
    font-size: 10px;
  }

  .mobile-frame-score {
    font-size: 10.5px;
  }
}

@media (max-width: 360px) {
  .mobile-frame-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) repeat(3, minmax(0, 1.2fr)) minmax(40px, 2fr);
  }

  .mobile-frame-rolls {
    font-size: 9px;
  }

  .mobile-frame-score {
    font-size: 9.5px;
  }
}
