:root {
  --bg-top: #070b1f;
  --bg-bottom: #101e42;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text-main: #f2f5ff;
  --text-sub: #b8c3e0;
  --unknown-color: #b1b7c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 14px 24px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: 1.3rem;
}

h2 {
  font-size: 0.95rem;
  color: var(--text-sub);
}

#draw-button,
#reset-button,
#continue-button,
#new-round-button {
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-radius: 999px;
  font-size: 0.95rem;
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

#draw-button:hover:enabled,
#reset-button:hover:enabled,
#continue-button:hover:enabled,
#new-round-button:hover:enabled {
  background: rgba(255, 255, 255, 0.2);
}

#draw-button:disabled,
#reset-button:disabled,
#continue-button:disabled,
#new-round-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status-text {
  min-height: 1.3rem;
  margin: 10px 2px 8px;
  color: var(--text-sub);
  font-size: 0.92rem;
}

.playfield {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(4px);
  overflow: hidden;
}

.draw-area,
.catalog-wrap {
  padding: 12px;
}

.draw-area {
  min-height: 220px;
  border-bottom: 1px solid var(--panel-border);
  position: relative;
}

.catalog-wrap {
  min-height: 260px;
}

.catalog-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}

.catalog-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.catalog-card.collected {
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}

.card-visual {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: #222;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.catalog-card:not(.collected) .card-visual {
  color: #1a1d27;
  background: rgba(190, 197, 214, 0.7);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.shape-square {
  border-radius: 10px;
}

.card-visual.rarity-rare,
.floating-piece.rarity-rare {
  border: 4px solid var(--rare-border-color, #ffffff);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22), 0 8px 20px rgba(0, 0, 0, 0.25);
}

.card-visual.rarity-legendary,
.floating-piece.rarity-legendary {
  border: 2px solid rgba(255, 248, 208, 0.95);
  animation: pulse-glow 1.2s ease-in-out infinite alternate;
}

.card-name {
  font-size: 0.78rem;
  text-align: center;
  color: var(--text-sub);
}

.floating-piece {
  position: absolute;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--unknown-color);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  color: #232a3c;
  font-weight: 800;
  font-size: 1.3rem;
  user-select: none;
  touch-action: none;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  animation: float 3.4s ease-in-out infinite alternate;
}

.floating-piece.dragging {
  animation: none;
  transform: scale(1.04);
}

.floating-piece.revealed {
  color: transparent;
}

@keyframes float {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-8px);
  }
}

@keyframes pulse-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.24);
  }
}

#ad-slot-bottom {
  margin-top: 12px;
  width: 100%;
  min-height: 60px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
}

.ad-slot-placeholder {
  color: var(--text-sub);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.completion-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 8, 20, 0.68);
}

.completion-dialog[hidden] {
  display: none;
}

.completion-dialog-panel {
  width: min(420px, 100%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 33, 68, 0.97), rgba(11, 18, 39, 0.97));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  padding: 18px 16px;
}

.completion-dialog-panel p {
  margin: 10px 0 0;
  color: var(--text-sub);
}

.completion-dialog-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (min-width: 768px) {
  #ad-slot-bottom {
    min-height: 90px;
  }
}
