:root {
  --coal: #201814;
  --ink: #33231a;
  --cream: #fff7e6;
  --paper: #fffdf6;
  --red: #d9251d;
  --deep-red: #a71916;
  --yellow: #ffc533;
  --orange: #f26a21;
  --green: #159661;
  --line: rgba(32, 24, 20, 0.16);
  --shadow: 0 22px 70px rgba(79, 31, 12, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 197, 51, 0.5), transparent 28rem),
    linear-gradient(135deg, #fff8e9 0%, #ffe7b7 42%, #f9eee4 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.stage {
  min-height: min(720px, calc(100vh - 56px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}

.brand-bar,
.meter-layout,
.bottom-grid {
  display: grid;
  gap: 18px;
}

.brand-bar {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.brand-mark {
  width: 82px;
  height: 82px;
  position: relative;
  border-radius: 24px;
  background: var(--red);
  box-shadow: var(--shadow);
  transform: rotate(-4deg);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  background: var(--yellow);
}

.brand-mark::before {
  width: 46px;
  height: 28px;
  top: -14px;
  left: 18px;
  border-radius: 26px 26px 6px 6px;
}

.brand-mark::after {
  width: 36px;
  height: 18px;
  right: -13px;
  top: 31px;
  border-radius: 0 18px 18px 0;
}

.brand-mark span {
  width: 22px;
  height: 22px;
  left: 30px;
  top: 30px;
  border-radius: 50%;
  box-shadow: 18px 2px 0 #fff7e6;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--deep-red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 780px;
  font-size: clamp(2.65rem, 8vw, 6.6rem);
  line-height: 0.88;
  color: var(--coal);
}

h2 {
  font-size: 1.05rem;
}

.meter-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: stretch;
}

.challenge-panel,
.reward-panel,
.settings-panel,
.leaderboard-panel {
  border: 1px solid var(--line);
  background: rgba(255, 253, 246, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.challenge-panel {
  min-height: 460px;
  padding: 28px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  border-radius: 8px;
}

.timer-ring {
  width: 260px;
  height: 260px;
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--red) 0deg, rgba(217, 37, 29, 0.1) 0deg);
  position: relative;
}

.timer-ring::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
}

.timer-copy {
  position: relative;
  display: grid;
  justify-items: center;
}

.timer-copy span {
  color: var(--coal);
  font-size: 4.3rem;
  font-weight: 900;
  line-height: 1;
}

.timer-copy small {
  color: rgba(51, 35, 26, 0.74);
  font-weight: 800;
}

.status-strip {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--coal);
  font-size: 0.86rem;
  font-weight: 900;
}

#statusText {
  color: rgba(51, 35, 26, 0.76);
  font-weight: 700;
}

#waveCanvas {
  width: 100%;
  height: 100%;
  min-height: 250px;
  border-radius: 8px;
  border: 1px solid rgba(32, 24, 20, 0.12);
  background:
    linear-gradient(rgba(32, 24, 20, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 24, 20, 0.06) 1px, transparent 1px),
    #fffaf0;
  background-size: 28px 28px;
}

.controls {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.mini-btn {
  min-height: 46px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.primary-btn {
  padding: 0 22px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 10px 22px rgba(217, 37, 29, 0.25);
}

.primary-btn:disabled {
  cursor: wait;
  background: #8d8179;
  box-shadow: none;
}

.ghost-btn {
  padding: 0 18px;
  color: var(--coal);
  background: rgba(32, 24, 20, 0.08);
}

.reward-panel {
  min-height: 460px;
  padding: 28px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.reward-top strong {
  display: block;
  color: var(--red);
  font-size: clamp(4rem, 10vw, 7rem);
  line-height: 0.9;
}

.reward-copy {
  display: grid;
  gap: 12px;
  color: rgba(51, 35, 26, 0.78);
  font-weight: 800;
}

#voucherCode {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed rgba(167, 25, 22, 0.45);
  border-radius: 8px;
  color: var(--deep-red);
  background: rgba(255, 197, 51, 0.16);
  overflow-wrap: anywhere;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(32, 24, 20, 0.1);
}

.progress-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--orange), var(--red));
  transition: width 140ms ease;
}

.bottom-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.settings-panel,
.leaderboard-panel {
  padding: 20px;
  border-radius: 8px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading span {
  color: rgba(51, 35, 26, 0.64);
  font-size: 0.86rem;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: rgba(51, 35, 26, 0.78);
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--red);
}

.setting-values {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: rgba(51, 35, 26, 0.68);
  font-size: 0.9rem;
  font-weight: 800;
}

.mini-btn {
  min-height: 34px;
  padding: 0 12px;
  color: var(--deep-red);
  background: rgba(217, 37, 29, 0.08);
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  min-height: 94px;
  margin: 0;
  padding-left: 24px;
}

.leaderboard-list li {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 197, 51, 0.18);
  font-weight: 850;
}

@media (max-width: 920px) {
  .stage {
    justify-content: flex-start;
  }

  .meter-layout,
  .bottom-grid,
  .challenge-panel {
    grid-template-columns: 1fr;
  }

  .timer-ring {
    grid-row: auto;
    justify-self: center;
  }

  .reward-panel {
    min-height: 290px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

  .brand-bar {
    grid-template-columns: 58px 1fr;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
  }

  .brand-mark::before {
    width: 34px;
    height: 20px;
    top: -10px;
    left: 12px;
  }

  .brand-mark::after {
    width: 24px;
    height: 14px;
    right: -9px;
    top: 22px;
  }

  .brand-mark span {
    width: 15px;
    height: 15px;
    left: 22px;
    top: 22px;
    box-shadow: 13px 1px 0 #fff7e6;
  }

  .challenge-panel,
  .reward-panel,
  .settings-panel,
  .leaderboard-panel {
    padding: 16px;
  }

  .timer-ring {
    width: min(248px, 82vw);
    height: min(248px, 82vw);
  }
}
