/* === Pub Chatter / Dark Fantasy Theme === */

:root {
  --bg-dark: #0f0e0d;
  --bg-card: #1a1816;
  --bg-surface: #231f1b;
  --bg-hover: #2d2722;
  --border: #3a322a;
  --gold: #c8a84e;
  --gold-dim: #8a7236;
  --gold-glow: #e8c85e;
  --amber: #d4a043;
  --text: #d4cdc4;
  --text-dim: #8a827a;
  --red: #a33;
  --red-hover: #c44;
  --green: #4a7;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* === Tap to Start Overlay === */

#tap-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  perspective: 800px;
  overflow: hidden;
}

.tap-content {
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
  will-change: transform, opacity, filter, clip-path;
}

.tap-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 10px rgba(200, 168, 78, 0.55));
  display: inline-block;
  will-change: transform, filter;
}

.tap-content h1 {
  font-size: 1.8rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.tap-content p {
  color: var(--text-dim);
  font-size: 1rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Mute toggle (bottom-right corner of overlay) */
.tap-mute {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(232, 200, 94, 0.25);
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
.tap-mute:hover, .tap-mute:active {
  background: rgba(232, 200, 94, 0.10);
}
.tap-mute.muted {
  color: var(--text-dim);
  border-color: rgba(138, 130, 122, 0.3);
}

/* Entrance animation: cheers tilt + iris closing on the stein.
   The pulse animation is replaced by these once .anim-cheers-iris is added. */
.tap-content.anim-cheers-iris {
  animation: animIrisOnStein 1050ms cubic-bezier(.55, 0, .4, 1) forwards;
}
.tap-content.anim-cheers-iris .tap-icon {
  animation: animCheersHold 850ms ease forwards;
  transform-origin: 50% 80%;
}
@keyframes animCheersHold {
  0%   { transform: rotate(0)      translateY(0); }
  30%  { transform: rotate(-14deg) translateY(-6px); }
  55%  { transform: rotate(8deg)   translateY(-3px); }
  100% { transform: rotate(-2deg)  translateY(-8px); filter: drop-shadow(0 0 16px rgba(232, 200, 94, 0.85)); }
}
@keyframes animIrisOnStein {
  0%   { clip-path: circle(75% at 50% 24%); }
  85%  { clip-path: circle(8%  at 50% 22%); filter: brightness(1.3); }
  100% { clip-path: circle(0%  at 50% 22%); filter: none; opacity: 0; }
}

/* === Header === */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

header h1 {
  font-size: 1.1rem;
  color: var(--gold);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.master-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.master-volume label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.master-volume input[type="range"] {
  width: 100px;
}

.master-volume span {
  font-size: 0.8rem;
  color: var(--text-dim);
  width: 2.5em;
  text-align: right;
}

/* === Scene Bar === */

#scene-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.scene-scroll {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  flex: 1;
  padding: 0.25rem 0;
  scrollbar-width: none;
}

.scene-scroll::-webkit-scrollbar {
  display: none;
}

.btn-scene {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-scene:hover {
  border-color: var(--gold-dim);
  color: var(--text);
}

.btn-scene.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: #fff;
}

.btn-save {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn-save:hover {
  background: var(--gold-dim);
  color: #fff;
}

/* === Mixer === */

main#mixer {
  padding: 0.5rem;
  padding-bottom: 5rem;
}

.category {
  margin-bottom: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-surface);
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.category-icon {
  font-size: 1rem;
}

.collapse-icon {
  margin-left: auto;
  font-size: 0.6rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.category.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.category.collapsed .sound-list {
  display: none;
}

.sound-list {
  padding: 0.25rem 0;
}

.sound-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  transition: background 0.15s ease;
}

.sound-row:hover {
  background: var(--bg-hover);
}

.sound-row.active {
  background: rgba(200, 168, 78, 0.06);
}

.mute-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.mute-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(200, 168, 78, 0.1);
  box-shadow: 0 0 6px rgba(200, 168, 78, 0.2);
}

.sound-name {
  flex: 0 0 auto;
  min-width: 6em;
  font-size: 0.85rem;
  color: var(--text);
}

.volume-slider {
  flex: 1;
  min-width: 60px;
}

.volume-pct {
  width: 2.5em;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* === Range Slider Styling === */
/*
 * The input element itself is the touch target — keep it ~32px tall so fingers
 * can actually grab it. The visible track is drawn by the runnable-track
 * pseudo-element. Thumb margin-top centers it on the 4px track:
 *   margin-top = (track_height - thumb_height) / 2
 */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
  margin: 0;
}

/* Track */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  border: none;
}

/* Thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 0 4px rgba(200, 168, 78, 0.3);
  margin-top: -9px;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 0 4px rgba(200, 168, 78, 0.3);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

/* Press / drag feedback */
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 12px rgba(200, 168, 78, 0.7);
}

