/* =========================================
   1. Root & Global Styles
   ========================================= */
:root {
  --apple-bg: rgba(22, 22, 23, 0.85);
  --apple-border: rgba(255, 255, 255, 0.1);
  --apple-glass: rgba(30, 30, 32, 0.75);
  --apple-hover: rgba(255, 255, 255, 0.08);
  --apple-accent: #0a84ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0f0f0f;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================
   2. Layout & Header
   ========================================= */
header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--apple-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--apple-border);
  z-index: 1000;
  width: 100%;
}

.logo {
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
  padding-left: 15px;
}

.logo a {
  color: #fff;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.nav button {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav button.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.nav button.inactive {
  background: transparent;
  color: #888;
}

.nav button.inactive:hover {
  background: var(--apple-hover);
  color: #fff;
}

/* =========================================
   3. Search Bar
   ========================================= */
.search {
  flex: 1;
  max-width: 460px;
  margin: 0 12px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0 4px 0 14px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: all 0.25s ease;
}

.search:focus-within {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--apple-accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  padding: 9px 8px;
  font-size: 13px;
  color: #fff;
}

.search button {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #ccc;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  margin: 2px;
  transition: background 0.2s;
}

.search button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* =========================================
   4. Main Content & Player Layout
   ========================================= */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.player-wrap {
  background: #121212;
  margin: 8px auto;
  overflow: hidden;
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 1024px;
  width: calc(100% - 16px);
  border-radius: 14px;
  border: 1px solid var(--apple-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#alphaTab {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
  scroll-behavior: auto;
  position: relative;
}

.top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px auto;
  background: var(--apple-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--apple-border);
  max-width: 1024px;
  width: calc(100% - 24px);
}

.top-bar select {
  flex: 1;
  max-width: 300px;
}

.option-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.option-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.option-btn:active {
  transform: scale(0.96);
}

select {
  background-color: rgba(40, 40, 42, 0.8);
  color: #fff;
  border: 1px solid var(--apple-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  backdrop-filter: blur(10px);
}

/* =========================================
   5. Drawers, Overlays & Modals
   ========================================= */
.options-drawer {
  position: fixed;
  top: 0;
  right: -340px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: rgba(24, 24, 26, 0.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--apple-border);
  z-index: 100;
  transition: right 0.25s ease;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.options-drawer.open { right: 0; }

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  display: none;
}

.drawer-overlay.open { display: block; }

.drawer-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-group label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
}

.drawer-group select { width: 100%; }

#browseOverlay, #staticPageOverlay {
  position: fixed;
  inset: 56px 0 0 0;
  background: #0f0f0f;
  z-index: 500;
  overflow: auto;
  padding: 16px;
  display: none;
}

#browseOverlay.open, #staticPageOverlay.open { display: block; }

#browseGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px;
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.song-card {
  background: var(--apple-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--apple-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.song-card:hover {
  background: rgba(45, 45, 48, 0.8);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.artist-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #ffcc00;
  color: #ffcc00 !important;
}

/* =========================================
   6. Controls & Fretboard
   ========================================= */
.bottom-float {
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  background: #1e232e;
  border-top: 2px solid #2a303f;
}

.float-controls {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background: rgba(30, 30, 32, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--apple-border);
  z-index: 11;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.float-controls button {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.float-controls button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.float-controls button:active {
  transform: scale(0.96);
}

.fretboard {
  flex-shrink: 0;
  background: #1e232e;
  position: relative;
  border-top: 2px solid #2a303f;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100vw;
}

.fretboard-inner {
  position: relative;
  min-width: 100%;
  background: linear-gradient(180deg, #232938 0%, #1a1e2a 100%);
}

.string {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #4a5568;
}

.fret {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #e2e8f0 0%, #a0aec0 50%, #e2e8f0 100%);
}

.fret:first-child { width: 4px; }

.dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #e2e8f096;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.note {
  position: absolute;
  background: #f6ad09;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #000;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #000;
}

.note.note-red {
  background: #ff0000;
  color: #fff;
  border-color: #0f0f0f;
}

/* =========================================
   7. AlphaTab Customization
   ========================================= */
.at-cursor-bar {
  background: rgba(255, 0, 0, 0.08) !important;
  border: none !important;
}

.at-cursor-beat {
  background: red !important;
  width: 4px !important;
}

.at-highlight * {
  fill: red;
  stroke: red;
}

.at-marker text {
  font-size: 24px !important;
  font-weight: 900 !important;
  font-family: Inter, system-ui !important;
  fill: #ffffff !important;
}

.at-marker rect {
  fill: #ff0000 !important;
  stroke: #222222 !important;
  stroke-width: 2px !important;
  rx: 6px !important;
}

/* =========================================
   8. Footer & Static Pages
   ========================================= */
.tablatory-footer {
  display: block;
  background: #0a0a0a;
  border-top: 1px solid #1f1f1f;
  padding: 24px 16px;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
}

.footer-brand {
  flex: 1;
  min-width: 260px;
}

.footer-brand h3 {
  font-size: 16px;
  font-weight: 900;
  margin: 0 0 8px 0;
}

.footer-brand h3 span { color: #ff0000; }

.footer-brand p {
  font-size: 11px;
  color: #777;
  line-height: 16px;
  max-width: 380px;
}

.footer-links {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.footer-col { min-width: 140px; }

.footer-col h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: #888;
  letter-spacing: .5px;
  margin: 0 0 10px 0;
}

.footer-col a {
  display: block;
  font-size: 11px;
  color: #aaa;
  text-decoration: none;
  margin-bottom: 8px;
}

.footer-col a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-bottom {
  max-width: 1200px;
  margin: 16px auto 0 auto;
  padding-top: 16px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: #555;
}

.static-page {
  max-width: 800px;
  margin: 0 auto;
  background: var(--apple-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--apple-border);
  border-radius: 12px;
  padding: 24px;
}

.static-page h1 { font-size: 22px; font-weight: 900; margin: 0 0 8px 0; }
.static-page h2 { font-size: 14px; font-weight: 700; margin: 20px 0 8px 0; color: #fff; }
.static-page p, .static-page li { font-size: 12px; line-height: 18px; color: #aaa; }
.static-page a { color: #facc15; text-decoration: none; }

.static-close {
  background: #222;
  border: 1px solid #333;
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 16px;
}

/* =========================================
   9. Custom Scrollbars
   ========================================= */
#alphaTab, .main, .options-drawer, #browseOverlay, #staticPageOverlay, .fretboard {
  scrollbar-width: thin;
  scrollbar-color: #000000 #181818;
}

#alphaTab::-webkit-scrollbar,
.main::-webkit-scrollbar,
.options-drawer::-webkit-scrollbar,
#browseOverlay::-webkit-scrollbar,
#staticPageOverlay::-webkit-scrollbar,
.fretboard::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

#alphaTab::-webkit-scrollbar-track,
.main::-webkit-scrollbar-track,
.options-drawer::-webkit-scrollbar-track,
#browseOverlay::-webkit-scrollbar-track,
#staticPageOverlay::-webkit-scrollbar-track,
.fretboard::-webkit-scrollbar-track {
  background: #181818;
}

#alphaTab::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb,
.options-drawer::-webkit-scrollbar-thumb,
#browseOverlay::-webkit-scrollbar-thumb,
#staticPageOverlay::-webkit-scrollbar-thumb,
.fretboard::-webkit-scrollbar-thumb {
  background: #000000;
  border-radius: 999px;
}

#alphaTab::-webkit-scrollbar-thumb:hover,
.main::-webkit-scrollbar-thumb:hover,
.options-drawer::-webkit-scrollbar-thumb:hover,
#browseOverlay::-webkit-scrollbar-thumb:hover,
#staticPageOverlay::-webkit-scrollbar-thumb:hover,
.fretboard::-webkit-scrollbar-thumb:hover {
  background: #333333;
}

/* =========================================
   10. Media Queries (Responsive Design)
   ========================================= */
@media (max-width: 768px) {
  body { overflow-x: hidden; }
  header { width: 100% !important; max-width: 100vw !important; padding: 0 10px !important; gap: 8px !important; }
  .logo { font-size: 15px !important; }
  .nav button { padding: 5px 10px !important; font-size: 11px !important; }
  .search { margin: 0 6px !important; max-width: none !important; flex: 1 !important; min-width: 0 !important; }
  .search input { font-size: 12px !important; }
  #browseOverlay, #staticPageOverlay, #songDetailOverlay { width: 100vw !important; max-width: 100vw !important; }
  .song-grid { grid-template-columns: 1fr !important; }
  .player-wrap { margin: 4px !important; width: calc(100% - 8px) !important; }
  .top-bar { margin: 4px !important; flex-wrap: wrap; width: calc(100% - 8px) !important; }
  .fretboard { max-width: 100vw !important; }
  #songDetailOverlay > div > div { grid-template-columns: 1fr !important; }
  .bottom-float { position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; width: 100vw !important; max-width: 100vw !important; z-index: 50 !important; }
}

@media (max-width: 500px) {
  header .nav { display: none !important; }
  header { gap: 10px; padding: 10px 12px; }
  header .search { flex: 1; min-width: 0; display: flex; }
  header .search input { width: 100%; min-width: 0; }
}

/* ==========================================
   BUNDLE CARD STYLES (Steam/Humble Bundle Style)
   ========================================== */
.bundle-container { margin-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.bundle-card { background: #121820; border: 1px solid #1e2837; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.bundle-header { display: flex; gap: 20px; padding: 20px; background: linear-gradient(90deg, #182333 0%, #121820 100%); flex-wrap: wrap; }
.bundle-cover { width: 220px; height: 124px; border-radius: 6px; object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,0.8); flex-shrink: 0; }
.bundle-info { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 200px; }
.bundle-badge { align-self: flex-start; background: #f59e0b; color: #000; font-size: 10px; font-weight: 800; padding: 4px 10px; border-radius: 4px; text-transform: uppercase; margin-bottom: 8px; }
.bundle-title { font-size: 18px; font-weight: 800; color: #fff; margin: 0 0 4px 0; line-height: 1.2; }
.bundle-publisher { font-size: 12px; color: #8fa0b5; margin: 0 0 16px 0; }
.bundle-action { display: flex; align-items: center; gap: 16px; margin-top: auto; flex-wrap: wrap; }
.bundle-price { font-size: 20px; font-weight: 800; color: #a4d007; }
.bundle-btn { background: #0ea5e9; color: #fff; text-decoration: none; padding: 8px 16px; border-radius: 6px; font-weight: 700; font-size: 13px; transition: 0.2s; border: none; cursor: pointer; }
.bundle-btn:hover { background: #0284c7; }

/* TRACKLIST SECTION */
.bundle-includes { background: #0b0f14; padding: 16px 20px; border-top: 1px solid #1e2837; }
.bundle-includes h4 { margin: 0 0 12px 0; font-size: 11px; color: #8fa0b5; text-transform: uppercase; letter-spacing: 0.5px; }
.bundle-tracklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.bundle-tracklist li a { display: block; color: #d1d5db; text-decoration: none; font-size: 12px; padding: 8px 12px; background: rgba(255,255,255,0.03); border-radius: 4px; transition: 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bundle-tracklist li a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.bundle-tracklist li.current-track a { background: rgba(14, 165, 233, 0.15) !important; color: #38bdf8 !important; border-left: 2px solid #38bdf8; font-weight: 700; }

@media (max-width: 768px) {
  .bundle-header { flex-direction: column; padding: 16px; }
  .bundle-cover { width: 100%; height: auto; aspect-ratio: 16/9; }
}