* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: #fff;
  font-family: Arial, sans-serif;
  overflow: hidden;
  touch-action: none;
  background: #000;
}

#pageBackground {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--tuin-bg-desktop);
}

#pageShade {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at top, rgba(255,204,0,0.06), rgba(0,0,0,0.08) 45%, rgba(0,0,0,0.30) 100%);
  pointer-events: none;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  font-size: 17px;
  background: rgba(0,0,0,0.70);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 0 14px rgba(0,0,0,0.7);
  line-height: 1.5;
}

#topbar {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  background: #ffcc00;
  color: #111;
  border: 0;
  border-radius: 8px;
  font-weight: bold;
  padding: 9px 13px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255,204,0,0.35);
}

button:hover { filter: brightness(1.15); }
button.muted { background: #555; color: #eee; }
button.danger { background: #ff3b58; color: #fff; }

#pauseBtn.paused {
  background: #00d9ff;
  color: #001015;
  box-shadow: 0 0 14px rgba(0,217,255,0.55);
}

#fxBtn {
  background: #151515;
  color: #ffcc00;
  border: 1px solid rgba(255,204,0,0.45);
}

body.fx-low canvas {
  box-shadow: 0 0 12px rgba(255,204,0,0.45);
  backdrop-filter: none;
}

body.fx-low #pageShade {
  opacity: 0.65;
}

#gameWrap {
  position: relative;
  z-index: 5;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 12vw;
  padding-right: 12vw;
}

canvas {
  background: rgba(0,0,0,0.26);
  border: 5px solid #ffcc00;
  box-shadow:
    0 0 30px rgba(255,204,0,0.8),
    inset 0 0 45px rgba(255,255,255,0.06);
  max-width: 74vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  image-rendering: auto;
  backdrop-filter: blur(1px);
}

#help {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 20;
  font-size: 14px;
  color: #ddd;
  background: rgba(0,0,0,0.5);
  padding: 9px 13px;
  border-radius: 9px;
}

#fireBtn {
  position: fixed;
  right: 18px;
  bottom: 150px;
  z-index: 30;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #ff3b58;
  color: #fff;
  font-size: 15px;
  line-height: 1.1;
  display: none;
  box-shadow:
    0 0 24px rgba(255,59,88,0.75),
    inset 0 0 20px rgba(255,255,255,0.20);
}

body.touch-mode #fireBtn { display: block; }

#fireBtn.muted {
  background: #555;
  color: #eee;
  box-shadow:
    0 0 14px rgba(0,0,0,0.75),
    inset 0 0 20px rgba(255,255,255,0.10);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#welcomeOverlay {
  background:
    radial-gradient(circle at top, rgba(255,204,0,0.18), rgba(0,0,0,0.60) 46%, rgba(0,0,0,0.92) 100%);
  z-index: 200;
}

#welcomePanel,
#selectPanel,
#shopPanel,
#patchNotesPanel,
#helpPanel,
#prestigePanel,
#missionsPanel,
#relicsPanel,
#challengesPanel,
#codexPanel,
#skinInspectPanel,
#difficultySelectPanel,
#nicknamePromptPanel,
#backupPanel,
#restorePanel,
#redeemPanel,
#dailyGiftPanel,
#leaderboardPanel {
  width: min(680px, 94vw);
  background:
    radial-gradient(circle at top, rgba(0,217,255,0.10), transparent 38%),
    rgba(5,5,5,0.88);
  border: 3px solid #ffcc00;
  border-radius: 24px;
  box-shadow:
    0 0 40px rgba(255,204,0,0.52),
    inset 0 0 30px rgba(255,255,255,0.06);
  padding: 26px;
  text-align: center;
  backdrop-filter: blur(6px);
  max-height: 92vh;
  overflow: auto;
}

#selectOverlay,
#shopOverlay,
#patchNotesOverlay,
#helpOverlay,
#prestigeOverlay,
#missionsOverlay,
#relicsOverlay,
#challengesOverlay,
#codexOverlay,
#skinInspectOverlay,
#difficultySelectOverlay,
#nicknamePromptOverlay,
#dailyGiftOverlay,
#trophyRoomOverlay,
#runSummaryOverlay,
#presentOpenOverlay,
#backupOverlay,
#restoreOverlay,
#redeemOverlay,
#leaderboardOverlay,
#loadoutRestartOverlay {
  background:
    radial-gradient(circle at top, rgba(255,204,0,0.16), rgba(0,0,0,0.54) 48%, rgba(0,0,0,0.88) 100%);
  display: none;
  align-items: center;
  justify-content: center;
}

