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

body {
  background: #121212;
  color: #fff;
  font-family: 'Google Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  user-select: none;
}

.wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 740px;
  max-width: 94vw;
  position: relative;
  z-index: 1;
}

.scene {
  perspective: 600px;
  width: 100%;
}

.card {
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.card-face {
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-front {
  background: #1e1e1e;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  position: relative;
}

.card-back {
  position: absolute;
  inset: 0;
  background: #1e1e1e;
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  place-items: stretch;
  transform: rotateY(180deg);
}

.card-back .back-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

@media (min-width: 641px) {
  .card-back.two-up {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .card-back.two-up #card-back-img-2,
  .card-back.two-up #card-back-img-3 {
    display: block !important;
  }
}

.left { display: flex; flex-direction: column; gap: 16px; }
.right { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.label { color: #aaa; font-size: 14px; }

.rate { font-size: 46px; font-weight: 300; letter-spacing: -1px; transition: opacity 0.4s; }

.currency-name { font-size: 30px; font-weight: 400; color: #ddd; }

.source { font-size: 12px; color: #666; }
.source span { text-decoration: underline; cursor: pointer; }

.inputs { display: flex; flex-direction: column; gap: 10px; }

.input-row {
  display: flex;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  overflow: hidden;
  background: #252525;
}

.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  width: 0;
  min-width: 0;
}

.input-row select {
  background: transparent;
  border: none;
  border-left: 1px solid #3a3a3a;
  color: #aaa;
  font-size: 13px;
  padding: 0 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 60px;
}

.tabs {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.tab {
  background: none;
  border: none;
  color: #888;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.tab.active { background: #333; color: #fff; }
.tab:not(.active):hover { background: #2a2a2a; }

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 180px;
  background: #181818;
  border-radius: 8px;
  overflow: hidden;
}

.y-labels {
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  color: #555;
  width: 42px;
  pointer-events: none;
}

.x-labels {
  position: absolute;
  bottom: 3px;
  left: 50px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #555;
  pointer-events: none;
}

#waveform {
  position: absolute;
  left: 50px;
  top: 0;
  width: calc(100% - 50px);
  height: calc(100% - 20px);
}

.more-btn {
  width: 100%;
  background: #2a2a2a;
  border: none;
  color: #ccc;
  padding: 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.more-btn:hover { background: #333; }

/* Controls bar */
.controls {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e1e1e;
  border-radius: 14px;
  padding: 12px 20px;
  border: 1px solid #2a2a2a;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(74, 222, 134, 0.10);
  pointer-events: none;
  transition: width 0.15s linear;
}

.song-picker, .btn-group { position: relative; z-index: 1; }

.controls select {
  background: #252525;
  color: #ddd;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 8px 30px 8px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  flex: 1;
  min-width: 140px;
  max-width: 300px;
}
.controls select:disabled { opacity: 0.35; cursor: not-allowed; }
.controls select option { background: #1e1e1e; color: #fff; }

.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls button {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  padding: 8px 14px;
  transition: all 0.15s;
  font-family: inherit;
  font-weight: 500;
  background: #2a2a2a;
  color: #ccc;
  line-height: 1;
}
.controls button:not(:disabled):active { transform: scale(0.93); }
.controls button:disabled { opacity: 0.25; cursor: not-allowed; }
#btn-start:not(:disabled) { background: #065f46; color: #6ee7b7; }
#btn-start:not(:disabled):hover { background: #047857; }
#btn-start.stop:not(:disabled) { background: #222; color: #fff; }
#btn-start.stop:not(:disabled):hover { background: #333; }

.song-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 300px;
}
.music-icon { flex-shrink: 0; }

#download-msg {
  display: none;
  color: #34d399;
  font-size: 12px;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
  white-space: nowrap;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

/* Override animate.css headShake on wrapper */
.wrapper.animate__animated.animate__headShake {
  animation-duration: 0.35s !important;
}

/* Falling banknotes background */
#banknotes-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.5s ease;
}
#banknotes-container.visible {
  opacity: 1;
}
.banknote {
  position: absolute;
  width: 300px;
  height: auto;
  opacity: 1;
  pointer-events: none;
  will-change: transform;
}
@keyframes fall {
  0%   { transform: translateY(-700px) rotate(0deg); }
  100% { transform: translateY(calc(100vh + 1600px)) rotate(360deg); }
}

#rate-value { color: #fff; }
#rate-loading { color: #666; font-size: 46px; font-weight: 300; }

.gif-pop {
  position: fixed;
  z-index: 2;
  width: 250px;
  height: 250px;
  object-fit: cover;
  pointer-events: none;
}

@media (max-width: 640px) {
  .wrapper {
    padding: 16px;
    gap: 10px;
  }

  .more-btn,
  .currency-name {
    display: none;
  }

  .card-front {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }

  .rate {
    font-size: 32px;
  }

  .currency-name {
    font-size: 22px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }

  .song-picker {
    max-width: none;
    width: 100%;
  }

  .btn-group {
    width: 100%;
  }

  .controls button {
    width: 100%;
    padding: 12px 14px;
  }
}

.watermark {
  display: block;
  width: fit-content;
  margin: 0 auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #000;
  background: #4ade80;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.watermark.visible {
  opacity: 1;
}
</style>
