:root {
  --mint: #7dd9c4;
  --mint-dark: #3da894;
  --yellow: #ffe566;
  --yellow-soft: #fff3a8;
  --lilac: #c4a8f5;
  --coral: #ff8a7a;
  --white: #fffef8;
  --ink: #2a2438;
  --ink-soft: #4a4258;
  --panel: rgba(255, 254, 248, 0.94);
  --panel-border: rgba(61, 168, 148, 0.35);
  --shadow: 0 18px 50px rgba(42, 36, 56, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --error: #d64550;
  --page-fill: linear-gradient(165deg, var(--yellow-soft) 0%, #e8f7f2 45%, #f0e6ff 100%);
}

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

/* Fyller iframe / vindu uten dokument-scroll; «bokstavluke» får samme gradient som bakgrunn (ikke hvitt). */
html {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--page-fill);
}

body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  font-family: "Signika", "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page-fill);
}

.hero {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 0;
}

.hero-picture {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-fill);
}

.hero-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: top;
}

.hero-overlay-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background: linear-gradient(
    to top,
    rgba(42, 36, 56, 0.62) 0%,
    rgba(42, 36, 56, 0.2) 55%,
    transparent 100%
  );
  pointer-events: none;
}

.hero-content {
  position: absolute;
  left: 50%;
  bottom: clamp(0.75rem, 3vw, 1.75rem);
  transform: translateX(-50%);
  z-index: 2;
  text-align: center;
  max-width: min(92vw, 420px);
  width: 100%;
  padding: 0 0.75rem;
  line-height: normal;
  pointer-events: none;
}

.hero-content .btn-hero {
  pointer-events: auto;
}

.hero-kicker {
  margin: 0 0 0.35rem;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--yellow-soft);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.hero-title {
  margin: 0 0 1rem;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.15rem);
  color: var(--white);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.btn-hero {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: clamp(0.82rem, 2.8vw, 1rem);
  line-height: 1.35;
  letter-spacing: 0.02em;
  padding: 0.75rem 1.15rem;
  max-width: min(100%, 22rem);
  margin-inline: auto;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(135deg, var(--yellow) 0%, var(--mint) 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.btn-hero:focus-visible {
  outline: 3px solid var(--lilac);
  outline-offset: 3px;
}

.chat-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.chat-panel[hidden] {
  display: none;
}

.chat-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 36, 56, 0.4);
  backdrop-filter: blur(4px);
}

.chat-panel-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(92vh, 780px);
  background: var(--panel);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.35s ease-out;
}

@keyframes sheetUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(61, 168, 148, 0.2);
  background: linear-gradient(90deg, rgba(255, 230, 102, 0.35), rgba(125, 217, 196, 0.25));
}

.panel-title {
  margin: 0;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(42, 36, 56, 0.08);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-close:hover {
  background: rgba(255, 138, 122, 0.35);
}

.app-inner {
  padding: 0.75rem 1rem 1.25rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tagline {
  margin: 0 0 0.65rem;
  font-size: clamp(1.35rem, 4.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f472b6;
  text-align: center;
  text-shadow:
    0.06em 0.06em 0 #9a3412,
    0.1em 0.1em 0 #c2410c;
}

.riddle-card {
  background: linear-gradient(135deg, rgba(255, 243, 168, 0.5), rgba(196, 168, 245, 0.2));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}

.riddle-prompt {
  margin: 0;
  font-size: 0.98rem;
  color: var(--ink);
}

.words-progress {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 0.5rem;
  min-height: 1.2em;
}

.solved-banner {
  text-align: center;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  color: var(--mint-dark);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--mint-dark);
  background: rgba(125, 217, 196, 0.25);
}

.chat-log {
  flex: 1;
  min-height: 200px;
  max-height: min(38vh, 320px);
  overflow-y: auto;
  padding: 0.35rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
  scroll-behavior: smooth;
}

.msg {
  max-width: 94%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-user {
  align-self: flex-end;
  background: rgba(196, 168, 245, 0.35);
  border-color: rgba(196, 168, 245, 0.5);
}

.msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(61, 168, 148, 0.25);
}

.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.msg-role {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mint-dark);
  font-weight: 700;
}

.btn-tts {
  flex-shrink: 0;
  font-family: "Quicksand", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--yellow-soft);
  color: var(--ink);
  cursor: pointer;
}

.btn-tts:hover {
  background: var(--yellow);
}

.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.input-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.message-input {
  flex: 1;
  resize: vertical;
  min-height: 48px;
  max-height: 120px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
}

.message-input:focus {
  outline: 2px solid var(--mint);
  outline-offset: 1px;
}

.message-input:disabled {
  opacity: 0.55;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.btn {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-send {
  background: linear-gradient(135deg, var(--coral), #ff6b6b);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.25);
  min-height: 44px;
  min-width: 100px;
}

.btn-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: rgba(42, 36, 56, 0.15);
}

.btn-ghost:hover {
  background: rgba(125, 217, 196, 0.2);
}

.btn-tiny {
  font-size: 0.65rem;
  padding: 0.35rem 0.55rem;
  text-transform: none;
  letter-spacing: 0;
}

.btn-icon {
  width: 48px;
  min-width: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--mint), var(--mint-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  filter: brightness(1.06);
}

.btn-icon.recording {
  animation: pulseRec 1s ease-in-out infinite;
  background: linear-gradient(160deg, var(--coral), #e85d4c);
}

@keyframes pulseRec {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.btn-icon .icon-mic,
.btn-icon .icon-stop {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-icon .icon-stop {
  display: none;
  width: 16px;
  height: 16px;
  background: currentColor;
  border-radius: 3px;
}

.btn-icon.recording .icon-mic {
  display: none;
}

.btn-icon.recording .icon-stop {
  display: block;
}

.icon-mic {
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.mic-status {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--mint-dark);
  text-align: center;
}

.error-line {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--error);
}

.riddle-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
