:root {
  --bg-top: #0a2a47;
  --bg-bottom: #071521;
  --stadium-bg: url("https://source.unsplash.com/MeLu29OK5es/1600x900");
  --panel: rgba(255, 255, 255, 0.1);
  --panel-strong: rgba(255, 255, 255, 0.16);
  --text-main: #eef6ff;
  --text-muted: #c6d7eb;
  --accent: #ff7a18;
  --accent-2: #ffd166;
  --field: #0e5f3a;
  --danger: #ff5d73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text-main);
  background:
    linear-gradient(170deg, rgba(5, 16, 25, 0.82), rgba(6, 19, 31, 0.85)),
    var(--stadium-bg);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  padding: 16px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 122, 24, 0.35), transparent 35%),
    radial-gradient(circle at 90% 30%, rgba(255, 209, 102, 0.2), transparent 40%),
    linear-gradient(160deg, rgba(8, 34, 57, 0.68), rgba(7, 21, 33, 0.8));
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  padding: 18px;
  backdrop-filter: blur(6px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  animation: card-enter 480ms ease both;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.timer-wrap p {
  margin: 0 0 4px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

.eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 12px;
}

h1 {
  margin: 2px 0 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 0.9;
  letter-spacing: 0.05em;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.timer {
  min-width: 72px;
  text-align: center;
  font-family: "Bebas Neue", sans-serif;
  font-size: 44px;
  line-height: 1;
  border-radius: 12px;
  background: linear-gradient(180deg, #1e3f63, #122940);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  padding: 6px 10px 4px;
}

.scoreboard {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px;
}

.score-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.goal-panel {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.goal-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(11, 29, 46, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.goal-chip strong {
  display: block;
  font-size: 14px;
}

.goal-chip span {
  font-size: 12px;
  color: var(--text-muted);
}

.goal-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.diamond-wrap {
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(17, 78, 48, 0.75), rgba(7, 47, 29, 0.76));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 10px;
}

.base-diamond {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto;
}

.base-diamond::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px solid rgba(255, 255, 255, 0.34);
  transform: rotate(45deg);
}

.base {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transform: rotate(45deg);
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
  transition: transform 120ms ease, background-color 120ms ease;
}

.base.active {
  background: var(--accent-2);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.7);
}

.base.first {
  right: 14px;
  top: 48px;
}

.base.second {
  left: 48px;
  top: 14px;
}

.base.third {
  left: 14px;
  top: 48px;
}

.home {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff2d8;
}

.play-text {
  margin: 6px 0 0;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-height: 26px;
}

.tool-panel {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 184, 121, 0.34);
  background:
    linear-gradient(180deg, rgba(41, 27, 11, 0.66), rgba(22, 16, 12, 0.52)),
    radial-gradient(circle at 15% 10%, rgba(255, 158, 62, 0.24), transparent 40%);
}

.tool-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 42, 67, 0.55);
  color: var(--text-main);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.tool-btn .tool-icon {
  font-size: 16px;
  line-height: 1;
}

.tool-btn.active {
  background: linear-gradient(180deg, #ffd166, #ff9f3f);
  color: #2b1800;
  border-color: #ffdba3;
  box-shadow:
    0 0 0 1px rgba(255, 225, 168, 0.82),
    0 0 18px rgba(255, 192, 88, 0.68);
}

.tool-btn.tool-success {
  animation: tool-burst 360ms ease-out;
}

.tool-btn.locked {
  opacity: 0.45;
}

.board.shake {
  animation: board-shake 220ms ease;
}

@keyframes board-shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

@keyframes tool-burst {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 225, 168, 0.65);
  }
  55% {
    transform: scale(1.06);
    box-shadow: 0 0 0 10px rgba(255, 225, 168, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 225, 168, 0);
  }
}

.tool-tip {
  margin: 4px 2px 0;
  color: #ffdcae;
  font-size: 11px;
  line-height: 1.25;
}

.board-area {
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--board-size, 7), 1fr);
  gap: 6px;
  touch-action: none;
}

.tile {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  color: #fff;
  font-size: clamp(20px, 3.8vw, 28px);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0) 38%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.16));
  box-shadow:
    inset 0 -5px 10px rgba(0, 0, 0, 0.22),
    inset 0 2px 6px rgba(255, 255, 255, 0.28),
    0 6px 12px rgba(0, 0, 0, 0.2);
  transition: transform 120ms ease, filter 160ms ease;
}

.tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.tile.selected {
  outline: 2px solid var(--accent-2);
  transform: translateY(-2px) scale(1.04);
}

.tile.matching {
  animation: pop 220ms ease-in;
}

.tile.dropping {
  animation: drop-in 260ms ease-out both;
}

.tile-icon {
  width: 82%;
  height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.tile-ice::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(180, 226, 255, 0.24), rgba(149, 214, 255, 0.08)),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.3), transparent 34%);
  border: 1px solid rgba(183, 229, 255, 0.48);
  pointer-events: none;
}

.tile-ice {
  cursor: not-allowed;
}

.tile.tile-helmet .tile-icon,
.tile.tile-bat .tile-icon,
.tile.tile-gloves .tile-icon {
  width: 90%;
  height: 90%;
}

@keyframes drop-in {
  from {
    transform: translateY(calc(var(--drop-distance, 0px) * -1));
    opacity: 0.2;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pop {
  from {
    transform: scale(1);
    opacity: 1;
  }
  45% {
    transform: scale(1.14);
  }
  to {
    transform: scale(0.86);
    opacity: 0.2;
  }
}

.action-row {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.asset-credit p {
  margin: 10px 2px 0;
  font-size: 11px;
  color: rgba(219, 232, 244, 0.84);
}

.btn {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background-color 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(180deg, #ff9a3c, #ff7a18);
  border-color: #ffb879;
  color: #1f0f00;
}

dialog {
  border: 0;
  background: transparent;
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog-card {
  width: min(92vw, 420px);
  background: linear-gradient(180deg, #12345a, #0d2238);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 18px;
}

.dialog-card h2 {
  margin: 0;
  font-size: 24px;
}

.dialog-card p {
  color: #d6e5f3;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dialog-actions .btn {
  min-width: 120px;
}

.hit-effect {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity 160ms ease, transform 160ms ease;
}

.hit-effect.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.level-banner {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 162, 69, 0.96), rgba(255, 111, 21, 0.96));
  color: #1e0c00;
  border-radius: 18px;
  padding: 16px 22px;
  border: 1px solid rgba(255, 226, 184, 0.88);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
  text-align: center;
  min-width: min(72vw, 360px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.level-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.celebrate-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.tool-effect-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.fx-smash-core {
  position: fixed;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8c9, #ff9f3f 55%, rgba(255, 150, 72, 0) 72%);
  transform: translate(-50%, -50%) scale(0.3);
  animation: fx-smash-core 360ms ease-out forwards;
}

.fx-smash-ring {
  position: fixed;
  border-radius: 999px;
  border: 4px solid rgba(255, 213, 126, 0.92);
  transform: translate(-50%, -50%) scale(0.2);
  animation: fx-smash-ring 420ms ease-out forwards;
}

.fx-smash-spark {
  position: fixed;
  width: 6px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe9ab, #ff8c3b);
  transform-origin: center top;
  animation: fx-smash-spark 440ms ease-out forwards;
}

.fx-swap-line {
  position: fixed;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.15), rgba(255, 214, 130, 0.98), rgba(255, 209, 102, 0.15));
  box-shadow: 0 0 14px rgba(255, 214, 130, 0.7);
  transform-origin: left center;
  animation: fx-swap-line 320ms ease-out forwards;
}

.fx-plus-two {
  position: fixed;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.04em;
  font-size: 44px;
  color: #ffe7ad;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%) scale(0.7);
  animation: fx-plus-two 680ms ease-out forwards;
}

@keyframes fx-smash-core {
  from { opacity: 0.95; transform: translate(-50%, -50%) scale(0.3); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
}

@keyframes fx-smash-ring {
  from { opacity: 0.95; transform: translate(-50%, -50%) scale(0.2); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
}

@keyframes fx-smash-spark {
  from { opacity: 1; transform: translate(-50%, -50%) rotate(var(--spark-angle, 0deg)) translateY(0); }
  to { opacity: 0; transform: translate(-50%, -50%) rotate(var(--spark-angle, 0deg)) translateY(-56px); }
}

@keyframes fx-swap-line {
  from { opacity: 0.95; transform: scaleX(0.2); }
  to { opacity: 0; transform: scaleX(1); }
}

@keyframes fx-plus-two {
  from { opacity: 0.98; transform: translate(-50%, -50%) scale(0.7); }
  to { opacity: 0; transform: translate(-50%, -100%) scale(1.06); }
}

.confetti {
  position: absolute;
  width: 8px;
  height: 12px;
  opacity: 0;
  transform: translateY(0) rotate(0deg);
  animation: confetti-fall 1200ms ease-out forwards;
}

@keyframes confetti-fall {
  from {
    opacity: 0.95;
    transform: translateY(-12px) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translateY(90vh) rotate(520deg);
  }
}

.hit-effect-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(160deg, rgba(15, 60, 100, 0.94), rgba(10, 33, 55, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.38);
}

.hit-effect-card img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 209, 102, 0.9);
  object-fit: cover;
}

.hit-effect-text strong {
  display: block;
  font-size: 22px;
  line-height: 1;
  color: #ffd978;
}

.hit-effect-text span {
  font-size: 13px;
  color: #e8f5ff;
}

@media (max-width: 560px) {
  body {
    padding: 4px;
    display: block;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    padding: 7px;
    width: min(99vw, 560px);
    border-radius: 14px;
    margin: 0 auto;
    transform-origin: top center;
  }

  .title-row {
    gap: 8px;
    align-items: flex-start;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    margin: 0;
    font-size: 30px;
    line-height: 0.9;
  }

  .timer-wrap {
    display: grid;
    justify-items: center;
    gap: 2px;
  }

  .timer-wrap p {
    margin: 0;
    font-size: 9px;
  }

  .scoreboard {
    margin-top: 6px;
    gap: 4px;
  }

  .score-card {
    padding: 5px 6px;
    border-radius: 10px;
  }

  .score-card p {
    font-size: 9px;
  }

  .score-card strong {
    margin-top: 2px;
    font-size: 15px;
    line-height: 1.05;
  }

  .goal-panel {
    margin-top: 6px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding-bottom: 0;
  }

  .goal-chip {
    min-width: 0;
    gap: 5px;
    padding: 6px;
    border-radius: 10px;
    align-items: center;
  }

  .goal-chip > div:last-child {
    min-width: 0;
  }

  .goal-chip strong {
    font-size: 11px;
    line-height: 1.1;
    word-break: break-all;
  }

  .goal-chip span {
    display: none;
  }

  .goal-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
  }

  .diamond-wrap {
    margin-top: 6px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 60px;
  }

  .base-diamond {
    width: 54px;
    height: 54px;
    margin: 0;
    flex: 0 0 54px;
  }

  .base-diamond::before {
    inset: 9px;
  }

  .base {
    width: 8px;
    height: 8px;
  }

  .base.first {
    right: 10px;
    top: 23px;
  }

  .base.second {
    left: 23px;
    top: 10px;
  }

  .base.third {
    left: 10px;
    top: 23px;
  }

  .home {
    bottom: 6px;
    font-size: 8px;
  }

  .play-text {
    margin: 0;
    min-height: 0;
    text-align: left;
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: 0.01em;
  }

  .tool-panel {
    margin-top: 6px;
    gap: 4px;
    padding: 5px;
    border-radius: 10px;
  }

  .tool-btn {
    padding: 6px 4px;
    font-size: 10px;
    border-radius: 8px;
    gap: 4px;
  }

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

  .tool-tip {
    font-size: 10px;
    margin-top: 3px;
  }

  .board-area {
    padding: 4px;
    margin-top: 6px;
  }

  .board {
    gap: 1px;
  }

  .tile {
    border-radius: 8px;
  }

  .tile-icon {
    width: 92%;
    height: 92%;
  }

  .timer {
    min-width: 52px;
    font-size: 28px;
    padding: 3px 7px 2px;
    border-radius: 10px;
  }

  .level-banner {
    font-size: 22px;
    padding: 14px 18px;
    min-width: min(76vw, 320px);
  }

  .hit-effect {
    top: 12%;
  }

  .hit-effect-card img {
    width: 48px;
    height: 48px;
  }

  .hit-effect-text strong {
    font-size: 18px;
  }

  .action-row {
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
  }

  .btn {
    padding: 9px 12px;
  }

  .dialog-actions .btn {
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
  }

  .asset-credit {
    display: none;
  }
}