input[type="range"]:active::-moz-range-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 12px rgba(200, 168, 78, 0.7);
}

/* Keyboard focus ring */
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--gold-dim);
}

input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px var(--gold-dim);
}

/* === Footer === */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.btn-stop {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: transparent;
  color: var(--red);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-stop:hover {
  background: var(--red);
  color: #fff;
}

.btn-attr {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-attr:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

/* === Modals === */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  color: var(--gold);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 1rem;
}

.modal-content input[type="text"]:focus {
  border-color: var(--gold-dim);
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-primary {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  background: var(--gold-dim);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--gold);
}

.btn-secondary {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-danger {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--red-hover);
}

/* === Attribution === */

.attr-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.attr-item:last-child {
  border-bottom: none;
}

.attr-detail {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.attr-detail a {
  color: var(--gold-dim);
  text-decoration: none;
}

.attr-detail a:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* === Tip jar === */

.footer-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-tip {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  background: transparent;
  color: var(--gold);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tip:hover {
  background: var(--gold-dim);
  color: #fff;
}

.tip-blurb {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.tip-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tip-amount {
  padding: 0.75rem 0.25rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-dark);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tip-amount:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.tip-amount.selected {
  border-color: var(--gold);
  background: rgba(200, 168, 78, 0.12);
  color: var(--gold);
  box-shadow: 0 0 8px rgba(200, 168, 78, 0.2);
}

#tip-custom-row {
  position: relative;
  margin-bottom: 1rem;
}

.tip-custom-prefix {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  font-size: 0.95rem;
}

#tip-custom-amount {
  width: 100%;
  padding: 0.6rem 0.8rem 0.6rem 1.6rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

#tip-custom-amount:focus {
  border-color: var(--gold-dim);
}

#tip-custom-amount::-webkit-outer-spin-button,
#tip-custom-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#tip-custom-amount[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.tip-fineprint {
  margin-top: 0.75rem;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.4;
}

/* === Thanks page === */

.page-thanks {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
}

.thanks-wrap {
  width: 100%;
  max-width: 420px;
}

.thanks-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
}

.thanks-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.thanks-card h1 {
  color: var(--gold);
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.thanks-card p {
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.thanks-sub {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem !important;
  margin-top: 0.75rem !important;
  margin-bottom: 1.5rem !important;
}

.thanks-btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  text-decoration: none;
  font-size: 0.9rem;
}

/* === Mobile responsive === */

@media (max-width: 480px) {
  header h1 {
    font-size: 0.95rem;
  }

  .master-volume input[type="range"] {
    width: 90px;
  }

  .sound-name {
    min-width: 5em;
    font-size: 0.8rem;
  }

  .sound-row {
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
  }

  .mute-btn {
    width: 32px;
    height: 32px;
  }

  .category-header {
    padding: 0.75rem;
  }

  .footer-right {
    gap: 0.35rem;
  }

  .btn-tip {
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
  }

  .btn-attr {
    padding: 0.5rem 0.7rem;
  }

  .tip-amount {
    font-size: 0.9rem;
  }
}

/* Prevent text selection on interactive elements */
button, .category-header, .mute-btn {
  user-select: none;
  -webkit-user-select: none;
}
