:root {
  --ink: #0e1116;
  --panel: #171b24;
  --sand: #e8e0d4;
  --sand-dim: #a39b8e;
  --teal: #3eb49a;
  --teal-deep: #2a8f7a;
  --amber: #e6b84d;
  --line: rgba(232, 224, 212, 0.14);
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--sand);
  background:
    radial-gradient(ellipse 90% 60% at 70% -10%, rgba(62, 180, 154, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 10% 100%, rgba(230, 184, 77, 0.1), transparent 50%),
    linear-gradient(165deg, #141820 0%, #0e1116 45%, #12161e 100%);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* —— Landing —— */
.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hero {
  position: relative;
  flex: 1;
  min-height: min(100dvh, 820px);
  display: grid;
  align-items: end;
  padding: clamp(24px, 5vw, 56px);
  overflow: hidden;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 28rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 12vw, 6.5rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--sand);
}

.tag {
  margin-top: 0.85rem;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  color: var(--sand-dim);
  max-width: 22rem;
}

.cta-row {
  margin-top: 1.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--sand);
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border-radius: 2px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #0e1116;
}

.btn-primary:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #0e1116;
}

.landing-foot {
  padding: 1.25rem clamp(24px, 5vw, 56px) 1.75rem;
  border-top: 1px solid var(--line);
  color: var(--sand-dim);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
}

.about {
  padding: clamp(32px, 6vw, 72px) clamp(24px, 5vw, 56px);
  max-width: 720px;
}

.about h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.about p {
  color: var(--sand-dim);
  margin-bottom: 0.75rem;
}

.about ul {
  margin: 1rem 0 0 1.1rem;
  color: var(--sand-dim);
}

.about li {
  margin-bottom: 0.35rem;
}

/* —— Screens —— */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(10px);
}

.topbar .brand-sm {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.play-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 0.75rem;
}

.play-meta {
  width: min(100%, 920px);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.play-meta h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.play-meta p {
  color: var(--sand-dim);
  font-size: 0.95rem;
}

#board {
  display: block;
  border: 1px solid var(--line);
  border-radius: 2px;
  touch-action: none;
  cursor: crosshair;
  max-width: 100%;
  background: #12151c;
}

.tray {
  width: min(100%, 920px);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 3rem;
  align-items: center;
}

.tray-item {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: lowercase;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--sand);
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border-left: 3px solid var(--band, var(--teal));
}

.tray-item.active {
  border-color: var(--teal);
  background: rgba(62, 180, 154, 0.12);
}

.tray-count {
  color: var(--sand-dim);
  font-weight: 500;
}

.tray-empty {
  color: var(--sand-dim);
  font-size: 0.9rem;
}

.help-line {
  width: min(100%, 920px);
  font-size: 0.85rem;
  color: var(--sand-dim);
}

.solved-banner {
  width: min(100%, 920px);
  padding: 0.65rem 0.9rem;
  background: rgba(62, 180, 154, 0.15);
  border: 1px solid var(--teal);
  color: var(--teal);
  font-weight: 600;
  border-radius: 2px;
}

/* level select */
.select-wrap {
  padding: 1.5rem clamp(16px, 4vw, 40px) 2.5rem;
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
}

.select-wrap h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.select-wrap .sub {
  color: var(--sand-dim);
  margin-bottom: 1.25rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.5rem;
}

.level-chip {
  aspect-ratio: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--sand);
  cursor: pointer;
  border-radius: 2px;
}

.level-chip:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
}

.level-chip.done {
  background: rgba(62, 180, 154, 0.2);
  border-color: var(--teal);
}

.level-chip.locked {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .help-line {
    font-size: 0.8rem;
  }
}
