@import url("https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;600;700;800;900&display=swap");

:root {
  --bg-1: #f8a084;
  --bg-2: #f3724a;
  --card: #ffffff;
  --text: #1f1820;
  --muted: #4e3d45;
  --accent-low: #003255;
  --accent-high: #771b2a;
  --primary: #003255;
  --secondary: #771b2a;
  --warning: #9b2c2c;
  --font-main: "Work Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --font-accent: "Trebuchet MS", "Work Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--text);
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, var(--bg-1), var(--bg-2));
}

.app {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 16px 24px;
}

h1 {
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-family: var(--font-accent);
  font-style: italic;
}

.warning {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  color: var(--warning);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid #efb6a1;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 20px rgba(119, 27, 42, 0.14);
}

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

.controls button,
.clap-buttons button {
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  min-height: 52px;
  touch-action: manipulation;
  cursor: pointer;
  transition: transform 90ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.controls button:hover,
.clap-buttons button:hover {
  box-shadow: 0 10px 20px rgba(0, 50, 85, 0.28);
}

#startBtn {
  background: var(--primary);
}

#stopBtn {
  background: var(--secondary);
}

#lowBtn {
  background: var(--accent-low);
}

#highBtn {
  background: var(--accent-high);
}

.clap-buttons {
  margin-top: 10px;
}

.clap-buttons button {
  flex: 1 1 220px;
}

.pulse {
  transform: scale(1.07);
  filter: brightness(1.18);
}

.live-feedback {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  background: #fff1eb;
  color: #4c1d1d;
  border: 1px solid #efb6a1;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.live-feedback.low {
  background: #e8f0f7;
  border-color: #7aa2c3;
  color: #0b3558;
}

.live-feedback.high {
  background: #f9e8ec;
  border-color: #d18a96;
  color: #5b1020;
}

.key-hint {
  margin: 10px 0 2px;
  color: #4e3d45;
  font-size: 14px;
}

.key-hint kbd {
  font-family: Consolas, "Courier New", monospace;
  background: #fff3ef;
  border: 1px solid #e79c86;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#timeDisplay {
  font-weight: 600;
}

.settings h2,
.panel h2 {
  margin: 0 0 12px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input[type="number"] {
  width: 130px;
  border: 1px solid #9fb3c8;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
}

#scoreSummary {
  font-size: 16px;
  font-weight: 600;
}

.score-summary-card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid #bcccdc;
  background: linear-gradient(130deg, #f8fbff 0%, #ecf4fb 100%);
  color: #102a43;
  padding: 12px;
}

.score-summary-card.is-win {
  border: 1px solid #b7791f;
  background: linear-gradient(135deg, #6b4f00 0%, #d69e2e 55%, #fff0a8 100%);
  color: #fffef8;
  box-shadow: 0 12px 30px rgba(107, 79, 0, 0.35);
  animation: scorePop 420ms ease-out;
}

.score-summary-card.is-win::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -35%;
  width: 28%;
  height: 180%;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
  transform: rotate(24deg);
  animation: shineSweep 2.2s ease-out;
}

.win-tag {
  letter-spacing: 0.09em;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.92;
}

.win-score {
  margin-top: 4px;
  font-size: clamp(36px, 8vw, 56px);
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(69, 52, 0, 0.3);
}

.win-score span {
  font-size: 18px;
  font-weight: 700;
  margin-left: 6px;
}

.win-rank {
  margin-top: 6px;
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(16, 42, 67, 0.25);
}

.win-stats {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.95;
}

.score-summary-card.tier-draen {
  background: linear-gradient(130deg, #5a2e00 0%, #9c4221 50%, #f6ad55 100%);
}

.score-summary-card.tier-sidstegangs {
  background: linear-gradient(130deg, #374151 0%, #4b5563 50%, #9ca3af 100%);
}

.score-summary-card.tier-medarbejder {
  background: linear-gradient(130deg, #1f4d6b 0%, #2c7a9a 52%, #7ecbe6 100%);
}

.score-summary-card.tier-bandet {
  background: linear-gradient(130deg, #064e3b 0%, #059669 48%, #6ee7b7 100%);
}

.score-summary-card.tier-niels {
  background: linear-gradient(130deg, #4a154b 0%, #9d174d 45%, #f59e0b 100%);
}

@keyframes scorePop {
  0% {
    transform: scale(0.97);
    opacity: 0.2;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes shineSweep {
  from {
    left: -35%;
  }
  to {
    left: 130%;
  }
}

#scoreDetails {
  margin: 10px 0 0;
  background: #f8fbff;
  border-radius: 10px;
  padding: 10px;
  overflow-x: auto;
}

.leaderboard-entry {
  margin-top: 14px;
  border-top: 1px solid #efb6a1;
  padding-top: 12px;
}

.leaderboard-entry label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.leaderboard-entry-row {
  gap: 8px;
}

#playerNameInput {
  flex: 1 1 240px;
  border: 1px solid #9fb3c8;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
}

#saveScoreBtn {
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

#saveScoreBtn:hover {
  box-shadow: 0 8px 18px rgba(0, 50, 85, 0.24);
}

.leaderboard-message {
  margin: 8px 0 0;
  min-height: 20px;
  font-size: 14px;
  color: #2f4858;
}

.leaderboard-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.leaderboard-item {
  border: 1px solid #dfae9a;
  border-radius: 10px;
  background: #fff7f3;
  padding: 10px 12px;
}

.leaderboard-main {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.leaderboard-meta {
  margin-top: 2px;
  color: #5e4750;
  font-size: 13px;
}

.leaderboard-empty {
  list-style: none;
  color: #5e4750;
}

@media (max-width: 640px) {
  .app {
    margin-top: 16px;
  }

  .controls,
  .clap-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  #timeDisplay {
    grid-column: 1 / -1;
    text-align: center;
  }

  .controls button,
  .clap-buttons button {
    min-height: 64px;
    font-size: 18px;
    border-radius: 14px;
  }

  .key-hint {
    font-size: 15px;
    line-height: 1.4;
  }

  input[type="number"] {
    width: 100%;
  }

  .win-stats {
    line-height: 1.4;
  }

  #saveScoreBtn,
  #playerNameInput {
    width: 100%;
  }
}
