/* ===========================================
   DM Bottles – Punkfish logic game
   =========================================== */

.pf-tool-frame.dm-bottles-container {
  max-width: 1200px;
  width: min(1200px, calc(100vw - 2rem));
  overflow: hidden;
}

.dm-bottles-container,
.dm-bottles-container *,
.dm-bottles-container *::before,
.dm-bottles-container *::after {
  box-sizing: border-box;
}

.dm-bottles-container {
  --pf-purple: #3b22a3;
  --pf-yellow: #ffea00;
  --pf-ink: #1f2540;
  --pf-muted: #657085;
  --pf-line: rgba(59, 34, 163, 0.18);
  --pf-soft: #f6f4ff;
  --dive1: #3b22a3;
  --dive2: #008c95;
  --spare: #ffb000;

  font-family: inherit;
  color: var(--pf-ink);
}

.dm-bottle-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 1rem;
  align-items: stretch;
  padding: 1.25rem;
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(255,234,0,0.32), transparent 34%),
    linear-gradient(135deg, #3b22a3, #24116f 64%, #170a49);
  color: #fff;
  overflow: hidden;
  position: relative;
}

.dm-bottle-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  color: var(--pf-yellow);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dm-bottle-hero h1 {
  margin: 0.65rem 0 0.55rem;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
  color: #fff;
}

.dm-bottle-hero p {
  max-width: 72ch;
  margin: 0;
  line-height: 1.55;
  color: rgba(255,255,255,0.9);
}

.dm-bottle-mini-car {
  align-self: center;
  min-height: 170px;
  border-radius: 18px;
  background: rgba(255,255,255,0.12);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.16);
}

.dm-bottle-mini-car::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 10%;
  bottom: 34px;
  height: 64px;
  border-radius: 26px 52px 18px 18px;
  background: rgba(255,234,0,0.9);
  box-shadow: inset 0 -12px 0 rgba(0,0,0,0.14);
}

.dm-bottle-mini-car::after {
  content: "";
  position: absolute;
  left: 27%;
  bottom: 84px;
  width: 42%;
  height: 48px;
  border-radius: 32px 46px 0 0;
  background: rgba(255,255,255,0.3);
  border: 8px solid rgba(255,234,0,0.85);
}

.dm-mini-wheel {
  position: absolute;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #14142d;
  border: 8px solid rgba(255,255,255,0.25);
  z-index: 2;
}

.dm-mini-wheel.left { left: 24%; }
.dm-mini-wheel.right { right: 20%; }

.dm-mini-bottle {
  position: absolute;
  z-index: 3;
  width: 20px;
  border-radius: 12px 12px 6px 6px;
  background: #3b22a3;
  bottom: 68px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2);
}

.dm-mini-bottle:nth-child(1) { left: 48%; height: 56px; }
.dm-mini-bottle:nth-child(2) { left: 56%; height: 44px; background: #008c95; }
.dm-mini-bottle:nth-child(3) { left: 64%; height: 50px; background: #ffb000; }

.dm-game-grid {
  display: grid;
  grid-template-columns: minmax(255px, 0.72fr) minmax(0, 1.28fr);
  gap: 1rem;
  margin-top: 1rem;
}

.dm-panel {
  background: #fff;
  border: 1px solid var(--pf-line);
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(31,37,64,0.08);
  overflow: hidden;
}

.dm-panel-head {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid var(--pf-line);
  background: linear-gradient(180deg, #fff, var(--pf-soft));
}

.dm-panel-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  color: var(--pf-purple);
}

.dm-panel-head p {
  margin: 0;
  color: var(--pf-muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.dm-source-list {
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
}

.dm-bottle-card {
  position: relative;
  min-height: 178px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.35rem;
  padding: 0.65rem;
  border: 2px solid rgba(59,34,163,0.16);
  border-radius: 16px;
  background: #fff;
  cursor: grab;
  user-select: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.dm-bottle-card:active {
  cursor: grabbing;
}

.dm-bottle-card:hover,
.dm-bottle-card.dm-selected {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(31,37,64,0.14);
  border-color: var(--pf-purple);
}

.dm-bottle-card.dm-selected::after {
  content: attr(data-selected-label);
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: var(--pf-yellow);
  color: #17102e;
  font-size: 0.7rem;
  font-weight: 900;
}

.dm-cylinder-wrap {
  min-height: 96px;
  display: flex;
  align-items: end;
  justify-content: center;
  padding-top: 0.4rem;
}

.dm-cylinder {
  position: relative;
  width: 42px;
  height: 88px;
  border-radius: 18px 18px 10px 10px;
  background: var(--bottle-color, var(--pf-purple));
  box-shadow:
    inset 7px 0 0 rgba(255,255,255,0.24),
    inset -7px 0 0 rgba(0,0,0,0.16),
    0 8px 12px rgba(31,37,64,0.16);
}

.dm-cylinder::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 12px;
  width: 18px;
  height: 18px;
  border-radius: 8px 8px 4px 4px;
  background: #303348;
}

.dm-cylinder::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 7px;
  right: 7px;
  height: 22px;
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
}

.dm-bottle-card[data-shape="ten"] .dm-cylinder { height: 88px; width: 40px; }
.dm-bottle-card[data-shape="short"] .dm-cylinder { height: 76px; width: 50px; }
.dm-bottle-card[data-shape="long"] .dm-cylinder { height: 102px; width: 40px; }
.dm-bottle-card[data-shape="large"] .dm-cylinder { height: 102px; width: 50px; }

.dm-bottle-meta {
  text-align: center;
}

.dm-bottle-meta strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  color: var(--pf-ink);
}

.dm-bottle-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
}

.dm-tag {
  display: inline-flex;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  background: rgba(59,34,163,0.08);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--pf-purple);
}

