/* Andra Ordit – byggt för två mobiler bredvid varandra. */

:root {
  --bg: #10131a;
  --bg-elev: #191d27;
  --bg-input: #0c0f15;
  --line: #2a3040;
  --text: #f2f4f8;
  --muted: #99a2b5;
  --accent: #6ee7a8;
  --accent-ink: #04170d;
  --warn: #f6c453;
  --danger: #ff7a7a;
  --radius: 16px;
  --tap: 60px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

/* Spelarvyn ska fylla skärmen så ordet hamnar i mitten. */
body.stage {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overscroll-behavior: none;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
p { margin: 0 0 1rem; }

.muted { color: var(--muted); font-size: .95rem; }
.tiny { font-size: .8rem; color: var(--muted); }

.card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 16px;
}

/* ---------- knappar ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease, opacity .15s ease;
}

.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible { outline: 3px solid #8ab4ff; outline-offset: 2px; }

.btn-secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  border-color: #59323a;
  color: var(--danger);
}

.btn-big {
  min-height: 84px;
  font-size: 1.35rem;
}

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* ---------- formulär ---------- */

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  min-height: var(--tap);
}

textarea { min-height: 120px; resize: vertical; line-height: 1.4; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#code-input {
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: .35em;
  text-indent: .35em;   /* balanserar sista bokstavens spärr */
  text-transform: uppercase;
  min-height: 76px;
}

fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.choice input { accent-color: var(--accent); width: 22px; height: 22px; }
.choice:has(input:checked) { border-color: var(--accent); background: #16241d; }
.choice span { font-weight: 600; }
.choice small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- ordet ---------- */

.word-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 12px 0;
  min-height: 200px;
}

.word {
  font-size: clamp(2.4rem, 13vw, 4.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.word-next {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--warn);
  overflow-wrap: anywhere;
}

.label {
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- topprad ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.pill {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}

.code-badge {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: .25em;
  text-indent: .25em;
  text-align: center;
  padding: 14px;
  background: var(--bg-input);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* ---------- poäng ---------- */

.score {
  font-size: clamp(4rem, 26vw, 7rem);
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

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

.stat {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat b { display: block; font-size: 1.6rem; }

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
  max-height: 30vh;
  overflow-y: auto;
}

.word-list li {
  padding: 4px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .85rem;
}

/* ---------- status ---------- */

.banner {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: .9rem;
  text-align: center;
}

.banner.warn { border-color: #5c4a1c; background: #2a2313; color: var(--warn); }
.banner.error { border-color: #59323a; background: #2a1518; color: var(--danger); }

.spinner-dot {
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

[hidden] { display: none !important; }
