.screen-play {
  position: relative;
}

.play-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 600px;
  height: 100%;
  margin: 0 auto;
  padding: calc(8px + var(--safe-top)) 10px 10px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}

.hud-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 40%), linear-gradient(180deg, #78d4ff, #2f9be8);
  box-shadow: 0 4px 0 #17609f, 0 8px 12px rgba(10, 2, 30, 0.4);
  color: #fff;
  font-size: 22px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.hud-btn-hint {
  background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 40%), linear-gradient(180deg, #ffe680, #ffaf2b);
  box-shadow: 0 4px 0 #b36b00, 0 8px 12px rgba(10, 2, 30, 0.4);
  color: #55270a;
}

.hud-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(20, 6, 50, 0.5);
}

.hud-title {
  display: grid;
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.05;
}

.hud-world {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
}

.hud-level {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(138, 47, 181, 0.9);
}

.goal-strip {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.goal-strip .chip {
  min-height: 30px;
  padding: 3px 11px;
  background: rgba(20, 6, 50, 0.55);
  font-size: 13px;
}

.goal-strip .chip b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
}

.chip-par {
  color: var(--lavender);
}

.tip {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 16px;
  background: rgba(20, 6, 50, 0.4);
  font-size: 13px;
  line-height: 1.25;
  color: var(--cream);
}

.tip .icon {
  color: var(--gold);
}

.tip span:last-child {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.board-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 26px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 70%), rgba(20, 6, 50, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 4px 18px rgba(10, 2, 30, 0.35), 0 6px 0 rgba(20, 6, 50, 0.45);
  touch-action: none;
}

.board-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.controls {
  display: grid;
  flex: none;
}

.controls[data-phase='build'] .panel-walk,
.controls[data-phase='walk'] .panel-build {
  display: none;
}

