.modal[hidden],
.consent[hidden] {
  display: none !important;
}

.consent {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center center;
  padding: 12px;
  background: transparent;
  z-index: 999;
  pointer-events: none;
}

.consent-card {
  width: min(92vw, 520px);
  background: rgba(15, 18, 32, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px;
  color: var(--text);
  max-height: 60vh;
  overflow: auto;
  pointer-events: auto;
}

.consent-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.consent-actions button {
  min-width: 96px;
}

@media (max-width: 420px) {
  .consent {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .consent-card {
    padding: 12px;
    max-height: 70vh;
  }

  .consent-actions {
    position: sticky;
    bottom: 0;
    background: rgba(15, 18, 32, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 8px;
  }

  .consent-actions button {
    flex: 1 1 auto;
  }
}

.modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1000;
}

.modal-card {
  background: rgba(15, 18, 32, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 260px;
  color: var(--text);
  text-align: left;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Harmonize non-primary button inside modal */
#closeShare {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

:root {
  --bg: #0f1220;
  --bg-accent: #151933;
  --text: #f5f7ff;
  --muted: #b8c1ec;
  --brand: #7c4dff;
  --brand-2: #00e5ff;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1000px 600px at 10% 10%, var(--bg-accent), transparent),
    radial-gradient(800px 500px at 90% 20%, #0b1028, transparent),
    linear-gradient(180deg, var(--bg), #0a0d1a);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

#app>* {
  max-width: 720px;
}

/* Overlays must not be constrained by #app child max-width */
#app>.modal,
#app>.consent {
  max-width: none;
}

h1 {
  margin: 0 0 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: clamp(40px, 8vw, 72px);
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: clamp(16px, 2.4vw, 20px);
}

.level {
  margin: 0 0 12px;
  color: var(--text);
  font-weight: 700;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

#status {
  margin-top: 12px;
  text-align: center;
  color: var(--brand-2);
  font-weight: 700;
}

.site-footer {
  margin: 16px 0 8px;
  text-align: center;
  color: var(--muted);
}

.site-footer a {
  color: var(--brand-2);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

button.primary {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  color: #0b0e1a;
  background: linear-gradient(180deg, #a984ff, #7c4dff);
  box-shadow: 0 10px 24px rgba(124, 77, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

button.primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

#puzzle {
  margin: 28px auto 0;
  max-width: none;
  width: calc(100% - 16px);
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  text-align: left;
}

@media (max-width: 480px) {
  #puzzle {
    width: 100%;
    padding: 0; /* remove inner padding so SVG can use full width */
    border-left: none;
    border-right: none;
    border-radius: 0;
    margin: 12px 0 0;
  }
}

.graph-svg {
  width: 100%;
  height: min(75vh, 820px);
  display: block;
}

.link {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1.5;
}

.link.highlight {
  stroke: var(--brand-2);
  stroke-width: 2.2;
}

.node circle {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1px;
}

.node.word circle {
  fill: rgba(0, 229, 255, 0.7);
}

.node.category circle {
  fill: rgba(124, 77, 255, 0.7);
}

.node.category rect {
  fill: #9aa3b0;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1px;
}

.node.category.highlight rect {
  fill: var(--brand);
  stroke: var(--brand-2);
  stroke-width: 2px;
}

.node.category .cat-emoji {
  font-size: 16px;
  pointer-events: none;
}

.node.category .cat-label {
  font-size: 12px;
  font-weight: 700;
  fill: var(--text);
  pointer-events: none;
}

.node text {
  fill: #0b0e1a;
  font-weight: 700;
  font-size: 12px;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}

.word-circles {
  pointer-events: none;
}

.word-circle text {
  fill: var(--brand-2);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.word-circle circle {
  fill: #4e3aa9;
  /* dark-ish purple */
  stroke: var(--brand);
  stroke-width: 2px;
}

.word-circle.highlighted circle {
  fill: #00e5ff; /* light cyan bubble variant */
  stroke: #4e3aa9;
}
.word-circle.highlighted text {
  fill: #0b0e1a; /* invert to dark text for contrast */
}

.share-preview {
  white-space: pre-wrap;
  background: #0f1220;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  max-width: 80vw;
}

.word-circle {
  pointer-events: all;
  cursor: pointer;
}

.word-circle.selected circle {
  stroke: #00e5ff;
  stroke-width: 3px;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.5));
}

.graph {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
}

.graph h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #0f1220;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.edge {
  font-size: 12px;
  color: var(--muted);
}