* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(circle at 20% 10%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 80% 20%, #fff 0 2px, transparent 3px),
    linear-gradient(180deg, #ffd6ea, #ff9dcc);
}

.app {
  width: 100vw;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

/* ===================== HUD ===================== */

.hud {
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.score-card {
  height: 56px;
  background: linear-gradient(180deg, #fff, #ffe6f1);
  border: 3px solid #ff75ad;
  border-radius: 16px;
  text-align: center;
  padding: 5px 8px;
  box-shadow: 0 5px 0 #e94c91;
  transition: transform 0.15s ease;
}

.score-card p {
  margin: 0;
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 900;
  color: #ef3d8c;
}

.score-card h2 {
  margin: 0;
  font-size: 22px;
  color: #831945;
  transition: transform 0.15s ease;
}

.score-pop {
  animation: scorePop 0.35s cubic-bezier(0.36, 1.4, 0.5, 1);
}

@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===================== BUTTONS ===================== */

button {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ff70ae, #ec2d83);
  color: white;
  font-weight: 900;
  font-size: 13px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b91d60;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b91d60;
}

/* ===================== DESKTOP LAYOUT ===================== */

.desktop-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: hidden;
}

.side-panel {
  display: none;
}

.desktop-title {
  display: none;
}

/* ===================== GAME WRAP ===================== */

.game-wrap {
  position: relative;
  width: 100%;
  height: calc(100dvh - 200px);
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 15%, rgba(255,255,255,.12), transparent 32%),
    linear-gradient(180deg, #5a174e, #281326);
  box-shadow:
    0 6px 0 #ec6ca4,
    0 0 0 4px #ffb7d6;
  transition: transform 0.05s ease;
  flex-shrink: 0;
}

/* ===================== MOBILE BOTTOM PANEL ===================== */

.mobile-bottom-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
  flex-shrink: 0;
  overflow: hidden;
}

.mobile-bottom-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .72);
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 12px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.mobile-current {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-current-thumb {
  width: 34px;
  height: 30px;
  border: 2px dashed #ff8fbd;
  border-radius: 8px;
  background: #fffafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.mobile-current-thumb img {
  max-width: 28px;
  max-height: 24px;
  object-fit: contain;
}

.mobile-current small {
  display: none;
}

.mobile-current strong {
  font-size: 11px;
  color: #7d143d;
  font-weight: 900;
  white-space: nowrap;
}

.mobile-evo-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.evo-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  opacity: .3;
  transition: opacity .3s ease, transform .3s ease;
}

.evo-dot.active {
  opacity: 1;
}

.evo-dot.reached {
  opacity: 1;
}

.evo-dot img {
  width: 24px;
  height: 20px;
  object-fit: contain;
  border-radius: 5px;
  border: 2px solid #ffccdd;
  background: white;
  padding: 1px;
}

.evo-dot.reached img {
  border-color: #ef3d8c;
}

.evo-dot span {
  font-size: 7px;
  font-weight: 900;
  color: #7d143d;
  line-height: 1;
}

.mobile-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.mobile-controls button {
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 900;
  box-shadow: 0 2px 0 #b91d60;
}

.mobile-controls button:active {
  box-shadow: 0 1px 0 #b91d60;
  transform: translateY(1px);
}

#mobileMusicBtn {
  background: linear-gradient(180deg, #87d958, #4dae2f);
  box-shadow: 0 2px 0 #2f7e21;
}

#mobileMusicBtn:active {
  box-shadow: 0 1px 0 #2f7e21;
}

