:root {
  --bg-top: #163222;
  --bg-bottom: #09110d;
  --panel: rgba(14, 27, 20, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f7f3e8;
  --text-soft: #c7d1c7;
  --accent-us: #ffd166;
  --accent-them: #7bd389;
  --danger-soft: #ff7b7b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  --app-max-width: 1100px;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 209, 102, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(123, 211, 137, 0.15), transparent 22%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
label,
input,
.btn,
.score-btn,
.nav-btn,
.view-shortcut {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.game-view-mode {
  overflow: hidden;
}

.app-shell {
  min-height: 100vh;
}

.app-header,
.app-main {
  position: relative;
  z-index: 1;
}

.app-main {
  max-width: var(--app-max-width);
}

.hero-panel,
.actions-panel,
.history-panel,
.welcome-panel,
.settings-panel,
.settings-block,
.status-card,
.team-card {
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-panel {
  padding: 1.25rem;
}

.main-nav,
.welcome-actions,
.game-toolbar-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav-btn.is-active {
  color: #08110c;
  background: #f7f3e8;
  border-color: #f7f3e8;
}

.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.app-title {
  font-size: clamp(1.9rem, 6vw, 3rem);
  line-height: 1;
}

.app-subtitle,
.actions-help,
.history-empty,
.history-meta,
.status-label,
.section-head,
.team-kicker,
.settings-help {
  color: var(--text-soft);
}

.wake-lock-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.toolbar-badge {
  min-width: 5.4rem;
  text-align: center;
}

.app-view {
  animation: fade-in 180ms ease;
}

.welcome-view {
  min-height: calc(100vh - 12rem);
  display: grid;
  place-items: center;
}

.welcome-panel,
.settings-panel {
  padding: 1.5rem;
}

.welcome-panel {
  width: min(100%, 720px);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.75rem;
}

.status-card {
  padding: 0.95rem 1rem;
}

.status-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.25rem;
}

.game-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.game-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.game-toolbar-actions {
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.game-toolbar-actions .btn {
  white-space: nowrap;
}

.scoreboard-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.team-card {
  position: relative;
  overflow: hidden;
  padding: 0.85rem 4.35rem;
}

.team-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 6px;
}

.team-card-us::before {
  background: linear-gradient(90deg, var(--accent-us), rgba(255, 209, 102, 0.15));
}

.team-card-them::before {
  background: linear-gradient(90deg, var(--accent-them), rgba(123, 211, 137, 0.15));
}

.team-card.is-winner {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.team-card.is-finished {
  opacity: 0.92;
}

.team-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.team-name {
  font-size: clamp(1rem, 3.8vw, 2rem);
}

.team-score {
  font-size: clamp(2rem, 8vw, 4.5rem);
  line-height: 1;
  font-weight: 800;
  margin-top: 0.2rem;
}

.sticks-board {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}

.sticks-section {
  padding: 0.65rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.sticks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.stick {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: background-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.stick-bundle {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 3.65rem;
  max-width: 5.25rem;
  width: 100%;
  margin: 0 auto;
}

.stick-top,
.stick-bottom {
  left: 20%;
  width: 60%;
  height: 5px;
}

.stick-top {
  top: 16%;
}

.stick-bottom {
  bottom: 16%;
}

.stick-left,
.stick-right {
  top: 20%;
  width: 5px;
  height: 60%;
}

.stick-left {
  left: 18%;
}

.stick-right {
  right: 18%;
}

.stick-diagonal {
  top: 18%;
  left: 49%;
  width: 5px;
  height: 64%;
  transform: translateX(-50%) rotate(-41deg);
  transform-origin: center;
}

.stick.active-us,
.stick.active-them {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

.stick.active-us {
  background: var(--accent-us);
}

.stick.active-them {
  background: var(--accent-them);
}

.stick.just-scored {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14), 0 0 16px rgba(255, 255, 255, 0.24);
}

.stick-bundle.bundle-complete {
  background: rgba(255, 255, 255, 0.06);
}

.score-btn {
  width: 3.6rem;
  height: 3.6rem;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.65rem;
  font-weight: 700;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
}

.score-btn:active {
  transform: translateY(-50%) scale(1.07);
}

.score-btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.2);
  cursor: not-allowed;
}

.score-btn-floating {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
}

.team-card-us .score-btn-floating {
  left: 1rem;
}

.team-card-them .score-btn-floating {
  right: 1rem;
}

.score-btn-plus {
  margin-top: -3rem;
}

.score-btn-minus {
  margin-top: 3rem;
}

.btn-minus {
  background: linear-gradient(180deg, #8e2b2b, #611d1d);
}

.btn-plus {
  background: linear-gradient(180deg, #27804d, #174d30);
}

.actions-panel,
.history-panel {
  padding: 1.1rem;
}

.history-title {
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.history-list {
  display: grid;
  gap: 0.85rem;
}

.history-empty {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

.history-item {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-item strong {
  font-size: 1.05rem;
}

.history-score {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 600;
}

.history-meta {
  font-size: 0.92rem;
  margin-top: 0.3rem;
}

.settings-panel {
  display: grid;
  gap: 1rem;
}

.settings-block {
  padding: 1.25rem;
}

.settings-subtitle {
  font-size: 1.12rem;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
}

.palette-option {
  display: block;
  cursor: pointer;
}

.palette-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.palette-card {
  height: 100%;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.palette-option input:checked + .palette-card {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.palette-sample {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.palette-swatch {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.settings-switch .form-check-input {
  width: 3rem;
  height: 1.6rem;
}

.game-view-mode .app-header {
  display: none;
}

.game-view-mode .app-main {
  max-width: none;
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

.game-view-mode #gameView {
  display: block !important;
  min-height: 100vh;
}

.game-view-mode .game-shell {
  min-height: 100vh;
  padding: 1rem;
}

.game-view-mode .team-card {
  height: 100%;
}

.hidden {
  display: none !important;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 768px) {
  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .team-card {
    height: 100%;
    padding: 1.25rem 5.3rem;
  }

  .team-header {
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .team-name {
    font-size: clamp(1.35rem, 4vw, 2rem);
  }

  .team-score {
    font-size: clamp(2.7rem, 11vw, 4.5rem);
    margin-top: 0.35rem;
  }

  .sticks-board {
    gap: 1rem;
    margin-bottom: 0;
  }

  .sticks-section {
    padding: 0.85rem;
    border-radius: 18px;
  }

  .sticks-grid {
    gap: 1rem;
  }

  .stick-bundle {
    min-height: 4.8rem;
    border-radius: 16px;
  }

  .score-btn {
    width: 4.4rem;
    height: 4.4rem;
    font-size: 2rem;
  }

  .team-card-us .score-btn-floating {
    left: 1.35rem;
  }

  .team-card-them .score-btn-floating {
    right: 1.35rem;
  }

  .score-btn-plus {
    margin-top: -3.35rem;
  }

  .score-btn-minus {
    margin-top: 3.35rem;
  }

  .game-view-mode .game-shell {
    padding: 1.25rem;
  }
}

@media (max-width: 767px) {
  .main-nav,
  .welcome-actions,
  .game-toolbar-actions {
    width: 100%;
  }

  .main-nav .btn,
  .welcome-actions .btn,
  .game-toolbar-actions > .btn {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .wake-lock-panel {
    width: 100%;
    justify-content: space-between;
  }

  .wake-lock-panel .btn {
    flex: 1 1 auto;
  }

  .toolbar-badge {
    min-width: 4.8rem;
  }

  .game-toolbar {
    margin-bottom: 0.85rem;
    align-items: start;
  }

  .scoreboard-layout {
    gap: 0.7rem;
  }

  .team-card {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .score-btn-plus {
    margin-top: -2.75rem;
  }

  .score-btn-minus {
    margin-top: 2.75rem;
  }
}