#selectOverlay[style*="display: block"],
#shopOverlay[style*="display: block"],
#patchNotesOverlay[style*="display: block"],
#helpOverlay[style*="display: block"],
#prestigeOverlay[style*="display: block"],
#missionsOverlay[style*="display: block"],
#relicsOverlay[style*="display: block"],
#challengesOverlay[style*="display: block"],
#codexOverlay[style*="display: block"],
#skinInspectOverlay[style*="display: block"],
#difficultySelectOverlay[style*="display: block"],
#nicknamePromptOverlay[style*="display: block"],
#dailyGiftOverlay[style*="display: block"],
#trophyRoomOverlay[style*="display: block"],
#trophyRoomOverlay[style*="display: flex"],
#runSummaryOverlay[style*="display: block"],
#presentOpenOverlay[style*="display: block"],
#backupOverlay[style*="display: block"],
#restoreOverlay[style*="display: block"],
#redeemOverlay[style*="display: block"],
#leaderboardOverlay[style*="display: block"],
#loadoutRestartOverlay[style*="display: block"],
#loadoutRestartOverlay[style*="display: flex"] {
  display: flex !important;
}

#selectPanel h1,
#shopPanel h1,
#patchNotesPanel h1,
#prestigePanel h1,
#missionsPanel h1,
#relicsPanel h1,
#challengesPanel h1,
#codexPanel h1,
#runSummaryPanel h1 {
  margin: 0 0 8px;
  color: #ffcc00;
  font-size: 38px;
  text-shadow: 0 0 12px rgba(255,204,0,0.7);
}

#selectPanel p,
#shopPanel p,
#patchNotesPanel p,
#prestigePanel p,
#missionsPanel p,
#relicsPanel p,
#challengesPanel p,
#codexPanel p,
#runSummaryPanel p {
  margin: 0 0 18px;
  color: #ddd;
}

#startBtn,
#shopBackBtn {
  margin-top: 20px;
  font-size: 20px;
  padding: 13px 26px;
}

#resetSaveBtn {
  margin-top: 20px;
  margin-right: 10px;
  font-size: 15px;
  padding: 11px 18px;
}

#musicNote {
  margin-top: 12px;
  font-size: 13px;
  color: #aaa;
}

#dailyHeadDealBox {
  position: absolute;
  left: calc(100% + 24px);
  top: 50%;
  transform: translateY(-50%);
  width: 230px;
  padding: 14px;
  border: 2px solid rgba(0, 217, 255, 0.72);
  border-radius: 20px;
  background:
    radial-gradient(circle at top, rgba(0,217,255,0.22), transparent 45%),
    rgba(0,0,0,0.72);
  box-shadow:
    0 0 24px rgba(0,217,255,0.38),
    inset 0 0 22px rgba(255,255,255,0.05);
  text-align: center;
  z-index: 205;
}

#dailyHeadDealBadge {
  display: inline-block;
  margin-bottom: 9px;
  padding: 5px 9px;
  border: 1px solid rgba(255,204,0,0.75);
  border-radius: 999px;
  color: #ffcc00;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0,0,0,0.55);
  text-shadow: 0 0 8px rgba(255,204,0,0.75);
}

#dailyHeadDealPreviewWrap {
  width: 104px;
  height: 104px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(0,217,255,0.62);
  border-radius: 18px;
  background:
    linear-gradient(rgba(0,217,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,217,255,0.07) 1px, transparent 1px),
    rgba(0,0,0,0.52);
  background-size: 10px 10px;
  box-shadow:
    0 0 18px rgba(0,217,255,0.25),
    inset 0 0 18px rgba(255,204,0,0.07);
  overflow: hidden;
}

#dailyHeadDealPreview {
  width: 82px;
  height: 82px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 10px rgba(255,204,0,0.55));
  animation: dailyHeadFloat 2.4s ease-in-out infinite;
}

@keyframes dailyHeadFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

#dailyHeadDealInfo {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