.mobile-merge-log {
  background: rgba(255, 255, 255, .65);
  border: 2px solid rgba(255, 255, 255, .85);
  border-left: 4px solid #87d958;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 900;
  color: #7d143d;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* caption box */
.mobile-caption {
  background: linear-gradient(135deg, rgba(255,255,255,.55), rgba(255,230,242,.55));
  border: 2px dashed #ffccdd;
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 9px;
  font-weight: 900;
  color: #a04070;
  text-align: center;
  line-height: 1.4;
  font-style: italic;
  flex-shrink: 0;
  animation: captionBlink 3s ease-in-out infinite;
}

@keyframes captionBlink {
  0%, 100% { opacity: .7; }
  50%      { opacity: 1; }
}

/* ===================== AIM LINE ===================== */

.aim-line {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  border-left: 3px dotted rgba(255, 255, 255, 0.5);
  pointer-events: none;
  display: none;
  transition: left 0.04s ease-out;
}

/* ===================== WARNING LINE ===================== */

.warning-line {
  position: absolute;
  top: 88px;
  left: 0;
  width: 100%;
  border-top: 3px dashed #ff4f77;
  filter: drop-shadow(0 0 4px #ff4f77);
  pointer-events: none;
  animation: warningPulse 1.2s ease-in-out infinite;
}

@keyframes warningPulse {
  0%, 100% { opacity: 0.5; filter: drop-shadow(0 0 4px #ff4f77); }
  50%      { opacity: 1;   filter: drop-shadow(0 0 10px #ff4f77); }
}

/* ===================== START / GAME OVER ===================== */

.start-screen, .game-over {
  position: absolute;
  inset: 0;
  z-index: 10;
  color: #7b143d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.8) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 26%, rgba(255,255,255,.8) 0 2px, transparent 3px),
    linear-gradient(180deg, rgba(255,230,242,.96), rgba(255,198,224,.96));
  animation: overlayIn 0.35s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.start-screen::before {
  content: "🌸";
  font-size: 44px;
  margin-bottom: -4px;
  animation: floatIcon 2.5s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.start-screen h1, .game-over h1 {
  margin: 0;
  font-size: 28px;
  line-height: .95;
  color: #ef3d8c;
  text-shadow:
    2px 2px 0 #fff,
    0 4px 0 rgba(185, 29, 96, .18);
}

.start-screen p, .game-over p {
  max-width: 280px;
  margin: 0;
  line-height: 1.55;
  font-size: 13px;
  font-weight: 800;
}

.start-screen p {
  background: linear-gradient(135deg, #fff 0%, #ffe6f1 100%);
  border-radius: 14px;
  padding: 12px 14px;
  border: 2px dashed #ff9bc5;
  font-size: 12px;
  line-height: 1.6;
  color: #9a1b54;
}

.start-screen button {
  margin-top: 4px;
  padding: 12px 28px;
  font-size: 15px;
  border-radius: 16px;
}

.game-over {
  display: none;
  background: rgba(70, 15, 50, .88);
  backdrop-filter: blur(6px);
  color: white;
}

.game-over h1 {
  color: #fff;
  text-shadow: 2px 2px 0 #ef3d8c;
}

/* ===================== MOBILE PREVIEW MODAL ===================== */

.mobile-preview-btn {
  display: none;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.preview-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.preview-content {
  width: 90%;
  max-width: 360px;
  background: #ffd9ea;
  border-radius: 22px;
  padding: 16px;
  border: 3px solid white;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.preview-modal.show .preview-content {
  transform: scale(1) translateY(0);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.preview-header h3 {
  color: #ff3d91;
  margin: 0;
  font-size: 16px;
}

.preview-header button {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff73b1, #ec2d83);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 #b91d60;
}

.preview-header button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b91d60;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.preview-card {
  background: white;
  border-radius: 14px;
  padding: 8px;
  text-align: center;
  border: 2px solid #ff9bc5;
}

.preview-card img {
  width: 100%;
  height: 80px;
  object-fit: contain;
}

.preview-card.locked img {
  filter: brightness(0);
  opacity: .55;
}

.preview-card span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
}

.collection-footer {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  color: #7d143d;
}

/* ===========================================================
   DESKTOP BREAKPOINT (>= 900px)
=========================================================== */

@media (min-width: 900px) {

  .app {
    max-width: 1040px;
    padding: 8px 10px;
  }

  /* hide mobile panel on desktop */
  .mobile-bottom-panel {
    display: none;
  }

  .desktop-title {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
  }

  .desktop-title h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1;
    color: #ef3d8c;
    text-shadow: 3px 3px 0 #fff;
  }

  .desktop-title span {
    font-size: 12px;
    font-weight: 900;
    color: #7d143d;
  }

  .hud {
    width: 560px;
    height: 58px;
    margin: 0 0 10px;
  }

  .score-card {
    height: 52px;
    padding: 5px 8px;
  }

  .score-card h2 {
    font-size: 22px;
  }

  .hud button {
    padding: 10px 18px;
    font-size: 15px;
    border-radius: 17px;
  }

  .desktop-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 680px 240px;
    gap: 18px;
    justify-content: center;
    align-items: stretch;
    min-height: 0;
  }

  .game-wrap {
    width: 680px;
    height: calc(100dvh - 100px);
    max-height: none;
    aspect-ratio: auto;
    flex: none;
    border-radius: 26px;
    border-width: 4px;
    box-shadow:
      0 8px 0 #ec6ca4,
      0 0 0 5px #ffb7d6;
  }

  .game-wrap::after {
    border-radius: 22px;
  }

  .start-screen, .game-over {
    padding: 28px;
    gap: 14px;
  }

  .start-screen::before {
    font-size: 54px;
    margin-bottom: -8px;
  }

  .start-screen h1, .game-over h1 {
    font-size: 36px;
    text-shadow:
      3px 3px 0 #fff,
      0 5px 0 rgba(185, 29, 96, .18);
  }

  .start-screen p, .game-over p {
    max-width: 310px;
    font-size: 14px;
    line-height: 1.7;
  }

  .start-screen button {
    font-size: 15px;
    padding: 13px 18px;
    border-radius: 17px;
  }

  button {
    font-size: 15px;
    padding: 13px 18px;
    border-radius: 17px;
    box-shadow: 0 6px 0 #b91d60;
  }

  button:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #b91d60;
  }

  @media (hover: hover) {
    button:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 0 #b91d60;
    }
    button:active {
      transform: translateY(4px);
      box-shadow: 0 2px 0 #b91d60;
    }
  }

  .left-panel {
    display: none;
  }

  .right-panel {
    width: 240px;
    height: calc(100dvh - 100px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.58);
    border: 3px solid rgba(255,255,255,.9);
    box-shadow: 0 7px 0 #ec6ca4;
    overflow: hidden;
  }

  .next-card,
  .side-section,
  .side-controls,
  .merge-log {
    width: 100%;
    background: rgba(255,255,255,.78);
    border: 2px solid #ff9bc7;
    border-radius: 14px;
    padding: 10px;
  }

  .next-card {
    display: grid;
    grid-template-columns: 66px 1fr;
    align-items: center;
    gap: 10px;
    min-height: 78px;
  }

  .next-thumb {
    width: 62px;
    height: 56px;
    border: 2px dashed #ff8fbd;
    border-radius: 12px;
    background: #fffafc;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .next-thumb img {
    max-width: 58px;
    max-height: 52px;
    object-fit: contain;
  }

  .next-card small {
    display: block;
    font-size: 11px;
    font-weight: 900;
    color: #ef3d8c;
  }

  .next-card strong {
    display: block;
    font-size: 16px;
    color: #7d143d;
  }

  .side-section {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .side-section h3 {
    margin: 0 0 8px;
    color: #ef3d8c;
    font-size: 15px;
  }

  .evo-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .evo-list .preview-item {
    position: relative;
    width: 100%;
    height: 42px;
    display: grid;
    grid-template-columns: 18px 1fr 16px 40px;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border: 2px solid #ff8fbd;
    border-radius: 12px;
    background: rgba(255,255,255,.78);
    overflow: hidden;
    box-shadow: none;
    transition: background 0.3s ease, border-color 0.3s ease;
  }

  .evo-list .preview-item.unlocked {
    background: rgba(255, 255, 255, .95);
    border-color: #ef3d8c;
  }

  .evo-list .preview-item p {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 900;
    color: #7d143d;
    line-height: 1.1;
  }

  .evo-list .preview-item b {
    font-size: 12px;
    color: #7d143d;
  }

  .evo-list .preview-item img {
    width: 40px;
    height: 30px;
    object-fit: contain;
    transition: filter 0.3s ease;
  }

  .evo-list .preview-item.locked img {
    filter: brightness(0) blur(1px);
    opacity: .55;
  }

  .evo-list .preview-item.locked::after {
    content: "🔒";
    position: absolute;
    right: 4px;
    bottom: 2px;
    font-size: 11px;
  }

  .evo-color {
    width: 14px;
    height: 14px;
    border: 2px dashed currentColor;
    border-radius: 5px;
  }

  .evo-color.pink   { color: #ff5da2; }
  .evo-color.yellow { color: #f5c542; }
  .evo-color.green  { color: #75c95a; }
  .evo-color.blue   { color: #5aa7ff; }
  .evo-color.purple { color: #a374ff; }
  .evo-color.brown  { color: #b7865b; }
  .evo-color.teal   { color: #54b7aa; }

  .side-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .side-controls button {
    height: 44px;
    padding: 0;
    border-radius: 12px;
    font-size: 13px;
  }

  #musicBtn {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, #87d958, #4dae2f);
    box-shadow: 0 5px 0 #2f7e21;
  }

  @media (hover: hover) {
    #musicBtn:hover {
      box-shadow: 0 7px 0 #2f7e21;
    }
  }

  .merge-log {
    min-height: 58px;
    font-size: 12px;
    font-weight: 900;
    color: #7d143d;
    border-left: 6px solid #87d958;
    line-height: 1.35;
    transition: border-color 0.3s ease;
  }
}