/* =========================================================
   RESPONSIVE DASHBOARD — CLEAN / FIXED
========================================================= */

html,
body {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

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


/* =========================================================
   TOOLBAR
========================================================= */

.toolbar-container,
.toolbar-container.is-collapsed {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.toolbar-container {
  position: sticky;
  top: 0;
  z-index: 60;

  width: 100%;
  max-width: 100%;

  padding: 10px 16px;
  margin: 0;
}

.top-toolbar {
  width: 100%;
  max-width: 1800px;
  min-width: 0;

  margin: 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;

  gap: 8px;

  padding: 10px 14px;
}

.top-toolbar button {
  min-height: 40px;

  padding: 8px 14px;

  font-size: 0.85rem;

  white-space: nowrap;
}


/* =========================================================
   DASHBOARD
========================================================= */

.dashboard-shell {
  width: 100%;
  max-width: 2200px;
  min-width: 0;

  margin: 24px auto 0;

  padding:
    0
    20px
    30px;
}


/* =========================================================
   DESKTOP GRID
========================================================= */

.dashboard-layout {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  display: grid;

  grid-template-columns:
    minmax(220px, 280px)
    minmax(0, 1fr)
    minmax(220px, 280px);

  gap: 24px;

  align-items: start;
}


/* =========================================================
   MAIN / CENTER COLUMN
========================================================= */

.dashboard-layout > main {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  display: flex !important;
  flex-direction: column;

  align-items: center !important;
  justify-content: flex-start;

  text-align: center;
}


/* =========================================================
   MAIN CARD
========================================================= */

.dashboard-layout > main > .card {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;

  margin-left: 0 !important;
  margin-right: 0 !important;
}


/* =========================================================
   WHEEL AREA
========================================================= */

.wheel-area {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  display: flex;

  align-items: center;
  justify-content: center;

  margin: 0 auto;

  padding: 10px 0;

  overflow: visible;
}


/* =========================================================
   WHEEL WRAPPER
========================================================= */

.wheel-wrap {
  position: relative;

  width: min(100%, 680px);
  max-width: 680px;

  aspect-ratio: 1 / 1;

  margin-left: auto;
  margin-right: auto;

  flex: 0 1 auto;

  min-width: 0;
  min-height: 0;

  display: flex;

  align-items: center;
  justify-content: center;

  overflow: visible;

  left: auto;
  right: auto;

  transform: none;
}


/* =========================================================
   CANVAS
========================================================= */

.wheel-canvas,
#wheel {
  display: block;

  width: 100%;
  height: 100%;

  max-width: 100%;
  max-height: 100%;

  min-width: 0;
  min-height: 0;

  margin: 0;

  flex: 0 0 auto;

  aspect-ratio: 1 / 1;
}


/* =========================================================
   CONTROLS
========================================================= */

#controlsRow {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  display: flex;

  align-items: center;
  justify-content: center;

  flex-wrap: wrap;

  gap: 8px;

  padding:
    4px
    10px
    18px;
}

#controlsRow button {
  min-height: 42px;

  padding:
    9px 18px;

  font-size: 0.9rem;
}


/* =========================================================
   SIDE PANELS
========================================================= */

.leaderboard-panel-wrapper,
.ranked-tracks-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.leaderboard-panel,
.ranked-tracks-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  overflow: hidden;
}


/* =========================================================
   TEXT
========================================================= */

.leaderboard-header,
.ranked-tracks-head {
  font-size: 0.85rem;
}

.leaderboard-item,
.ranked-tracks-item {
  min-width: 0;

  gap: 8px;
}

.leaderboard-artist,
.ranked-tracks-title,
.ranked-tracks-artist {
  min-width: 0;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.small,
#subStatus,
#rankingStatus {
  font-size: 0.8rem;
}


/* =========================================================
   WINNER PLAYER
========================================================= */

.winner-modal .winner-player {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  margin-top: 14px;

  min-height: 166px;

  display: flex;

  align-items: center;
  justify-content: center;

  padding: 0;

  overflow: hidden;
}

.winner-modal .winner-player iframe {
  display: block;

  width: 100%;
  height: 166px;

  max-width: 100%;

  border: 0;
}


/* =========================================================
   WINNER MODAL
========================================================= */

.winner-overlay {
  position: fixed;

  inset: 0;

  z-index: 200;

  display: none;

  align-items: center;
  justify-content: center;

  padding: 20px;

  background:
    rgba(5, 8, 20, 0.72);

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  isolation: isolate;

  overflow: hidden;
}

.winner-overlay.is-open {
  display: flex;
}

.winner-overlay[hidden] {
  display: none !important;
}

