:root {
  --bg: #101525;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #f6f8ff;
  --muted: #aab4d0;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --accent-3: #ffb703;
  --danger: #ff5d73;
  --success: #2ee59d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 20%, rgba(124, 92, 255, 0.32), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(0, 212, 255, 0.24), transparent 28%),
    linear-gradient(135deg, #111827 0%, #111525 45%, #1a1235 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.7;
  pointer-events: none;
  animation: float 9s ease-in-out infinite;
}

.orb-1 {
  width: 140px;
  height: 140px;
  left: 4vw;
  top: 8vh;
  background: #7c5cff;
}

.orb-2 {
  width: 170px;
  height: 170px;
  right: 6vw;
  top: 24vh;
  background: #00d4ff;
  animation-delay: -3s;
}

.orb-3 {
  width: 110px;
  height: 110px;
  left: 55vw;
  bottom: 6vh;
  background: #ffb703;
  animation-delay: -5s;
}

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, -22px, 0) scale(1.05); }
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  position: relative;
}

.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  padding: 32px;
  border-radius: 34px;
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -80px -110px auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 183, 3, 0.28), transparent 68%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 5.4rem);
  line-height: 0.92;
  margin-bottom: 18px;
  letter-spacing: -0.06em;
}

h1 span {
  background: linear-gradient(120deg, #ffb703, #00d4ff, #7c5cff);
  -webkit-background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  max-width: 760px;
  line-height: 1.7;
  font-size: 1.02rem;
}

.quick-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.quick-stats div {
  min-width: 140px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px 16px;
}

.quick-stats strong {
  display: block;
  font-size: 1.35rem;
}

.quick-stats small {
  color: var(--muted);
}

.hero-preview {
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  transform: rotate(-4deg);
  z-index: 1;
}

.mini-piece {
  border-radius: 24px;
  background: linear-gradient(135deg, #7c5cff, #00d4ff);
  min-height: 80px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.25);
}

.p1 { background: linear-gradient(135deg, #7c5cff, #ffb703); }
.p2 { background: linear-gradient(135deg, #00d4ff, #2ee59d); transform: translateY(20px); }
.p3 { background: linear-gradient(135deg, #ff5d73, #ffb703); }
.p4 { background: linear-gradient(135deg, #2ee59d, #7c5cff); transform: translateY(-10px); }
.p5 { background: linear-gradient(135deg, #ffb703, #00d4ff); }
.p6 { background: linear-gradient(135deg, #ff5d73, #7c5cff); transform: translateY(16px); }

.game-layout {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 280px;
  gap: 22px;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  padding: 20px;
}

.panel-title {
  margin-bottom: 18px;
}

.panel-title h2 {
  font-size: 1.14rem;
  margin-bottom: 4px;
}

.panel-title span,
.control-group span,
.metric span {
  color: var(--muted);
  font-size: 0.88rem;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.control-group select,
.control-group input[type="file"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 13, 28, 0.7);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 13px;
  outline: none;
}

.control-group small {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.toggle-row {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 12px;
}

.switch-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.2s ease, filter 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  grid-column: span 2;
}

.btn.danger {
  background: rgba(255, 93, 115, 0.18);
  color: #ffd3da;
}

.tips-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.15);
  color: var(--muted);
  line-height: 1.55;
}

.tips-box strong {
  color: var(--text);
}

.topbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.28rem;
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 560px;
  overflow: hidden;
}

.game-board {
  width: min(100%, 760px);
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.18);
  border: 8px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 70px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 14px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

.tile:hover {
  transform: scale(0.985);
  filter: brightness(1.08);
}

.tile.empty {
  background: rgba(8, 12, 25, 0.58) !important;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  cursor: default;
}

.tile.correct {
  box-shadow: inset 0 0 0 2px rgba(46, 229, 157, 0.76), 0 0 22px rgba(46, 229, 157, 0.15);
}

.tile.hinted {
  animation: pulseHint 0.55s ease-in-out 4;
}

@keyframes pulseHint {
  0%, 100% { transform: scale(1); box-shadow: inset 0 0 0 2px rgba(255, 183, 3, 0.9); }
  50% { transform: scale(0.94); box-shadow: inset 0 0 0 5px rgba(255, 183, 3, 1), 0 0 28px rgba(255, 183, 3, 0.45); }
}

.tile-number {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 27px;
  height: 27px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(9, 13, 28, 0.72);
  color: white;
  font-size: 0.82rem;
  font-weight: 900;
  backdrop-filter: blur(8px);
}

.preview-overlay,
.win-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 18, 0.74);
  backdrop-filter: blur(12px);
  z-index: 10;
  padding: 22px;
}

.preview-card,
.win-card {
  width: min(520px, 100%);
  background: rgba(20, 25, 45, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.preview-card {
  position: relative;
}

.preview-card button {
  position: absolute;
  right: 18px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 0;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.6rem;
  cursor: pointer;
}

.preview-card img {
  width: 100%;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.trophy {
  font-size: 4rem;
  margin-bottom: 8px;
}

.stars {
  letter-spacing: 0.08em;
  color: var(--accent-3);
  font-size: 1.8rem;
  margin: 14px 0 20px;
}

.leaderboard {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  color: var(--muted);
  line-height: 1.45;
}

.leaderboard strong {
  color: var(--text);
}

.second-title {
  margin-top: 24px;
}

.mission-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.mission-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 310px 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 850px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-preview {
    min-height: 180px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: repeat(2, 1fr);
  }

  .board-wrap {
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 18px, 1500px);
    padding-top: 10px;
  }

  .hero-card,
  .panel {
    border-radius: 20px;
    padding: 16px;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .btn.primary {
    grid-column: auto;
  }

  .topbar {
    gap: 8px;
  }

  .metric strong {
    font-size: 1.05rem;
  }

  .game-board {
    border-radius: 18px;
    border-width: 5px;
    gap: 3px;
  }

  .tile {
    border-radius: 10px;
  }
}
