:root {
  --felt: #2f5d4e;
  --felt-dark: #24463b;
  --wood: #9b6a3d;
  --wood-dark: #754c29;
  --wood-light: #c18a56;
  --ink: #1d1a16;
  --paper: #f5efe2;
  --danger: #9d3940;
  --gold: #e6b95f;
  --active: #4cbf87;
  --muted: #5f5a50;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 25% 15%, #ffffff1f 0, #ffffff00 35%),
    radial-gradient(circle at 75% 80%, #00000022 0, #00000000 45%),
    linear-gradient(140deg, var(--felt), var(--felt-dark));
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px 12px 32px;
}

.app-shell,
.app-shell * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.hero {
  background: linear-gradient(155deg, #f4e7cd, var(--paper));
  border: 3px solid #d4b179;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 12px 30px #1022196b;
}

.hero-top {
  position: relative;
}

.hero-top h1 {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(30px, 8vw, 42px);
  line-height: 0.95;
  letter-spacing: 0.2px;
}

.hero-top p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.collapse-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  color: #8b6f47;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10;
  pointer-events: auto;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.config {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
  opacity: 1;
}

.config.collapsed {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

.config label {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.config-row {
  display: flex;
  gap: 8px;
}

.name-fields {
  display: grid;
  gap: 8px;
}

.order-heading {
  margin: 8px 0 0;
  font-size: 15px;
  color: #5a4d3c;
  letter-spacing: 0.2px;
}

.name-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 8px;
  align-items: center;
}

.name-row-actions {
  display: flex;
  gap: 6px;
}

.order-btn {
  border: 0;
  border-radius: 10px;
  min-height: 34px;
  padding: 0 10px;
  background: linear-gradient(170deg, var(--wood-light), var(--wood));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 0 #0000002b;
  white-space: nowrap;
}

.order-btn:active {
  transform: translateY(1px);
}

.order-btn:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.name-row label {
  font-size: 13px;
  font-weight: 800;
  color: #5a4d3c;
}

.name-row input {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 2px solid #caa165;
  background: #fff8ea;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.config-help {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(79, 74, 63, 0.06);
  border-radius: 10px;
  font-size: 13px;
  color: #5a4d3c;
  line-height: 1.5;
}

.config-help p {
  margin: 6px 0;
}

.config-help strong {
  font-weight: 800;
}
  color: var(--ink);
}

.name-row input:focus {
  outline: 3px solid #4cbf8780;
  outline-offset: 1px;
}

.config select {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid #caa165;
  background: #fff8ea;
  padding: 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.wood-btn {
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
  box-shadow: 0 4px 0 #00000033;
  pointer-events: auto;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.wood-btn:active {
  transform: translateY(1px);
}

.wood-btn:focus {
  outline: none;
}

.wood-btn.secondary {
  background: linear-gradient(170deg, var(--wood-light), var(--wood));
}

.wood-btn.primary {
  background: linear-gradient(170deg, #5ed4a0, var(--active));
  min-height: 88px;
  font-size: 16px;
  line-height: 1.3;
}

.wood-btn.danger {
  background: linear-gradient(170deg, #bb4e57, var(--danger));
}

.board-zone {
  margin-top: 14px;
  background: #f5efe2;
  border-radius: 18px;
  border: 3px solid #ddbc84;
  padding: 12px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.controls:last-of-type {
  margin-top: 16px;
}

.status {
  margin: 10px 2px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.timers {
  display: grid;
  gap: 10px;
}

.timers,
.timers * {
  -webkit-user-select: none !important;
  user-select: none !important;
}

.timer-card {
  position: relative;
  border: 2px solid #dec18f;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff8eb, #f1e7d2);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.timer-card.pressing {
  box-shadow: 0 0 0 2px #5fa3d955;
}

.timer-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.timer-card.drag-over {
  border-color: #5fa3d9;
  box-shadow: 0 0 0 2px #5fa3d944;
}

.drop-indicator {
  height: 0;
  border-top: 4px solid #c72e2e;
  border-radius: 999px;
  margin: 2px 0;
  box-shadow: 0 0 0 1px #ffffffaa;
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  transform: scale(1.02);
  box-shadow: 0 14px 28px #00000040;
}

.timer-card.active {
  border-color: #47b783;
  box-shadow: 0 0 0 2px #47b78333;
}

.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
}

.meeple {
  width: 20px;
  height: 20px;
  border-radius: 6px 6px 9px 9px;
  background: var(--meeple);
  position: relative;
}

.meeple::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--meeple);
  left: 5px;
  top: -5px;
}

.timer-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.current-turn {
  font-size: 12px;
  font-weight: 700;
  color: #47b783;
}

.live-time {
  font-weight: 800;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.substats {
  margin-top: 5px;
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: #4f4a3f;
  font-weight: 700;
  flex-wrap: wrap;
}

.results {
  margin-top: 14px;
  background: #f5efe2;
  border-radius: 18px;
  border: 3px solid #ddbc84;
  padding: 12px;
}

.results h2 {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 30px;
}

.global-summary {
  margin: 5px 0 12px;
  color: #564e40;
  font-weight: 700;
}

.bars {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 8px;
  align-items: center;
}

.bar-label {
  font-weight: 800;
  font-size: 13px;
}

.bar-track {
  height: 22px;
  border-radius: 10px;
  background: #dbc8a0;
  overflow: hidden;
  border: 1px solid #c7af80;
}

.bar-fill {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  min-width: 36px;
}

.table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #ddc9a0;
  white-space: nowrap;
}

th {
  font-size: 12px;
  color: #60564a;
}

.positive {
  color: #8c2b2b;
  font-weight: 800;
}

.negative {
  color: #226c48;
  font-weight: 800;
}

.turn-log {
  margin-top: 14px;
  background: #f5efe2;
  border-radius: 18px;
  border: 3px solid #ddbc84;
  padding: 12px;
}

.turn-log h2 {
  margin: 0 0 12px 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 24px;
  color: #564e40;
}

.turn-log table {
  font-size: 14px;
}

.turn-log th {
  font-size: 13px;
  font-weight: 800;
  color: #60564a;
}

.turn-log td {
  font-weight: 600;
  color: #564e40;
}

.tip-jar {
  margin-top: 14px;
  background: #f5efe2;
  border-radius: 18px;
  border: 3px solid #ddbc84;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.tip-jar h2 {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 24px;
  color: #564e40;
}

.tip-jar p {
  margin: 0;
  color: #5a4d3c;
  font-size: 14px;
  font-weight: 700;
}

.tip-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
}

.hidden {
  display: none;
}

.timer-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.timer-btn {
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 #00000022;
  transition: transform 0.05s;
  width: 100%;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.timer-btn:active {
  transform: translateY(1px);
}

.timer-btn:focus {
  outline: none;
}

.pause-btn {
  background: linear-gradient(170deg, #5fa3d9, #4682b4);
}

.select-btn {
  background: linear-gradient(170deg, var(--wood-light), var(--wood));
}

@media (min-width: 760px) {
  .app-shell {
    padding: 22px 20px 40px;
  }

  .board-zone,
  .results,
  .hero,
  .tip-jar,
  .turn-log {
    padding: 18px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .name-row {
    grid-template-columns: 78px minmax(0, 1fr) auto;
  }
}