.build-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.tray {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 62px;
  padding: 6px 8px;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(20, 6, 50, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.slot {
  display: grid;
  flex: none;
  place-items: center;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  touch-action: none;
  cursor: grab;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.slot.is-selected {
  border-color: var(--gold);
  background: rgba(255, 210, 63, 0.2);
  transform: translateY(-2px);
}

.slot.is-used {
  background: rgba(255, 255, 255, 0.04);
}

.slot-canvas {
  pointer-events: none;
}

.tools {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 6px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 60px;
  min-height: 44px;
  padding: 4px 8px;
  border: 2px solid rgba(255, 255, 255, 0.26);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  box-shadow: 0 3px 0 rgba(20, 6, 50, 0.5);
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}

.tool-btn .icon {
  font-size: 19px;
}

.tool-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 rgba(20, 6, 50, 0.5);
}

.tool-btn:disabled {
  opacity: 0.4;
}

.btn-go {
  --btn-a: #86ec78;
  --btn-b: #2fb84a;
  --btn-edge: #17782f;
  width: 100%;
  min-height: 54px;
  margin-top: 8px;
  font-size: 23px;
  opacity: 0.72;
  filter: saturate(0.7);
}

.btn-go.is-ready {
  opacity: 1;
  filter: none;
  animation: goPulse 1.6s ease-in-out infinite;
}

@keyframes goPulse {
  0%,
  100% {
    box-shadow: 0 5px 0 var(--btn-edge), 0 10px 18px rgba(20, 6, 50, 0.35), 0 0 0 0 rgba(134, 236, 120, 0.7);
  }
  50% {
    box-shadow: 0 5px 0 var(--btn-edge), 0 10px 18px rgba(20, 6, 50, 0.35), 0 0 0 12px rgba(134, 236, 120, 0);
  }
}

.panel-walk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 5px;
  flex: none;
}

.pad-spacer {
  display: block;
}

.pad-btn {
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 20px;
  background: radial-gradient(circle at 32% 20%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%), linear-gradient(180deg, #ff7ae6, #d23cc6);
  box-shadow: 0 4px 0 #8a1a84, 0 8px 12px rgba(10, 2, 30, 0.35);
  color: #fff;
  font-size: 26px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.pad-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #8a1a84;
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

.pad-left {
  grid-column: 1;
  grid-row: 2;
}

.pad-down {
  grid-column: 2;
  grid-row: 2;
}

.pad-right {
  grid-column: 3;
  grid-row: 2;
}

.tools-walk {
  flex: 1;
  min-width: 0;
}

.tools-walk .tool-btn {
  flex-direction: row;
  justify-content: flex-start;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  font-size: 13.5px;
}

.drag-chip {
  filter: drop-shadow(0 8px 6px rgba(10, 2, 30, 0.45));
  opacity: 0.95;
}

.win {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.win-star {
  display: inline-flex;
  font-size: 60px;
  color: rgba(255, 255, 255, 0.15);
  transform: translateY(0) scale(0.85);
  transition: transform 0.4s cubic-bezier(0.3, 1.8, 0.5, 1), filter 0.3s ease;
}

.win-star:nth-child(2) {
  transform: translateY(-10px) scale(0.95);
}

.win-star svg path {
  fill: rgba(20, 6, 50, 0.5);
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.4;
}

.win-star.is-on {
  filter: drop-shadow(0 0 12px rgba(255, 210, 63, 0.9));
  transform: scale(1.1);
}

.win-star:nth-child(2).is-on {
  transform: translateY(-10px) scale(1.2);
}

.win-star.is-on svg path {
  fill: var(--gold);
  stroke: #b97200;
}

.win-summary {
  text-align: center;
  font-size: 14.5px;
  color: var(--lavender);
}

.win-list {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.win-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 14px;
  background: rgba(20, 6, 50, 0.4);
  font-size: 14.5px;
}

.win-list .is-done .icon {
  color: var(--mint);
}

.win-list .is-missed {
  opacity: 0.7;
}

.win-list .is-missed .icon {
  color: var(--berry);
}

.win-score {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  width: 100%;
  padding: 8px 0 0;
}

.win-score span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lavender);
}

.win-score strong {
  font-size: 34px;
  color: var(--gold);
  text-shadow: 0 3px 0 #8a3b00;
}

.tag-best {
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff7ae6, #c93ac0);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.win-daily {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--gold);
}

.how {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.how-art {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border-radius: 22px;
  background: rgba(20, 6, 50, 0.45);
}

.how-icon {
  width: 42px;
  height: 42px;
  color: var(--gold);
}

.how-title {
  margin-top: 4px;
  text-align: center;
  font-size: 24px;
  color: #fff;
}

.how-text {
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
}

.how-dots {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.how-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  transition: width 0.3s ease, background 0.3s ease;
}

.how-dot.is-on {
  width: 26px;
  background: var(--gold);
}

@media (max-height: 640px) {
  .tip {
    display: none;
  }

  .play-shell {
    gap: 6px;
    padding-top: calc(6px + var(--safe-top));
  }

  .hud-btn {
    width: 42px;
    height: 42px;
  }

  .btn-go {
    min-height: 48px;
    margin-top: 6px;
    font-size: 21px;
  }

  .pad {
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(2, 50px);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .play-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: start;
    max-width: none;
    gap: 8px 12px;
    padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
  }

  .board-wrap {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  .hud {
    grid-column: 2;
    grid-row: 1;
  }

  .goal-strip {
    grid-column: 2;
    grid-row: 2;
  }

  .controls {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
  }

  .tip {
    display: none;
  }

  .panel-walk {
    flex-direction: column;
    gap: 8px;
  }

  .tools-walk {
    display: flex;
    flex-direction: row;
    width: 100%;
  }

  .tools-walk .tool-btn {
    flex: 1;
    justify-content: center;
    padding: 0 6px;
    font-size: 12.5px;
  }

  .tools-walk .tool-btn span:last-child {
    display: none;
  }

  .pad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(2, 46px);
  }

  .pad-btn {
    border-radius: 16px;
    font-size: 22px;
  }

  .btn-go {
    min-height: 44px;
    margin-top: 6px;
    font-size: 20px;
  }

  .tool-btn {
    min-height: 40px;
  }

  .modal-card {
    padding-top: 18px;
  }

  .win-star {
    font-size: 44px;
  }
}

@media (max-width: 350px) {
  .pad {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 48px);
  }

  .tools-walk .tool-btn {
    padding: 0 8px;
    font-size: 12.5px;
  }

  .tool-btn {
    min-width: 54px;
  }
}