.dm-tag[data-use="dive1"] { background: rgba(59,34,163,0.11); color: #3b22a3; }
.dm-tag[data-use="dive2"] { background: rgba(0,140,149,0.12); color: #00727a; }
.dm-tag[data-use="spare"] { background: rgba(255,176,0,0.18); color: #8a5a00; }

.dm-trunk-panel {
  min-width: 0;
}

.dm-trunk-stage {
  padding: 1rem;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(59,34,163,0.04), transparent),
    #fff;
}

.dm-car-shell {
  position: relative;
  max-width: 100%;
  min-height: 545px;
  padding: 2rem 1.25rem 1.25rem;
  border-radius: 26px;
  background: linear-gradient(180deg, #f2f0ff, #ffffff);
  border: 2px solid rgba(59,34,163,0.12);
  overflow: hidden;
}

.dm-car-shell::before {
  content: "";
  position: absolute;
  left: 2.5%;
  right: 2.5%;
  bottom: 18px;
  height: 145px;
  border-radius: 72px 120px 28px 28px;
  background: linear-gradient(180deg, #ffea00, #eacb00);
  box-shadow: inset 0 -18px 0 rgba(31,37,64,0.18);
}

.dm-car-shell::after {
  content: "";
  position: absolute;
  left: 17%;
  right: 28%;
  bottom: 136px;
  height: 98px;
  border-radius: 80px 96px 0 0;
  background: rgba(59,34,163,0.16);
  border: 18px solid #ffea00;
  border-bottom: none;
}

.dm-trunk-mouth {
  position: relative;
  z-index: 3;
  max-width: 640px;
  width: 100%;
  margin-left: auto;
  padding: 1rem;
  border-radius: 22px 22px 16px 16px;
  background: #25263d;
  border: 8px solid #17182a;
  box-shadow: 0 22px 30px rgba(31,37,64,0.22);
}

.dm-layer {
  display: grid;
  min-width: 0;
  grid-template-columns: 110px repeat(4, minmax(70px, 1fr));
  gap: 0.55rem;
  align-items: stretch;
  margin-bottom: 0.55rem;
}

.dm-layer:last-child { margin-bottom: 0; }

.dm-layer-label {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.88);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.dm-slot {
  position: relative;
  min-width: 0;
  min-height: 142px;
  border: 2px dashed rgba(255,255,255,0.28);
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  color: rgba(255,255,255,0.58);
  font-size: 0.75rem;
  text-align: center;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.dm-slot.dm-drop-ready,
.dm-slot:hover {
  border-color: var(--pf-yellow);
  background: rgba(255,234,0,0.14);
}

.dm-slot .dm-bottle-card {
  width: 100%;
  min-height: 132px;
  padding: 0.45rem;
  border-width: 2px;
  box-shadow: none;
  transform: none;
}

.dm-slot .dm-cylinder-wrap {
  min-height: 64px;
}

.dm-slot .dm-cylinder {
  transform: rotate(90deg) scale(0.88);
  transform-origin: center;
}

.dm-slot .dm-bottle-card[data-shape="large"] .dm-cylinder {
  transform: rotate(90deg) scale(0.82);
}

.dm-slot .dm-bottle-meta strong {
  font-size: 0.75rem;
}

.dm-slot .dm-tag {
  font-size: 0.62rem;
}

.dm-car-wheel {
  position: absolute;
  z-index: 4;
  bottom: 28px;
  width: 74px;
  height: 74px;
  border-radius: 999px;
  background: #17182a;
  border: 12px solid #5c6076;
}

.dm-car-wheel.left { left: 19%; }
.dm-car-wheel.right { right: 14%; }

.dm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding: 0 1rem 1rem;
}

.dm-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.78rem 1rem;
  font-weight: 900;
  cursor: pointer;
  background: var(--pf-purple);
  color: #fff;
  box-shadow: 0 8px 18px rgba(59,34,163,0.22);
}

.dm-btn:hover { filter: brightness(1.04); }

.dm-btn-secondary {
  background: #fff;
  color: var(--pf-purple);
  border: 2px solid rgba(59,34,163,0.18);
  box-shadow: none;
}

.dm-status {
  flex: 1 1 220px;
  color: var(--pf-muted);
  font-size: 0.92rem;
}

.dm-score-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--pf-line);
  box-shadow: 0 10px 28px rgba(31,37,64,0.08);
}

.dm-score-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.dm-score-number {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pf-yellow), #ffc400);
  color: #17102e;
  font-size: 1.55rem;
  font-weight: 1000;
  border: 5px solid #fff;
  box-shadow: 0 8px 20px rgba(31,37,64,0.16);
}

