:root {
  color-scheme: light;
  --paper: #fff9ef;
  --ink: #18232b;
  --muted: #60717d;
  --line: #d9cbb2;
  --gold: #f2c94c;
  --teal: #2f6f7e;
  --red: #c94a36;
  --green: #3f7d55;
  --shadow: 0 24px 60px rgb(24 35 43 / 18%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgb(47 111 126 / 12%) 0 25%, transparent 25% 50%, rgb(201 74 54 / 10%) 50% 75%, transparent 75%) 0 0 / 42px 42px,
    linear-gradient(160deg, #f5e5bd 0%, #f6f0df 43%, #dce9df 100%);
}

button {
  border: 0;
  font: inherit;
}

.shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
}

.riddle-tool {
  width: min(920px, 100%);
  min-height: min(680px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(22px, 4vw, 40px);
  padding: clamp(20px, 4vw, 44px);
  border: 1px solid rgb(24 35 43 / 13%);
  border-radius: 8px;
  background: rgb(255 249 239 / 94%);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand img {
  width: clamp(48px, 9vw, 72px);
  height: clamp(48px, 9vw, 72px);
  flex: 0 0 auto;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.25rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(44px, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7edda;
}

.segmented {
  min-width: 48px;
  min-height: 40px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.segmented.is-active {
  color: white;
  background: var(--teal);
}

.riddle-stage {
  display: grid;
  align-content: center;
  gap: 18px;
  padding-block: clamp(10px, 4vw, 36px);
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 {
  max-width: 16ch;
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.answer {
  max-width: 68ch;
  padding: 18px 20px;
  border-left: 5px solid var(--green);
  border-radius: 0 8px 8px 0;
  background: #eef6ee;
  color: #213529;
  font-size: clamp(1.02rem, 2.2vw, 1.22rem);
  line-height: 1.55;
}

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

.primary,
.secondary {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  background: var(--ink);
  color: white;
}

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.primary:hover,
.secondary:hover,
.segmented:hover {
  filter: brightness(0.97);
}

.primary:focus-visible,
.secondary:focus-visible,
.segmented:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

@media (max-width: 620px) {
  .riddle-tool {
    min-height: calc(100vh - 32px);
  }

  .topbar {
    align-items: flex-start;
  }

  .brand {
    align-items: flex-start;
  }

  .language-switch {
    flex: 0 0 auto;
  }

  h2 {
    max-width: 100%;
    font-size: clamp(1.85rem, 11vw, 3.4rem);
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
