:root {
  --bg-top: #1b1f3b;
  --bg-bottom: #0d0f22;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-active: rgba(255, 209, 128, 0.18);
  --accent: #ffd180;
  --text: #f2f3fb;
  --text-dim: #9aa0c3;
  --danger: #ff8a80;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: manipulation;
  user-select: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

header {
  text-align: center;
  padding-top: 8px;
}

header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.sounds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sound-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.sound-card .label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-badge,
.rename-badge {
  position: absolute;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.remove-badge {
  right: 6px;
  background: rgba(255, 138, 128, 0.9);
  color: #1b1f3b;
}

.rename-badge {
  left: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
  font-size: 11px;
}

.sound-card .icon {
  font-size: 28px;
}

.sound-card.active {
  background: var(--card-active);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.sound-card.loading .icon {
  animation: pulse 1s ease-in-out infinite;
}

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

.player {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
}

.now-playing span:last-child {
  word-break: break-word;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.timer-title {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.timer-presets button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
}

.timer-presets button.active {
  background: var(--accent);
  color: #1b1f3b;
  border-color: var(--accent);
}

.custom-timer {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.custom-timer input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.custom-timer input::placeholder {
  color: var(--text-dim);
}

.custom-timer button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
}

.remaining {
  text-align: center;
  margin: 14px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  min-height: 32px;
}

.controls {
  display: flex;
  gap: 10px;
}

.primary-btn, .secondary-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
}

.primary-btn {
  background: var(--accent);
  color: #1b1f3b;
}

.secondary-btn {
  background: rgba(255, 138, 128, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 138, 128, 0.3);
}

.hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:active {
  transform: scale(0.97);
}
