:root {
  --bg-page: #fdf1f3;
  --bg-card: #ffffff;
  --surface: #fbe4e8;
  --surface-2: #fdf1f3;
  --border: #f1e7e9;
  --accent: #8c325d;
  --accent-dark: #70284a;
  --text: #2b2b33;
  --text-dim: #45454c;
  --correct: #3cae6b;
  --wrong: #8c325d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, #ffffff 0%, var(--bg-page) 100%);
  color: var(--text);
  min-height: 100vh;
}

#app {
  display: flex;
  justify-content: center;
  padding: 16px;
  padding-top: 24px;
  padding-bottom: 76px; /* utrymme för menylisten som ligger längst ner */
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen {
  width: 100%;
  max-width: 480px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 10px 30px rgba(140, 50, 93, 0.12);
}

.card-wide { max-width: 480px; }

.title {
  font-size: 2.2rem;
  margin: 0 0 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 24px;
}

h2 { margin-top: 0; color: var(--text); }

.field {
  display: block;
  margin-bottom: 18px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

input[type="text"] {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

input[type="text"]::placeholder { color: var(--text-dim); }

.slider-wrap {
  position: relative;
  padding-top: 32px;
}

.slider-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-50%);
  background: var(--accent);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
}

.slider-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--accent);
  margin-top: -7px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  margin-top: 12px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 12px 24px rgba(112, 40, 74, 0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.btn-link {
  background: none;
  color: var(--text-dim);
  text-decoration: underline;
}

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

.hint {
  color: #9b9ba3;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 10px;
}

.warning {
  color: #96650a;
  background: #fff3d6;
  padding: 10px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.letter-chip {
  padding: 8px 0;
  text-align: center;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  font-size: 0.9rem;
}

.letter-chip.selected {
  background: var(--accent);
  color: white;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-field span { margin-bottom: 0; }

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.room-code-box {
  text-align: center;
  margin-bottom: 16px;
}

.room-code-box .label {
  display: block;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.room-code {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent-dark);
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.player-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  color: var(--text);
}

.player-list li .offline {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.settings-summary {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
}

.score-header {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.score-header-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text);
}

.score-header-mid {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
}

.round-label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.hamburger-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--surface);
}

.hamburger-menu {
  position: absolute;
  bottom: 100%;
  left: 16px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(140, 50, 93, 0.2);
  padding: 6px;
  min-width: 200px;
  z-index: 20;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface);
}

.menu-item-danger {
  color: var(--wrong);
}

.board-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.letter-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 10px 24px rgba(112, 40, 74, 0.3);
}

.board-letter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.board-score {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.timer {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  color: var(--text);
}

.timer.low { color: var(--wrong); }

.review-title {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text);
}

.category-list, .review-list {
  max-width: 480px;
  margin: 0 auto;
}

.category-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 6px 16px rgba(140, 50, 93, 0.08);
}

.category-item .cat-name {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

.category-item input {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.review-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 6px 16px rgba(140, 50, 93, 0.08);
}

.review-category .cat-name {
  font-weight: 700;
  margin-bottom: 10px;
  display: block;
  color: var(--accent-dark);
}

.review-answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.review-answer-row .player-name {
  font-size: 0.85rem;
  color: var(--text-dim);
  width: 90px;
  flex-shrink: 0;
}

.review-answer-row .answer-text {
  flex: 1;
  font-size: 1.05rem;
  padding: 0 8px;
  color: var(--text);
}

.review-answer-row .answer-text.empty {
  color: var(--text-dim);
  font-style: italic;
}

.mark-buttons {
  display: flex;
  gap: 6px;
}

.mark-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
}

.mark-btn.correct.active {
  background: var(--correct);
  border-color: var(--correct);
  color: white;
}

.mark-btn.wrong.active {
  background: var(--wrong);
  border-color: var(--wrong);
  color: white;
}

.mark-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.score-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.score-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  color: var(--text);
}

.score-list .delta {
  color: var(--correct);
  font-weight: 700;
  margin-left: 8px;
}

.score-list.final li:first-child {
  background: linear-gradient(90deg, #ffd76b, var(--accent));
  border: none;
  color: #2a1c10;
  font-weight: 800;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--wrong);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 100;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 10px 24px rgba(112, 40, 74, 0.35);
}

/* ---------- SPLASH ---------- */
.screen.splash-screen {
  background: linear-gradient(160deg, var(--accent), var(--accent-dark));
  border-radius: 24px;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #ffffff;
  box-shadow: 0 20px 50px rgba(140, 50, 93, 0.35);
}

.splash-logo-circle {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
}

.splash-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
  color: #ffffff;
}

.splash-sub {
  margin-top: 8px;
  font-size: 0.8rem;
  letter-spacing: 3px;
  opacity: 0.85;
  color: #ffffff;
}

.splash-dots {
  margin-top: 34px;
  display: flex;
  gap: 6px;
}

.splash-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}

.splash-dots span:first-child {
  background: #ffffff;
  width: 18px;
  border-radius: 4px;
}

@media (min-width: 500px) {
  .letter-grid { grid-template-columns: repeat(10, 1fr); }
}

/* ---------- ANNONS (förberedd för Google AdSense) ---------- */
.ad-container {
  position: sticky;
  top: 0;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.field-label-centered {
  text-align: center;
}

.value-inline {
  display: none !important;
}
