:root {
  --bg: #f7f7f8;
  --text: #1a1a1f;
  --muted: #6b6b76;
  --accent: #e8192c;
  --accent-dark: #b80f1f;
  --accent-light: #ff4d5e;
  --black: #111114;
  --shadow: rgba(17, 17, 20, 0.18);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #ffffff 0%, transparent 70%),
    var(--bg);
}

a {
  color: inherit;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1.5rem 2rem;
}

.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header__credit {
  margin: 0;
  text-align: right;
  font-size: 0.88rem;
  color: var(--muted);
}

.header__credit a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.header__credit a:hover {
  text-decoration: underline;
}

.challenge-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.challenge-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.challenge-link::after {
  content: "↗";
  font-size: 0.75rem;
  opacity: 0.55;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(100%, 520px);
  padding: 2rem 0 1.5rem;
}

.button-stack {
  position: relative;
  width: min(72vw, 320px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.button-stack.is-shaking {
  animation: stack-shake 0.38s ease-out;
}

@keyframes stack-shake {
  0%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(2px);
  }
  50% {
    transform: translateY(-1px);
  }
  75% {
    transform: translateY(1px);
  }
}

.press-ripples {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.press-effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.press-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34%;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.65;
  transform: translate(-50%, -50%) scale(0.3);
  animation: press-ripple 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.press-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    var(--accent-light) 0%,
    transparent 68%
  );
  opacity: 0.55;
  animation: press-glow 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.press-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 8px var(--accent);
  opacity: 1;
  animation: press-particle 0.55s ease-out forwards;
}

@keyframes press-ripple {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0.75;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
  }
}

@keyframes press-glow {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.75;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.4);
    opacity: 0;
  }
}

@keyframes press-particle {
  0% {
    transform: rotate(var(--angle)) translateX(18px) scale(1);
    opacity: 1;
  }
  100% {
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(0);
    opacity: 0;
  }
}

.talk-button {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.talk-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.talk-button:not(:disabled):active .talk-button__dome,
.talk-button.is-pressed .talk-button__dome {
  background: var(
    --dome-bg-pressed,
    linear-gradient(
      180deg,
      var(--accent-dark) 0%,
      var(--accent) 50%,
      var(--accent-dark) 100%
    )
  );
  box-shadow:
    inset 0 16px 24px rgba(0, 0, 0, 0.38),
    inset 0 -8px 14px rgba(0, 0, 0, 0.22),
    inset 0 2px 5px rgba(255, 255, 255, 0.07);
  filter: brightness(0.93);
}

.talk-button:not(:disabled):active .talk-button__shine,
.talk-button.is-pressed .talk-button__shine {
  opacity: 0.2;
  transition: opacity 0.22s ease;
}

.talk-button__shadow {
  position: absolute;
  inset: 10% 8% -4% 8%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.22) 0%,
    rgba(0, 0, 0, 0.08) 55%,
    transparent 72%
  );
  filter: blur(8px);
  transform: scaleY(0.45);
  z-index: 0;
}

.talk-button__base {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: linear-gradient(180deg, #2a2a30 0%, var(--black) 55%, #050507 100%);
  box-shadow:
    0 14px 28px var(--shadow),
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -6px 12px rgba(0, 0, 0, 0.45);
  z-index: 1;
}

.talk-button__dome {
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  outline: 6px solid rgba(255, 255, 255, 0.2);
  background: var(
    --dome-bg,
    linear-gradient(
      145deg,
      var(--accent-light) 0%,
      var(--accent) 38%,
      var(--accent-dark) 100%
    )
  );
  box-shadow:
    inset 0 -8px 16px rgba(0, 0, 0, 0.18),
    inset 0 10px 18px rgba(255, 255, 255, 0.28),
    0 4px 10px rgba(0, 0, 0, 0.12);
  z-index: 2;
  overflow: hidden;
  transition:
    box-shadow 0.24s ease,
    background 0.24s ease,
    filter 0.24s ease,
    outline-color 0.24s ease;
}

.talk-button__flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 255, 255, 0.7) 0%,
    rgba(255, 255, 255, 0.15) 40%,
    transparent 72%
  );
  opacity: 0;
  pointer-events: none;
}

.talk-button.is-burst .talk-button__flash {
  animation: dome-flash 0.38s ease-out;
}