#dailyHeadDealName {
  color: #fff;
  font-size: 15px;
  text-shadow: 0 0 10px rgba(255,255,255,0.35);
}

#dailyHeadDealSource {
  color: #8defff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#dailyHeadDealPrice {
  color: #ffcc00;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

#dailyHeadDealStatus {
  color: #cfcfcf;
  font-size: 11px;
  line-height: 1.3;
}

#dailyHeadDealActions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

#dailyHeadDealActions button {
  width: 100%;
  padding: 8px 9px;
  font-size: 11px;
  border-radius: 10px;
}

#dailyHeadDealInspectBtn {
  background: #151515;
  color: #8defff;
  border: 1px solid rgba(0,217,255,0.45);
  box-shadow: 0 0 12px rgba(0,217,255,0.20);
}

#dailyHeadDealBox.owned {
  border-color: rgba(255,204,0,0.82);
  box-shadow:
    0 0 24px rgba(255,204,0,0.30),
    inset 0 0 22px rgba(255,255,255,0.05);
}

#dailyHeadDealBox.selected #dailyHeadDealBuyBtn {
  background: #555;
  color: #ddd;
  box-shadow: none;
  cursor: default;
}

@media (min-width: 701px) {
  #welcomePanel {
    position: relative;
    overflow: visible;
  }

  #dailyHeadDealBox {
    position: absolute;
    left: calc(100% + 24px);
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    width: 230px;
  }
}

@media (max-width: 1180px) and (min-width: 701px) {
  #dailyHeadDealBox {
    left: calc(100% + 16px);
    width: 210px;
  }
}