.dm-score-head h2 {
  margin: 0 0 0.35rem;
  color: var(--pf-purple);
}

.dm-score-head p {
  margin: 0;
  color: var(--pf-muted);
  line-height: 1.45;
}

.dm-feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.dm-feedback-box {
  border-radius: 16px;
  padding: 0.9rem;
  background: var(--pf-soft);
  border: 1px solid rgba(59,34,163,0.12);
}

.dm-feedback-box h3 {
  margin: 0 0 0.55rem;
  color: var(--pf-purple);
  font-size: 1rem;
}

.dm-feedback-box ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--pf-ink);
  line-height: 1.45;
}

.dm-summary {
  margin-top: 1rem;
  padding: 1rem;
  border-left: 6px solid var(--pf-yellow);
  border-radius: 14px;
  background: #fffbdb;
  color: #332900;
}

.dm-summary h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.dm-summary p {
  margin: 0;
  line-height: 1.5;
}

.dm-hide {
  display: none !important;
}

@media (max-width: 980px) {
  .dm-bottle-hero,
  .dm-game-grid,
  .dm-feedback-grid {
    grid-template-columns: 1fr;
  }

  .dm-trunk-mouth {
    margin: 0 auto;
  }
}

@media (max-width: 760px) {
  .pf-tool-frame.dm-bottles-container {
    width: min(100%, calc(100vw - 1rem));
  }

  .dm-bottle-hero,
  .dm-trunk-stage,
  .dm-panel-head,
  .dm-actions,
  .dm-score-panel {
    padding: 0.85rem;
  }

  .dm-car-shell {
    min-height: auto;
    padding: 0.5rem;
    border-radius: 18px;
  }

  .dm-car-shell::before,
  .dm-car-shell::after,
  .dm-car-wheel {
    display: none;
  }

  .dm-trunk-mouth {
    border-width: 5px;
    padding: 0.55rem;
  }

  .dm-layer {
    grid-template-columns: 1fr;
  }

  .dm-layer-label {
    min-height: auto;
  }

  .dm-slot {
    min-height: 118px;
  }

  .dm-source-list {
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  }
}

/* v3: movement-based evaluation */
.dm-score-number {
  grid-template-rows: 1fr auto;
  line-height: 1;
  text-align: center;
}

.dm-score-number small {
  margin-top: 0.15rem;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dm-move-breakdown,
.dm-spare-note {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 16px;
  background: #fffdf0;
  border: 1px solid rgba(255, 176, 0, 0.28);
}

.dm-move-breakdown h3,
.dm-spare-note h3 {
  margin: 0 0 0.75rem;
  color: var(--pf-purple);
  font-size: 1rem;
}

.dm-move-breakdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.dm-move-breakdown li {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.15rem 0.75rem;
  align-items: start;
  padding: 0.65rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(59, 34, 163, 0.1);
}

.dm-move-breakdown li strong {
  grid-row: span 2;
  display: grid;
  place-items: center;
  min-height: 2.5rem;
  border-radius: 12px;
  background: var(--pf-purple);
  color: #fff;
  font-size: 1.2rem;
}

.dm-move-breakdown li span {
  font-weight: 900;
  color: var(--pf-ink);
}

.dm-move-breakdown li small {
  color: var(--pf-muted);
  line-height: 1.35;
}

.dm-spare-note p {
  margin: 0;
  color: var(--pf-ink);
  line-height: 1.45;
}

.dm-bottle-hero p {
  margin-top: 0.8rem;
}