@keyframes dome-flash {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

.talk-button__shine {
  position: absolute;
  top: 8%;
  left: 14%;
  width: 42%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.75) 0%,
    rgba(255, 255, 255, 0.15) 55%,
    transparent 72%
  );
  transform: rotate(-18deg);
  transition: opacity 0.22s ease;
}

.talk-button__label {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(2.4rem, 12vw, 4rem);
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.talk-button__label:empty {
  display: none;
}

.talk-button__label--sm {
  font-size: clamp(1.35rem, 6.5vw, 2.35rem);
  letter-spacing: 0.03em;
}

.talk-button__label--multiline {
  white-space: pre-line;
  text-align: center;
  line-height: 1.05;
  font-size: clamp(1.15rem, 5.8vw, 2rem);
  letter-spacing: 0.05em;
}

.talk-button[data-has-emoji="true"] .talk-button__label {
  font-size: clamp(4.2rem, 20vw, 7rem);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: none;
}

.talk-button.is-playing .talk-button__dome {
  animation: pulse 0.9s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08);
  }
}

.record-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.record-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 10.5rem;
  height: 3.1rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease;
}

.record-button:hover:not(:disabled) {
  transform: scale(1.05);
}

.record-button:active:not(:disabled) {
  transform: scale(0.96);
}

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

.record-button:disabled:hover,
.record-button:disabled:active {
  transform: none;
}

.delete-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.1rem;
  height: 3.1rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.delete-button.hidden {
  display: none;
}

.delete-button:hover:not(:disabled) {
  transform: scale(1.05);
}

.delete-button:active:not(:disabled) {
  transform: scale(0.96);
}

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

.delete-button__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #2e2e34 0%, var(--black) 100%);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.28),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.delete-button__icon {
  position: relative;
  z-index: 1;
  width: 1.15rem;
  height: 1.15rem;
}

.record-button__ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #2e2e34 0%, var(--black) 100%);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.28),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.record-button__label {
  position: relative;
  z-index: 2;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}

.record-button__dot {
  position: relative;
  z-index: 2;
  width: 0;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.record-button.is-recording .record-button__dot {
  width: 0.55rem;
  margin-right: 0.45rem;
  border-radius: 22%;
  background: #ff3b30;
  box-shadow: 0 0 10px rgba(255, 59, 48, 0.55);
  animation: rec-blink 1s step-end infinite;
}

@keyframes rec-blink {
  50% {
    opacity: 0.45;
  }
}

.status {
  margin: 1.75rem 0 0;
  font-size: 1rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.5em;
}

.timer {
  margin-top: 0.85rem;
  width: min(240px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.timer.hidden {
  display: none;
}

.timer__bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.1s linear;
}

.actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem;
  justify-content: center;
  width: min(100%, 520px);
}

.action-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.2rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--black);
  color: #fff;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-btn--ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

body.sidebar-open {
  overflow: hidden;
}

.sidebar {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.sidebar.is-open {
  pointer-events: auto;
}

.sidebar__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 20, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar.is-open .sidebar__backdrop {
  opacity: 1;
}

.sidebar__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 360px);
  height: 100%;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem 1.5rem;
  overflow-y: auto;
}

.sidebar.is-open .sidebar__panel {
  transform: translateX(0);
}

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

.sidebar__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar__close {
  appearance: none;
  border: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #f2f2f4;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.design-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #f6f6f8;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.design-preview:hover {
  background: #efeff2;
}

.design-preview.is-active {
  border-color: var(--text);
  background: #fff;
}

.design-preview__button {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.design-preview__button .talk-button__label {
  font-size: 0.62rem;
  letter-spacing: 0.05em;
}

.design-preview__button .talk-button__label--sm {
  font-size: 0.42rem;
}

.design-preview__button .talk-button__label--multiline {
  font-size: 0.34rem;
  line-height: 1.05;
}

.design-preview__button[data-has-emoji="true"] .talk-button__label {
  font-size: 1.1rem;
}

.design-preview__name {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 480px) {
  .record-button {
    min-width: 9.5rem;
    height: 2.85rem;
    padding: 0 1rem;
  }

  .record-button__label {
    font-size: 0.82rem;
  }

  .actions {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .action-btn {
    flex: 1;
    padding: 0.72rem 0.75rem;
    font-size: 0.84rem;
  }
}