@media (max-width: 900px) {
  #headGrid,
  #shopGrid,
  #secretHeadGrid,
  #presentHeadGrid,
  #specialHeadGrid,
  #backgroundGrid,
  #mobileBackgroundGrid,
  #paddleGrid {
    grid-template-columns: repeat(3, 1fr);
  }

  #prestigeGrid {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 700px) {
  #dailyHeadDealBox {
    position: static;
    transform: none;
    width: 100%;
    margin: 5px auto 8px;
    padding: 7px;
    border-radius: 14px;
  }

  #dailyHeadDealBadge {
    margin-bottom: 6px;
    font-size: 9px;
    padding: 4px 7px;
  }

  #dailyHeadDealPreviewWrap {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    margin-bottom: 4px;
  }

  #dailyHeadDealPreview {
    width: 46px;
    height: 46px;
  }

  #dailyHeadDealName {
    font-size: 12px;
  }

  #dailyHeadDealInfo {
    gap: 2px;
    margin-bottom: 7px;
  }

  #dailyHeadDealSource,
  #dailyHeadDealStatus {
    font-size: 9px;
  }

  #dailyHeadDealPrice {
    font-size: 11px;
  }

  #dailyHeadDealActions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  #dailyHeadDealActions button {
    min-height: 28px;
    padding: 5px 6px;
    font-size: 10px;
  }

  #marketTabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    margin: 12px 0 14px;
  }

  .marketTab {
    min-height: 36px;
    font-size: 10px;
    padding: 8px 5px;
    letter-spacing: 0.015em;
  }

  .marketPageHeader {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    text-align: center;
    padding: 10px;
  }

  .marketPager {
    width: 100%;
    justify-content: space-between;
    border-radius: 14px;
  }

  .marketPager button {
    flex: 1;
  }

  .marketPageText {
    min-width: 56px;
  }

  #pageBackground {
    background: var(--tuin-bg-mobile);
  }

  #pageShade {
    background:
      linear-gradient(
        180deg,
        rgba(0,0,0,0.20) 0%,
        rgba(0,0,0,0.08) 18%,
        rgba(0,0,0,0.46) 50%,
        rgba(0,0,0,0.08) 82%,
        rgba(0,0,0,0.34) 100%
      );
  }

  #hud {
    font-size: 11px;
    padding: 7px 8px;
    top: 8px;
    left: 8px;
    max-width: 94vw;
  }

  #topbar {
    top: auto;
    bottom: 48px;
    right: 8px;
    left: 8px;
    gap: 6px;
    justify-content: center;
    max-width: none;
  }

  button {
    padding: 8px 9px;
    font-size: 11px;
  }

  #fxBtn,
  #pauseBtn {
    font-size: 10px;
  }

  #help {
    font-size: 11px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    text-align: center;
  }

  #fireBtn,
  body.touch-mode #fireBtn {
    right: 14px;
    bottom: 118px;
    width: 72px;
    height: 72px;
    font-size: 12px;
  }

  #gameWrap {
    padding-left: 2vw;
    padding-right: 2vw;
    padding-top: 56px;
    padding-bottom: 118px;
  }

  canvas {
    max-width: 96vw;
    max-height: 63vh;
    background: rgba(0,0,0,0.34);
  }

  #welcomePanel,
  #selectPanel,
  #shopPanel,
  #patchNotesPanel,
  #helpPanel,
  #prestigePanel,
  #missionsPanel,
  #relicsPanel,
  #challengesPanel,
  #codexPanel,
  #skinInspectPanel,
  #difficultySelectPanel,
  #nicknamePromptPanel,
  #runSummaryPanel,
  #backupPanel,
  #restorePanel,
  #redeemPanel,
  #leaderboardPanel {
    padding: 8px 14px 34px;
    max-height: 86dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #welcomePanel {
    width: min(92vw, 520px);
  }

  #welcomeButtons {
    gap: 6px !important;
  }

  #welcomeButtons button,
  #startGameBtn,
  #startBtn {
    min-height: 38px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  #welcomeOverlay {
    align-items: flex-start;
    padding-top: 8px;
    padding-bottom: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #trophyRoomPanel {
    width: 96vw;
    height: 90vh;
  }

  #trophyRoomStage {
    padding: 12px;
  }

  #trophyRoomHeader {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  #trophyRoomHeader h1 {
    font-size: 28px;
  }

  #trophyRoomContent {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  #trophyHeadCloud {
    min-height: 0;
    grid-template-columns: repeat(2, minmax(110px, 1fr));
    padding: 12px;
    gap: 10px;
  }

  .trophyHeadCard img {
    width: 68px;
    height: 68px;
  }

  #trophyGoldZone {
    min-height: 190px;
  }

  #trophyGoldPile {
    max-height: 150px;
  }

  #trophyRoomButtons {
    flex-direction: column;
  }

  #trophyRoomButtons button {
    width: 100%;
  }


  #selectPanel h1,
  #shopPanel h1,
  #patchNotesPanel h1,
  #helpPanel h1,
  #prestigePanel h1,
  #missionsPanel h1,
  #relicsPanel h1,
  #challengesPanel h1,
  #codexPanel h1,
  #runSummaryPanel h1,
  #nicknamePromptPanel h1,
  #backupPanel h1,
  #restorePanel h1,
  #redeemPanel h1,
  #leaderboardPanel h1,
  #skinInspectName {
    font-size: 28px;
  }

  #helpPanel h2,
  .patchNoteBlock h2 { font-size: 17px; }

  #helpPanel p,
  #helpPanel li,
  .patchNoteBlock li,
  #patchNotesPanel p {
    font-size: 13px;
  }

  #selectPanel p,
  #shopPanel p,
  #prestigePanel p,
  #missionsPanel p,
  #relicsPanel p,
  #challengesPanel p,
  #codexPanel p {
    font-size: 14px;
  }

  #headGrid,
  #shopGrid,
  #secretHeadGrid,
  #presentHeadGrid,
  #specialHeadGrid,
  #backgroundGrid,
  #mobileBackgroundGrid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  #prestigeGrid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #runSummaryStats,
  #runSummaryDetails {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .prestigeItem {
    grid-template-columns: 54px 1fr;
    min-height: 112px;
    gap: 3px 9px;
  }

  .prestigeIcon {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .prestigeIcon img {
    width: 100%;
    height: 100%;
  }

  .prestigeItem em,
  .prestigeItem small {
    font-size: 11px;
  }

  .headChoice,
  .shopItem,
  .secretHeadItem,
  .presentHeadItem,
  .specialHeadItem,
  .backgroundItem,
  .mobileBackgroundItem,
  .paddleItem,
  .prestigeItem {
    padding: 8px;
    border-radius: 12px;
  }

  .headChoice img,
  .shopItem img,
  .secretHeadItem img,
  .presentHeadItem img,
  .specialHeadItem img,
  .backgroundItem img,
  .mobileBackgroundItem img {
    width: 74px;
    height: 74px;
  }

  .paddleItem img {
    width: 112px;
    height: 40px;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .headChoice span,
  .shopItem span,
  .secretHeadItem span,
  .presentHeadItem span,
  .specialHeadItem span,
  .backgroundItem span,
  .mobileBackgroundItem span,
  .paddleItem span,
  .prestigeItem span {
    font-size: 12px;
  }

  .secretQuestionMark,
  .presentQuestionMark {
    width: 74px;
    height: 74px;
    border-radius: 14px;
    font-size: 42px;
  }

  #presentMarketBox {
    grid-template-columns: 1fr;
    text-align: center;
  }

  #presentPreviewBox {
    justify-content: center;
    text-align: left;
  }

  #presentOpenPanel {
    padding: 18px;
  }

  #presentOpenTitle {
    font-size: 28px;
  }

  #presentBoxAnimation {
    transform: scale(0.84);
    margin-bottom: 0;
  }

  .soundBadge {
    font-size: 10px;
    padding: 3px 6px;
  }

  #skinInspectCard,
  #skinInspectCard.paddleInspect {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  #skinInspectImageWrap {
    min-height: 190px;
  }

  #skinInspectImage {
    width: 170px;
    height: 170px;
  }

  #skinInspectCard.paddleInspect #skinInspectImage {
    width: min(250px, 82vw);
    height: 110px;
  }

  #skinInspectCard.paddleInspect #skinInspectImageWrap {
    min-height: 150px;
  }

  #skinInspectInfo {
    text-align: center;
  }

  #skinInspectFlavor {
    font-size: 13px;
  }

  #playerCodeText {
    font-size: 20px;
    letter-spacing: 0.04em;
  }

  #nicknameInput,
  #nicknamePromptInput,
  #restoreCodeInput,
  #redeemCodeInput {
    font-size: 16px;
    padding: 12px;
  }

  #nicknameRow {
    grid-template-columns: 1fr;
  }

  #saveNicknameBtn {
    width: 100%;
  }

  #nicknamePromptButtons,
  #dailyGiftButtons,
  #backupButtons,
  #restoreButtons,
  #redeemButtons,
  #leaderboardButtons {
    flex-direction: column;
  }

  #difficultyCardGrid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .difficultyCard {
    min-height: 118px;
    padding: 14px;
  }

  .difficultyCard strong {
    font-size: 22px;
  }

  .difficultyCard span {
    font-size: 12px;
  }

  .difficultyCard em {
    margin-top: 8px;
    font-size: 10px;
  }

  #difficultySelectBackBtn {
    width: 100%;
  }

  #runSummaryNewBestBanner strong {
    font-size: 22px;
  }

  #runSummaryNewBestBanner span {
    font-size: 11px;
  }

  #nicknamePromptButtons button,
  #dailyGiftButtons button,
  #backupButtons button,
  #restoreButtons button,
  #redeemButtons button,
  #leaderboardButtons button {
    width: 100%;
  }

  .leaderboardRow {
    grid-template-columns: 48px 1fr 78px;
    gap: 8px;
    padding: 11px 10px;
  }

  .leaderboardCoins {
    grid-column: 2 / -1;
    text-align: left;
    color: #8defff;
  }

  .leaderboardRank {
    font-size: 18px;
  }

  .leaderboardPlayer strong {
    font-size: 15px;
  }

  .leaderboardPlayer span {
    font-size: 10px;
  }

  .leaderboardScore {
    font-size: 19px;
  }
}

/* Phone landscape menu safety:
   keep the Daily Head Deal stacked inside the start menu instead of floating right. */
@media (max-height: 820px) and (orientation: landscape) and (pointer: coarse) {
  #welcomePanel {
    width: min(94vw, 620px) !important;
    max-height: 84dvh !important;
    padding: 8px 12px 28px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #dailyHeadDealBox {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    margin: 6px auto 8px !important;
    padding: 7px !important;
  }

  #dailyHeadDealPreviewWrap {
    width: 56px !important;
    height: 56px !important;
    margin-bottom: 4px !important;
  }

  #dailyHeadDealPreview {
    width: 46px !important;
    height: 46px !important;
  }

  #dailyHeadDealActions {
    grid-template-columns: 1fr 1fr !important;
  }

  #welcomeButtons button,
  #startGameBtn,
  #startBtn {
    min-height: 34px !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
  }
}