.winner-modal {
  width: min(720px, 100%);
  max-width: 100%;

  max-height: 90vh;

  min-width: 0;

  overflow-x: hidden;
  overflow-y: auto;

  padding: 24px;

  border-radius: 18px;
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 1200px) {

  .dashboard-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .dashboard-layout {
    grid-template-columns:
      minmax(180px, 230px)
      minmax(0, 1fr)
      minmax(180px, 230px);

    gap: 16px;
  }

  .wheel-wrap {
    width: min(100%, 560px);
    max-width: 560px;
  }
}


/* =========================================================
   SMALL TABLET
========================================================= */

@media (max-width: 950px) {

  .dashboard-shell {
    padding-left: 10px;
    padding-right: 10px;

    margin-top: 20px;
  }

  .dashboard-layout {
    grid-template-columns:
      minmax(150px, 190px)
      minmax(0, 1fr)
      minmax(150px, 190px);

    gap: 12px;
  }

  .wheel-wrap {
    width: min(100%, 500px);
    max-width: 500px;
  }

  .top-toolbar {
    justify-content: center;
  }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 800px) {

  .toolbar-container {
    position: relative;

    padding:
      8px 8px 0;
  }

  .top-toolbar {
    justify-content: center;

    gap: 6px;
  }


  /* -------------------------------------------------------
     DASHBOARD
  ------------------------------------------------------- */

  .dashboard-shell {
    width: 100%;
    max-width: 100%;

    margin-top: 22px;

    padding-left: 8px;
    padding-right: 8px;
  }


  /* -------------------------------------------------------
     ONE COLUMN
  ------------------------------------------------------- */

  .dashboard-layout {
    display: flex !important;

    flex-direction: column !important;

    width: 100% !important;
    max-width: 100% !important;

    gap: 16px;
  }

  .dashboard-layout > main {
    order: 1;

    width: 100% !important;
    max-width: 100% !important;

    min-width: 0;
  }

  .leaderboard-panel-wrapper {
    order: 2;

    width: 100%;
  }

  .ranked-tracks-panel {
    order: 3;

    width: 100%;
  }


  /* -------------------------------------------------------
     MOBILE WHEEL AREA
  ------------------------------------------------------- */

  .wheel-area {
    width: 100% !important;
    max-width: 100% !important;

    display: flex !important;

    align-items: center !important;
    justify-content: center !important;

    padding:
      8px 0;
  }


  /* -------------------------------------------------------
     MOBILE WHEEL
  ------------------------------------------------------- */

  .wheel-wrap {
    width: min(
      calc(100vw - 16px),
      560px
    ) !important;

    max-width: 560px !important;

    aspect-ratio: 1 / 1;

    margin-left: auto !important;
    margin-right: auto !important;

    flex: 0 1 auto;

    align-self: center;

    left: auto !important;
    right: auto !important;

    transform: none !important;
  }


  .wheel-canvas,
  #wheel {
    width: 100% !important;
    height: 100% !important;

    max-width: 100% !important;
    max-height: 100% !important;

    margin: 0 !important;
  }


  /* -------------------------------------------------------
     MOBILE BUTTONS
  ------------------------------------------------------- */

  .top-toolbar button {
    flex: 1 1 auto;
  }


  /* -------------------------------------------------------
     MOBILE WINNER
  ------------------------------------------------------- */

  .winner-overlay {
    padding: 12px;
  }

  .winner-modal {
    width: 100%;

    max-width: 680px;

    max-height: 92vh;

    padding: 20px;
  }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 480px) {

  .dashboard-shell {
    width: 100%;
    max-width: 100%;

    margin-top: 18px;

    padding-left: 6px;
    padding-right: 6px;
  }


  .top-toolbar {
    gap: 5px;

    padding: 7px;
  }

  .top-toolbar button {
    flex:
      1 1 calc(50% - 5px);

    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;
  }


  /* -------------------------------------------------------
     SMALL MOBILE WHEEL
  ------------------------------------------------------- */

  .wheel-area {
    width: 100% !important;

    padding:
      6px 0;
  }

  .wheel-wrap {
    width: min(
      calc(100vw - 12px),
      560px
    ) !important;

    max-width: 560px !important;

    margin-left: auto !important;
    margin-right: auto !important;

    aspect-ratio: 1 / 1;
  }

  .wheel-canvas,
  #wheel {
    width: 100% !important;
    height: 100% !important;
  }


  /* -------------------------------------------------------
     WINNER
  ------------------------------------------------------- */

  .winner-overlay {
    padding: 8px;
  }

  .winner-modal {
    width: 100%;

    max-width: none;

    padding: 16px;

    border-radius: 15px;
  }

  .winner-modal .winner-name {
    font-size: 1.5rem;
  }

  .winner-modal .winner-player {
    min-height: 166px;
  }

  .winner-modal .winner-player iframe {
    height: 166px;
  }

  .winner-modal .winner-actions {
    justify-content: stretch;
  }

  .winner-modal .winner-actions button,
  .winner-modal .winner-actions a {
    flex: 1 1 100%;
  }
}


