:root {
  --ink: #142b41;
  --muted: #62798a;
  --bg: #eef4f2;
  --panel: #fff;
  --line: #d7e4df;
  --teal: #087d72;
  --gold: #ffd45e;
  --coral: #e87968;
  --violet: #7766b5;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 12% 0, #d7eee6, transparent 40%), var(--bg);
  color: var(--ink);
  font:
    15px/1.45 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
button {
  font: inherit;
  cursor: pointer;
}
.top {
  height: 62px;
  padding: 0 max(16px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffffd9;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--teal);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.12em;
}
.top a {
  font-size: 12px;
  color: #526f80;
  text-decoration: none;
  font-weight: 850;
}
.wrap {
  width: min(1240px, calc(100% - 32px));
  margin: 17px auto 35px;
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(115deg, #132c45, #156b70);
  box-shadow: 0 15px 30px #173b4c18;
}
.eyebrow {
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.15em;
  color: #c0efdf;
}
.hero h1 {
  margin: 4px 0;
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.hero p {
  max-width: 800px;
  margin: 5px 0 0;
  color: #e2f0ed;
  font-size: 12px;
}
.hero-icon {
  font-size: 48px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}
.board-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: 0 5px 18px #173b4d0b;
}
.board-panel {
  padding: 14px;
}
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.board-head h2 {
  margin: 0;
  font-size: 15px;
}
.board-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}
.stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stat {
  padding: 6px 8px;
  border-radius: 9px;
  background: #f1f6f4;
  color: #526d7b;
  font-size: 9px;
  font-weight: 900;
}
.stat b {
  color: var(--ink);
}
.puzzle {
  --n: 3;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 800px);
  margin: 0 auto;
  padding: 6px;
  border: 1px solid #cbded7;
  border-radius: 14px;
  background: #dcebe5;
}
.piece {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid #ffffffaa;
  border-radius: 5px;
  background-color: #d4e4dd;
  background-repeat: no-repeat;
  background-size: calc(var(--n) * 100%) calc(var(--n) * 100%);
  overflow: hidden;
  transition:
    transform 0.14s,
    box-shadow 0.14s,
    border-color 0.14s;
  cursor: pointer;
}
.piece:hover {
  z-index: 1;
  transform: scale(0.98);
  border-color: #fff;
}
.piece.selected {
  z-index: 2;
  transform: scale(0.94);
  outline: 4px solid var(--gold);
  box-shadow: 0 0 0 7px #ffd45e55;
}
.piece.correct {
  border-color: #72d4a9;
}
.piece.correct:after {
  position: absolute;
  right: 3px;
  top: 3px;
  content: "✓";
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #148a65;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  box-shadow: 0 1px 4px #1242;
}
.piece.hinted {
  z-index: 3;
  outline: 4px solid #ff9d58;
  animation: pulse 0.55s ease-in-out 3;
}
@keyframes pulse {
  50% {
    filter: brightness(1.3);
    transform: scale(0.94);
  }
}
.coord {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 2px 4px;
  border-radius: 4px;
  background: #0f263dbb;
  color: #fff;
  font-size: 8px;
  font-weight: 950;
  text-shadow: 0 1px 2px #000;
}
.board-foot {
  width: min(100%, 800px);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 9px auto 0;
  color: #677f8c;
  font-size: 10px;
}
.control-panel {
  padding: 14px;
}
.level-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 99px;
  background: #e8f5ef;
  color: #13745f;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.04em;
}
.level-tag i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #20a77a;
}
.control-panel h2 {
  margin: 10px 0 5px;
  font-size: 16px;
}
.control-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.progress-wrap {
  margin: 13px 0;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: #627887;
  font-size: 9px;
  font-weight: 850;
}
.progress {
  height: 9px;
  border-radius: 99px;
  background: #e6efeb;
  overflow: hidden;
}
.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #2fc895, #83db91);
  transition: width 0.25s;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 11px;
}
.btn {
  padding: 9px 7px;
  border: 1px solid #d4e2dd;
  border-radius: 9px;
  background: #f3f7f5;
  color: #3a5968;
  font-size: 10px;
  font-weight: 950;
}
.btn:hover:not(:disabled) {
  background: #e5f2ed;
}
.btn.primary {
  grid-column: 1/-1;
  border: 0;
  background: var(--gold);
  color: #24384a;
  box-shadow: 0 3px #d5aa3b;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.toast {
  min-height: 35px;
  margin-top: 9px;
  padding: 8px;
  border-radius: 9px;
  background: #f2f6f4;
  color: #4d6978;
  font-size: 10px;
  font-weight: 800;
}
.hintbox {
  margin-top: 11px;
  padding: 11px;
  border-radius: 11px;
  background: #fff7df;
  color: #765f27;
  font-size: 10px;
}
.hintbox b {
  display: block;
  margin-bottom: 3px;
  color: #5e4815;
}
.team-tip {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #e5ece9;
  color: #677d89;
  font-size: 10px;
}
.team-tip strong {
  color: #25495a;
}
.overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #10243bce;
}
.overlay[hidden] {
  display: none;
}
.dialog {
  width: min(540px, 100%);
  padding: 25px;
  border: 1px solid #caddd6;
  border-radius: 21px;
  background: #fff;
  text-align: center;
  box-shadow: 0 22px 70px #07172570;
}
.dialog-icon {
  font-size: 47px;
}
.dialog .eyebrow {
  color: var(--teal);
}
.dialog h2 {
  margin: 7px 0;
  font-size: 25px;
  line-height: 1.1;
}
.dialog p {
  color: #5d7482;
  font-size: 12px;
}
.dialog .btn {
  margin-top: 7px;
  padding: 11px 18px;
}
.final-note {
  padding: 10px;
  border-radius: 10px;
  background: #eaf6ef;
  color: #386452;
  font-weight: 800;
}
.footer {
  padding: 13px 4px 0;
  color: #758894;
  text-align: center;
  font-size: 10px;
}
:focus-visible {
  outline: 3px solid #e9b936;
  outline-offset: 2px;
}
@media (max-width: 850px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
  }
  .control-panel .level-tag,
  .control-panel h2,
  .control-panel > p,
  .progress-wrap,
  .actions,
  .toast,
  .hintbox,
  .team-tip {
    grid-column: 1/-1;
  }
  .puzzle {
    max-width: min(100%, 680px);
  }
}
@media (max-width: 520px) {
  .wrap {
    width: calc(100% - 18px);
    margin-top: 9px;
  }
  .hero {
    padding: 16px;
  }
  .hero-icon {
    display: none;
  }
  .board-panel {
    padding: 8px;
  }
  .board-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .stats {
    justify-content: flex-start;
  }
  .puzzle {
    gap: 2px;
    padding: 3px;
    border-radius: 9px;
  }
  .piece {
    border-radius: 3px;
  }
  .coord {
    font-size: 7px;
  }
  .control-panel {
    display: block;
  }
  .board-foot {
    font-size: 9px;
  }
  .control-panel {
    padding: 11px;
  }
}
.dialog-icon {
  display: none !important;
}
.hero-icon {
  display: none !important;
}
