:root {
  --ink: #1d2430;
  --muted: #667085;
  --line: #d9dee8;
  --panel: #ffffff;
  --page: #f5f7fb;
  --accent: #1977d2;
  --accent-strong: #0d5dad;
  --good: #15803d;
  --danger: #c2410c;
  --shadow: 0 16px 48px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.landing-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  position: relative;
  isolation: isolate;
}

.landing-page::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  background: #182333 var(--landing-image) center / cover no-repeat;
}

.landing-page::after {
  content: "";
  position: fixed;
  z-index: 1;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.landing-shell {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
}

.landing-auth {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.94);
}

.landing-brand {
  display: grid;
  gap: 6px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  background: #aab4c2;
  cursor: not-allowed;
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost:hover {
  border-color: #aeb8c8;
  background: #f8fafc;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2.2rem);
}

h2 {
  font-size: 1.1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(360px, 1fr) minmax(220px, 280px);
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 40px) 32px;
}

.panel,
.play-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.play-area {
  min-width: 0;
  overflow: hidden;
}

.panel-heading,
.puzzle-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}

.puzzle-toolbar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: #edf1f7;
  padding: 4px;
}

.tab {
  min-height: 34px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
}

.form-stack,
.upload-box {
  display: grid;
  gap: 12px;
}

.upload-box {
  margin-bottom: 14px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.gallery {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 360px);
  min-height: 120px;
  overflow: auto;
  padding-right: 2px;
}

.image-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}

.image-card:hover,
.image-card.active {
  border-color: var(--accent);
  background: #eef7ff;
}

.thumb {
  width: 76px;
  aspect-ratio: 1;
  min-height: 0;
  border-radius: 6px;
  border: 0;
  background: #e6ebf2 center / cover no-repeat;
  padding: 0;
}

.image-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.image-name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-facts {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.card-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.78rem;
}

.delete-button {
  background: var(--danger);
}

.delete-button:hover {
  background: #9a3412;
}

.board-frame {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 190px);
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(217, 222, 232, 0.55) 1px, transparent 1px),
    linear-gradient(rgba(217, 222, 232, 0.55) 1px, transparent 1px);
  background-size: 28px 28px;
}

.empty-state {
  max-width: 340px;
  border: 1px dashed #aeb8c8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  padding: 22px;
  text-align: center;
  font-weight: 800;
}

.puzzle-board {
  display: grid;
  width: min(100%, 760px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  background: #111827;
  touch-action: manipulation;
}

.piece {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 0;
  background-repeat: no-repeat;
  cursor: grab;
  outline: 0;
  padding: 0;
}

.piece:active {
  cursor: grabbing;
}

.piece.selected {
  box-shadow: inset 0 0 0 4px #ffd166;
}

.piece.correct {
  border-color: rgba(255, 255, 255, 0.35);
}

.preview-panel {
  align-self: start;
}

.preview-box {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  overflow: hidden;
  text-align: center;
  font-weight: 800;
}

.preview-box img {
  display: block;
  width: 100%;
  height: auto;
}

.locked {
  opacity: 0.52;
  pointer-events: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.verification-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.verification-panel {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.verification-panel p:not(.eyebrow) {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.button-link {
  display: inline-grid;
  min-height: 40px;
  width: fit-content;
  align-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-strong);
}

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

.ghost-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-link:hover {
  border-color: #aeb8c8;
  background: #f8fafc;
}

.hidden {
  display: none !important;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: minmax(250px, 320px) minmax(360px, 1fr);
  }

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

  .preview-box {
    min-height: 160px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-strip {
    width: 100%;
    justify-content: space-between;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .gallery {
    max-height: none;
  }
}