/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 360px) {

  .dashboard-shell {
    margin-top: 16px;

    padding-left: 4px;
    padding-right: 4px;
  }

  .wheel-wrap {
    width: min(
      calc(100vw - 8px),
      560px
    ) !important;
  }

  .winner-modal {
    padding: 13px;
  }

  .winner-modal .winner-name {
    font-size: 1.35rem;
  }

  .winner-modal .winner-player,
  .winner-modal .winner-player iframe {
    height: 150px;

    min-height: 150px;
  }
}


/* =========================================================
   VERY NARROW / SHORT VIEWPORT PROTECTION
========================================================= */

@media (max-width: 320px) {

  .wheel-wrap {
    width: calc(100vw - 12px) !important;

    max-width: calc(100vw - 12px) !important;
  }

}


/* =========================================================
   FLEX / GRID OVERFLOW PROTECTION
========================================================= */

main,
section,
.card,
.panel,
.content,
.dashboard-shell,
.dashboard-layout,
.dashboard-layout > main,
.wheel-area,
.wheel-wrap,
.leaderboard-panel-wrapper,
.leaderboard-panel,
.ranked-tracks-panel {
  min-width: 0;
  max-width: 100%;
}


/* =========================================================
   MEDIA ELEMENTS
========================================================= */

img,
canvas,
video,
iframe {
  max-width: 100%;
}


/* =========================================================
   SOUND CLOUD
========================================================= */

.winner-player {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  overflow: hidden;
}

.winner-player iframe {
  display: block;

  width: 100%;
  max-width: 100%;

  border: 0;
}


/* =========================================================
   LONG TEXT PROTECTION
========================================================= */

.winner-name,
.winner-artist,
.winner-notes,
.ranked-tracks-title,
.ranked-tracks-artist,
.leaderboard-artist {
  min-width: 0;

  overflow-wrap: anywhere;
}


/* =========================================================
   RANKED TRACKS
========================================================= */

#rankedTracksPanel {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  overflow: hidden;
}

.ranked-tracks-list {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.ranked-tracks-item {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  display: flex;
  align-items: center;

  gap: 12px;
}

.ranked-tracks-item-main {
  min-width: 0;

  flex: 1 1 auto;
}


/* =========================================================
   FINAL WHEEL CENTERING
========================================================= */

.dashboard-layout > main .wheel-area {
  width: 100% !important;
  max-width: 100% !important;

  display: flex !important;

  align-items: center !important;
  justify-content: center !important;

  margin-left: auto !important;
  margin-right: auto !important;

  padding-left: 0 !important;
  padding-right: 0 !important;
}


.dashboard-layout > main .wheel-wrap {
  position: relative !important;

  margin-left: auto !important;
  margin-right: auto !important;

  left: auto !important;
  right: auto !important;

  transform: none !important;

  display: flex !important;

  align-items: center !important;
  justify-content: center !important;
}


/* =========================================================
   DESKTOP FINAL SIZE
========================================================= */

@media (min-width: 1201px) {

  .dashboard-layout > main .wheel-wrap {
    width: min(100%, 680px) !important;
    max-width: 680px !important;
  }

}


/* =========================================================
   TABLET FINAL SIZE
========================================================= */

@media (min-width: 801px) and (max-width: 1200px) {

  .dashboard-layout > main .wheel-wrap {
    width: min(100%, 560px) !important;
    max-width: 560px !important;
  }

}


/* =========================================================
   MOBILE FINAL SIZE
========================================================= */

@media (max-width: 800px) {

  .dashboard-layout > main .wheel-wrap {
    width: min(
      calc(100vw - 16px),
      560px
    ) !important;

    max-width: 560px !important;

    margin-left: auto !important;
    margin-right: auto !important;
  }

}


/* =========================================================
   SMALL MOBILE FINAL SIZE
========================================================= */

@media (max-width: 480px) {

  .dashboard-layout > main .wheel-wrap {
    width: min(
      calc(100vw - 12px),
      560px
    ) !important;

    max-width: 560px !important;

    margin-left: auto !important;
    margin-right: auto !important;
  }

}


/* =========================================================
   FINAL CANVAS RULE
========================================================= */

.dashboard-layout > main .wheel-wrap .wheel-canvas,
.dashboard-layout > main .wheel-wrap #wheel {
  display: block !important;

  width: 100% !important;
  height: 100% !important;

  max-width: 100% !important;
  max-height: 100% !important;

  min-width: 0 !important;
  min-height: 0 !important;

  margin: 0 !important;

  aspect-ratio: 1 / 1;
}