/* Tietovisa — tyylit. Ei ulkoisia riippuvuuksia (fontit, kuvat, skriptit). */

:root {
  --brand: #46178f;
  --brand-2: #7a3fe0;
  --brand-3: #a46bff;
  --accent: #ff3d8b;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #ffc21a;
  --green: #26890c;
  --pink: #d6336c;
  --teal: #0b8f8c;
  --orange: #e8590c;
  --indigo: #5f3dc4;
  --slate: #495057;
  --lime: #5c940d;

  --bg: #f4f0fc;
  --surface: #ffffff;
  --surface-2: #f8f5ff;
  --ink: #1f1533;
  --muted: #6a6280;
  --line: #e4ddf3;
  --ok: #1b8a3a;
  --ok-bg: #e6f6ea;
  --bad: #c62839;
  --bad-bg: #fde8eb;
  --part: #b86e00;
  --part-bg: #fff3d9;
  --focus: #7a3fe0;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(40 20 80 / 8%), 0 8px 24px rgb(40 20 80 / 8%);
  --shadow-lg: 0 2px 4px rgb(40 20 80 / 10%), 0 18px 48px rgb(40 20 80 / 18%);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #150d26;
    --surface: #211538;
    --surface-2: #2a1c47;
    --ink: #f1ecfb;
    --muted: #a99fc4;
    --line: #3a2a5c;
    --ok: #5fd37c;
    --ok-bg: #123421;
    --bad: #ff7b8b;
    --bad-bg: #3c1620;
    --part: #ffc15a;
    --part-bg: #3a2b0a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand-2); }
img { max-width: 100%; }
code, .pin { font-family: var(--mono); }
code { background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 6px; font-size: 0.9em; }
code.block { display: block; padding: 0.7em 0.9em; margin-top: 0.5em; overflow-x: auto; white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.icon, .shape { flex: none; vertical-align: middle; }

/* ------------------------------------------------------------- apuluokat */

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }
.row { display: flex; align-items: center; gap: 0.6rem; }
.row.wrap, .wrap { flex-wrap: wrap; }
.row.center, .center { justify-content: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.center-text { text-align: center; }
.align-start { align-self: flex-start; }
.hint { color: var(--muted); font-size: 0.85rem; }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; overflow-wrap: anywhere; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.fatal { padding: 2rem; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 650;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip-new { background: var(--accent); color: #fff; border-color: transparent; }
.chip-role { background: var(--brand); color: #fff; border-color: transparent; }
.chip-me { background: var(--brand-3); color: #fff; border-color: transparent; margin-left: 0.4rem; }
.chip-owner { background: transparent; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.4rem; border: 1px solid var(--line);
}
.card.narrow { width: min(100%, 460px); }
.notice { background: var(--part-bg); color: var(--ink); border-left: 4px solid var(--part); padding: 0.7rem 0.9rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.92rem; }
.notice.small { font-size: 0.85rem; }
.error-box { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.error-box ul { margin: 0.4rem 0 0; padding-left: 1.2rem; color: var(--ink); font-size: 0.9rem; }
.form-error:not([hidden]) { margin-top: 0.8rem; }
.big-icon { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; background: var(--surface-2); color: var(--brand-2); }
.empty { display: grid; gap: 0.6rem; justify-items: center; text-align: center; padding: 2.5rem 1rem; }

/* --------------------------------------------------------------- painikkeet */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.55rem 1.1rem; border-radius: 12px; border: 2px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
  background: var(--surface-2); color: var(--ink);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 3px 0 rgb(30 8 70 / 35%); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 5px 0 rgb(30 8 70 / 35%), 0 8px 18px rgb(70 23 143 / 28%); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--brand-3); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 3px 0 rgb(100 0 15 / 35%); }
.btn-small { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.88rem; border-radius: 10px; }
.btn-xl { min-height: 58px; font-size: 1.15rem; padding: 0.7rem 1.6rem; border-radius: 16px; }
.btn-block { width: 100%; }
.is-busy { opacity: 0.7; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 10px;
  background: transparent; border: 0; color: var(--muted); cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ----------------------------------------------------------------- lomakkeet */

label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 650; font-size: 0.92rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-weight: 700; font-size: 0.92rem; display: inline-flex; align-items: center; gap: 0.4rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input:not([type]), textarea, select {
  width: 100%; font: inherit; font-weight: 500; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem; min-height: 44px;
}
textarea { resize: vertical; min-height: 5.5em; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-2) 22%, transparent); }
input[type="file"] { font: inherit; font-weight: 500; }

.check { flex-direction: row; align-items: center; gap: 0.6rem; font-weight: 600; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--brand-2); flex: none; }

/* Kytkin: sekä painike (.switch) että checkbox (.sw) */
.switch {
  position: relative; width: 56px; height: 32px; border-radius: 999px; border: 0; padding: 0; flex: none;
  background: #b9b0cc; cursor: pointer; transition: background 0.2s;
}
.switch-knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 30%); transition: transform 0.2s; }
.switch.is-on { background: var(--ok); }
.switch.is-on .switch-knob { transform: translateX(24px); }
input.sw { appearance: none; position: relative; width: 48px; height: 28px; border-radius: 999px; background: #b9b0cc; cursor: pointer; transition: background 0.2s; flex: none; }
input.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); transition: transform 0.2s; }
input.sw:checked { background: var(--ok); }
input.sw:checked::after { transform: translateX(20px); }
.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.toggle-text { display: flex; flex-direction: column; }
.toggle-text small { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.toggle-grid { display: flex; flex-wrap: wrap; gap: 0.6rem 2rem; }

.segmented { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0.3rem; background: var(--surface-2); border-radius: 14px; border: 1px solid var(--line); }
.segmented button { flex: 1 1 auto; min-width: max-content; white-space: nowrap; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; padding: 0.5rem 0.6rem; border-radius: 10px; cursor: pointer; font-size: 0.9rem; }
.segmented button.is-active { background: var(--surface); color: var(--brand-2); box-shadow: var(--shadow); }

.chips-select { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chips-select button { border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: 0.82rem; font-weight: 650; padding: 0.2rem 0.7rem; border-radius: 999px; cursor: pointer; }
.chips-select button.is-active { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem; text-align: center; cursor: pointer;
  padding: 1.2rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-weight: 650;
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--brand-2); color: var(--brand-2); background: var(--surface-2); }
.dropzone small { font-weight: 500; }
.image-field img { max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 0.6rem; }

/* ---------------------------------------------------------------- logo */

.logo { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 850; font-size: 1.25rem; letter-spacing: -0.02em; color: inherit; }
.logo-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 30px; height: 30px; transform: rotate(-8deg); }
.logo-mark i { display: block; border-radius: 4px; }
.lm-a { background: var(--red); border-radius: 50% 4px 4px 4px !important; }
.lm-b { background: var(--blue); }
.lm-c { background: var(--yellow); }
.lm-d { background: var(--green); border-radius: 4px 4px 50% 4px !important; }
.card-logo { display: flex; justify-content: center; color: var(--brand); }

/* ------------------------------------------------------- hallintanäkymän kehys */

.admin-shell { min-height: 100vh; background:
  radial-gradient(900px 400px at 100% -10%, color-mix(in srgb, var(--brand-3) 18%, transparent), transparent),
  radial-gradient(700px 400px at -10% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent), var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem clamp(1rem, 3vw, 2rem); background: linear-gradient(135deg, var(--brand), #2d0c63); color: #fff; box-shadow: 0 4px 18px rgb(30 8 70 / 30%);
}
.topbar .brand { color: #fff; text-decoration: none; }
.topbar .btn-ghost { color: #fff; border-color: rgb(255 255 255 / 30%); }
.topbar .btn-ghost:hover:not(:disabled) { background: rgb(255 255 255 / 12%); border-color: rgb(255 255 255 / 60%); }
.topbar .icon-btn { color: rgb(255 255 255 / 80%); }
.topbar .icon-btn:hover { background: rgb(255 255 255 / 14%); color: #fff; }
.topnav { display: flex; gap: 0.3rem; }
.topnav a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.9rem; border-radius: 10px; color: rgb(255 255 255 / 80%); text-decoration: none; font-weight: 700; }
.topnav a:hover { background: rgb(255 255 255 / 12%); color: #fff; }
.topnav a.active { background: rgb(255 255 255 / 20%); color: #fff; }
.usermenu { display: flex; align-items: center; gap: 0.2rem; }
.usermenu-name { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; font-size: 0.9rem; text-align: right; margin-right: 0.4rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-name small { font-weight: 500; opacity: 0.7; font-size: 0.75rem; }
.admin-main { width: min(1280px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.crumbs a { text-decoration: none; font-weight: 700; }

/* --------------------------------------------------------- julkinen kehys */

.public-shell {
  position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; color: #fff;
  background: radial-gradient(1200px 700px at 15% -10%, #8d4dff 0%, transparent 60%), radial-gradient(900px 600px at 100% 100%, #e0369a 0%, transparent 55%), linear-gradient(160deg, #46178f, #2b0b61 70%);
}
.public-shell .card { color: var(--ink); }
.public-shell .muted, .public-shell .hint { color: var(--muted); }
.bg-shapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bg-shape { position: absolute; display: block; opacity: 0.16; animation: float 14s ease-in-out infinite; }
.bg-shape-1 { width: 120px; height: 120px; background: var(--red); left: 6%; top: 12%; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.bg-shape-2 { width: 100px; height: 100px; background: var(--blue); right: 10%; top: 18%; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); animation-delay: -3s; }
.bg-shape-3 { width: 140px; height: 140px; background: var(--yellow); left: 12%; bottom: 10%; border-radius: 50%; animation-delay: -6s; }
.bg-shape-4 { width: 90px; height: 90px; background: var(--green); right: 14%; bottom: 14%; border-radius: 14px; animation-delay: -9s; transform: rotate(14deg); }
.bg-shape-5 { width: 60px; height: 60px; background: var(--accent); left: 46%; top: 6%; border-radius: 50%; animation-delay: -2s; }
.bg-shape-6 { width: 70px; height: 70px; background: var(--teal); right: 40%; bottom: 6%; clip-path: polygon(50% 0, 100% 100%, 0 100%); animation-delay: -11s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-26px) rotate(10deg); } }
.center-page { position: relative; flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.public-footer { position: relative; text-align: center; padding: 1rem; }
.public-footer a { color: rgb(255 255 255 / 85%); text-decoration: none; font-weight: 650; display: inline-flex; gap: 0.4rem; align-items: center; }
.public-footer a:hover { color: #fff; text-decoration: underline; }

.hero { width: min(100%, 520px); text-align: center; display: grid; gap: 1rem; }
.hero-logo { display: flex; justify-content: center; font-size: 1.4rem; }
.hero-logo .logo { color: #fff; font-size: 1.8rem; }
.hero-title { font-size: clamp(2rem, 7vw, 3.2rem); text-shadow: 0 3px 0 rgb(0 0 0 / 20%); }
.hero-sub { opacity: 0.88; font-size: 1.1rem; }
.pin-card { padding: 1.2rem; box-shadow: var(--shadow-lg); }
.pin-form { display: grid; gap: 0.8rem; }
.pin-input {
  text-align: center; font-family: var(--mono); font-size: clamp(1.8rem, 8vw, 2.6rem) !important; font-weight: 800 !important;
  letter-spacing: 0.18em; min-height: 74px !important; border-radius: 16px !important;
}
.pin-input::placeholder { letter-spacing: 0.04em; font-size: 1.3rem; font-weight: 600; color: var(--muted); opacity: 0.7; }
.pin-form .form-error { text-align: left; }

/* --------------------------------------------------------------- pelinäkymä */

.play-stage { position: relative; flex: 1; display: grid; place-items: center; padding: 1.2rem 1rem 3rem; transition: opacity 0.15s; }
.play-stage > * { width: 100%; }
.play-stage > .card.narrow { margin-inline: auto; }
.play-stage.is-locked { opacity: 0.6; pointer-events: none; }
.join-card h1 { font-size: 1.8rem; }

.question-screen { width: min(100%, 880px); margin-inline: auto; display: grid; gap: 1rem; align-self: start; }
.play-top { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.play-top .pill-nick { margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.9rem; border-radius: 999px; background: rgb(255 255 255 / 16%); backdrop-filter: blur(6px); font-weight: 750; font-size: 0.92rem; }
.pill-score { background: var(--yellow); color: #3b2a00; }

.timer { display: flex; align-items: center; gap: 0.8rem; }
.timer-bar { flex: 1; height: 14px; background: rgb(255 255 255 / 20%); border-radius: 999px; overflow: hidden; }
.timer-bar-fill { height: 100%; width: 100%; transform-origin: left; transform: scaleX(var(--left, 1)); background: linear-gradient(90deg, #52e07a, #ffd93d); border-radius: 999px; transition: transform 0.1s linear; }
.timer.is-urgent .timer-bar-fill { background: linear-gradient(90deg, #ff5d73, #ff9d5d); }
.timer-label { font-weight: 850; font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: right; font-size: 1.15rem; }
.timer.is-urgent .timer-label { color: #ffd1d6; animation: pulse 0.7s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.question-card { display: grid; gap: 0.9rem; justify-items: center; text-align: center; padding: clamp(1.2rem, 4vw, 2rem); }
.question-image { max-height: min(40vh, 340px); width: auto; border-radius: var(--radius-sm); object-fit: contain; }
.question-text { font-size: clamp(1.35rem, 4.5vw, 2rem); overflow-wrap: anywhere; white-space: pre-wrap; }

.answers { display: grid; gap: 0.7rem; }
.answers-grid { grid-template-columns: 1fr 1fr; }
.answers-tf { grid-template-columns: 1fr 1fr; }
.answer {
  --c: var(--red); --on: #fff;
  position: relative; display: flex; align-items: center; gap: 0.9rem; min-height: 84px; padding: 0.9rem 1.1rem; text-align: left;
  font: inherit; font-size: clamp(1rem, 3.2vw, 1.3rem); font-weight: 750; color: var(--on); background: var(--c);
  border: 0; border-radius: 14px; cursor: pointer; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 55%, #000); transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.answer span { overflow-wrap: anywhere; }
.answer:hover { filter: brightness(1.08); }
.answer:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 55%, #000); }
.answer-check { margin-left: auto; opacity: 0; transform: scale(0.5); transition: 0.15s; background: rgb(255 255 255 / 30%); border-radius: 50%; padding: 4px; display: grid; }
.answer[aria-pressed="true"] { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 55%, #000), inset 0 0 0 4px #fff; }
.answer[aria-pressed="true"] .answer-check, .answer.is-correct .answer-check { opacity: 1; transform: none; }
.answer.is-correct { box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 55%, #000), inset 0 0 0 4px #fff; }
.answers-tf .answer { justify-content: center; min-height: 110px; font-size: clamp(1.3rem, 5vw, 1.8rem); }

.c0 { --c: var(--red); }
.c1 { --c: var(--blue); }
.c2 { --c: #d99700; --on: #fff; }
.c3 { --c: var(--green); }
.c4 { --c: var(--pink); }
.c5 { --c: var(--teal); }
.c6 { --c: var(--orange); }
.c7 { --c: var(--indigo); }
.c8 { --c: var(--slate); }
.c9 { --c: var(--lime); }

.answer-text { font-size: 1.15rem; min-height: 9em; border-radius: 16px; padding: 1rem; background: var(--surface); }

.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; counter-reset: none; }
.order-item {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem 0.5rem 0.8rem; min-height: 64px; cursor: grab;
  background: var(--surface); color: var(--ink); border-radius: 14px; border-left: 8px solid var(--c); box-shadow: var(--shadow); font-weight: 700;
}
.order-item { user-select: none; -webkit-user-select: none; }
.order-item.is-dragging { z-index: 40; cursor: grabbing; pointer-events: none; box-shadow: 0 18px 40px rgb(20 5 50 / 45%); transform: rotate(0.8deg) scale(1.02); opacity: 0.93; }
.order-list.is-sorting { cursor: grabbing; }
.order-placeholder { display: flex; align-items: center; padding: 0.5rem 0.8rem; border-radius: 14px; border: 3px dashed rgb(255 255 255 / 75%); background: rgb(255 255 255 / 14%); }
.order-placeholder .order-num { background: #fff; color: var(--brand); }
.order-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; font-size: 0.9rem; flex: none; }
.order-grip { color: var(--muted); display: grid; cursor: grab; touch-action: none; padding: 10px 4px; margin: -10px 0; }
.order-text { flex: 1; overflow-wrap: anywhere; }
.order-btns { display: flex; }
.order-btns .icon-btn { color: var(--brand); }

/* täytettävät kentät */
.fill-fields { display: grid; gap: 0.7rem; padding: 1rem; }
.fill-field { flex-direction: row; align-items: center; gap: 0.8rem; }
.fill-field > span, .fill-label { flex: none; min-width: 3.2rem; display: inline-grid; place-items: center; padding: 0.35rem 0.7rem; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 850; font-size: 1rem; text-align: center; }
.fill-field input { flex: 1; min-width: 0; font-size: 1.05rem; }
.fill-result li { flex-wrap: wrap; }
.fill-result .fill-label { min-width: 2.4rem; padding: 0.1rem 0.5rem; font-size: 0.85rem; }
.fill-given { font-weight: 700; }
.fill-expected { margin-left: auto; font-weight: 700; color: var(--ok); }
.item-row-fill .label-input { max-width: 190px; font-weight: 800 !important; }
.order-num { min-width: 30px; width: auto; padding: 0 0.5rem; border-radius: 999px; }

/* palaute */
.feedback-screen { width: min(100%, 720px); margin-inline: auto; display: grid; gap: 1rem; align-self: start; }
.feedback-banner { display: grid; justify-items: center; gap: 0.3rem; padding: 1.6rem 1rem; border-radius: var(--radius); text-align: center; color: #fff; box-shadow: var(--shadow-lg); animation: pop 0.35s cubic-bezier(.2, 1.4, .4, 1); }
.feedback-banner.tone-ok { background: linear-gradient(135deg, #2fb24f, #1b8a3a); }
.feedback-banner.tone-part { background: linear-gradient(135deg, #f0a31a, #c97a00); }
.feedback-banner.tone-bad { background: linear-gradient(135deg, #f0455a, #c62839); }
.feedback-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: rgb(255 255 255 / 25%); }
.feedback-points { font-size: 2.2rem; font-weight: 900; }
.feedback-points small { font-size: 1rem; font-weight: 600; opacity: 0.85; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.feedback-body .eyebrow { font-size: 0.85rem; text-transform: none; letter-spacing: 0; }
.feedback-score { color: var(--muted); }
.feedback-body .btn { align-self: center; }

.parts, .option-result, .order-result { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.parts li, .option-result li, .order-result li { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.7rem; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
.part-ok, .opt-correct { background: var(--ok-bg) !important; color: var(--ok); }
.part-miss, .opt-wrong { background: var(--bad-bg) !important; color: var(--bad); }
.option-result li span, .parts li, .order-result li { color: var(--ink); }
.part-ok .icon, .opt-correct .icon { color: var(--ok); }
.part-miss .icon, .opt-wrong .icon { color: var(--bad); }
.given, .model, .explanation { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.model { border-left: 4px solid var(--ok); }
.given { border-left: 4px solid var(--brand-3); }
.explanation { border-left: 4px solid var(--blue); }
.given strong, .model strong, .explanation strong { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* tulokset */
.result-screen { width: min(100%, 720px); margin-inline: auto; display: grid; gap: 1rem; align-self: start; position: relative; }
.result-hero { box-shadow: var(--shadow-lg); }
.result-hero .big-icon.trophy { background: linear-gradient(135deg, #ffd93d, #ff9d2f); color: #5a3600; width: 88px; height: 88px; }
.score-big { font-size: clamp(3rem, 14vw, 5rem); font-weight: 900; line-height: 1; color: var(--brand-2); font-variant-numeric: tabular-nums; }
.score-big small { font-size: 1.1rem; color: var(--muted); font-weight: 650; }
.chips.center { justify-content: center; }
.leaderboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.leaderboard li { display: flex; align-items: center; gap: 0.8rem; padding: 0.55rem 0.9rem; border-radius: 12px; background: var(--surface-2); font-weight: 700; }
.leaderboard li:nth-child(1) .lb-rank { background: #ffc21a; color: #3b2a00; }
.leaderboard li:nth-child(2) .lb-rank { background: #cfd4dc; color: #2d3240; }
.leaderboard li:nth-child(3) .lb-rank { background: #e0a26b; color: #3a2108; }
.leaderboard li.is-you { outline: 3px solid var(--brand-2); background: color-mix(in srgb, var(--brand-2) 12%, var(--surface)); }
.lb-rank { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--line); font-weight: 850; flex: none; }
.lb-name { flex: 1; overflow-wrap: anywhere; }
.lb-name small { color: var(--brand-2); }
.lb-score { font-variant-numeric: tabular-nums; }
.review { display: grid; gap: 0.5rem; }
.review-item { border-radius: 12px; background: var(--surface-2); border-left: 6px solid var(--line); }
.review-item.tone-ok { border-left-color: var(--ok); }
.review-item.tone-part { border-left-color: var(--part); }
.review-item.tone-bad { border-left-color: var(--bad); }
.review-item summary { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.9rem; cursor: pointer; font-weight: 700; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.review-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; flex: none; }
.tone-ok .review-mark { background: var(--ok); }
.tone-part .review-mark { background: var(--part); }
.tone-bad .review-mark { background: var(--bad); }
.review-q { flex: 1; overflow-wrap: anywhere; }
.review-points { color: var(--muted); font-variant-numeric: tabular-nums; }
.review-body { padding: 0 0.9rem 0.9rem; }
.review-body strong { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.review-image { max-height: 160px; border-radius: 8px; justify-self: start; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti-piece { position: absolute; top: -20px; left: var(--x); width: 10px; height: 16px; background: var(--c); border-radius: 2px; transform: rotate(var(--r)); animation: fall 3.2s var(--d) ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(calc(var(--r) + 720deg)); opacity: 0.9; } }

/* ---------------------------------------------------------- esikatselu */

.preview-bar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; padding: 0.55rem clamp(1rem, 3vw, 2rem); background: #ffd93d; color: #3b2a00; box-shadow: 0 3px 12px rgb(0 0 0 / 25%); }
.preview-badge { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.7rem; border-radius: 999px; background: #3b2a00; color: #ffd93d; font-weight: 850; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.preview-note { font-weight: 650; font-size: 0.9rem; }
.preview-bar .btn-ghost { color: #3b2a00; border-color: rgb(59 42 0 / 35%); }
.preview-bar .btn-ghost:hover:not(:disabled) { background: rgb(59 42 0 / 10%); border-color: #3b2a00; }

/* ---------------------------------------------------- tietovisakortit */

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.2rem; }
.quiz-card { --t: var(--brand-2); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.quiz-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.quiz-card.tone-0 { --t: var(--red); }
.quiz-card.tone-1 { --t: var(--blue); }
.quiz-card.tone-2 { --t: #d99700; }
.quiz-card.tone-3 { --t: var(--green); }
.quiz-card.tone-4 { --t: var(--pink); }
.quiz-card.tone-5 { --t: var(--teal); }
.quiz-card-band { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 1rem; background: linear-gradient(135deg, var(--t), color-mix(in srgb, var(--t) 60%, #000)); color: #fff; }
.quiz-card-body { padding: 1rem 1.2rem; flex: 1; }
.quiz-title { font-size: 1.2rem; font-weight: 800; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.quiz-title:hover { color: var(--t); }
.pin-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.5rem; }
.pin-row small, .pin-display small { display: block; color: var(--muted); font-weight: 650; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.pin { font-size: 1.6rem; font-weight: 850; letter-spacing: 0.08em; color: var(--t, var(--brand-2)); }
.pin-xl { font-size: clamp(2.2rem, 5vw, 3rem); display: block; color: var(--brand-2); }
.quiz-card-actions { display: flex; align-items: center; gap: 0.3rem; padding: 0.7rem 1rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.quiz-card-actions .btn-primary { margin-right: 0.2rem; }
.quiz-card-actions .btn:nth-child(2) { margin-right: auto; }
.status { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.quiz-card-band .status { background: rgb(255 255 255 / 22%); color: #fff; }
.status-open { background: var(--ok-bg); color: var(--ok); }
.status-closed { background: var(--bad-bg); color: var(--bad); }
.quiz-card-band .switch { background: rgb(255 255 255 / 35%); }
.quiz-card-band .switch.is-on { background: #fff; }
.quiz-card-band .switch.is-on .switch-knob { background: var(--ok); }

/* --------------------------------------------------------------- editori */

.editor-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.5rem; align-items: start; margin-top: 1rem; }
.settings-panel { display: grid; gap: 1rem; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; padding: 4px; scrollbar-width: thin; }
.status-card { display: grid; gap: 0.9rem; border-top: 6px solid var(--bad); }
.status-card.is-open { border-top-color: var(--ok); }
.status-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.pin-display { text-align: center; padding: 0.6rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.saved-indicator { color: var(--ok); font-weight: 700; opacity: 0; transition: opacity 0.3s; }
.saved-indicator.is-visible { opacity: 1; }

.add-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; }
.type-tile { --c: var(--red); display: grid; gap: 0.2rem; justify-items: start; text-align: left; padding: 0.9rem; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; transition: 0.15s; }
.type-tile small { color: var(--muted); font-size: 0.78rem; line-height: 1.3; }
.type-tile:hover { border-color: var(--c); transform: translateY(-2px); box-shadow: var(--shadow); }
.type-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--c); color: #fff; margin-bottom: 0.3rem; }

.question-list { display: grid; gap: 0.8rem; }
.qcard { --c: var(--brand-2); background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.qcard.is-open { border-color: var(--brand-3); box-shadow: var(--shadow-lg); }
.qcard-head { display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 1rem; cursor: pointer; }
.qcard-head:hover { background: var(--surface-2); }
.qnum { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--c); color: #fff; font-weight: 850; flex: none; }
.qinfo { display: grid; gap: 0.1rem; flex: 1; min-width: 0; }
.qtype { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 750; }
.qtext { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qchips { display: flex; gap: 0.3rem; }
.row-btns { display: flex; align-items: center; }
.qcard-body { padding: 1.2rem 1.2rem 1.4rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.question-form .options-editor, .question-form .items-editor { gap: 0.6rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.6rem; position: sticky; bottom: 0; padding: 0.8rem 0; background: linear-gradient(transparent, var(--surface-2) 30%); }

.opt-row { --c: var(--red); display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.5rem; border-radius: 14px; background: var(--surface); border-left: 8px solid var(--c); box-shadow: 0 1px 2px rgb(40 20 80 / 10%); }
.opt-row input[type="text"] { border-color: transparent; background: var(--surface-2); }
.opt-shape { color: var(--c); display: grid; }
.opt-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-2); color: #fff; font-weight: 800; font-size: 0.85rem; flex: none; }
.correct-toggle { flex-direction: row; align-items: center; gap: 0.3rem; padding: 0.35rem 0.7rem; border-radius: 999px; border: 2px solid var(--line); color: var(--muted); font-size: 0.82rem; font-weight: 750; cursor: pointer; white-space: nowrap; flex: none; }
.correct-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.correct-toggle .icon { opacity: 0.3; }
.correct-toggle.is-on { background: var(--ok); border-color: var(--ok); color: #fff; }
.correct-toggle.is-on .icon { opacity: 1; }
.correct-toggle:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.tf-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.tf-choice .answer { min-height: 74px; opacity: 0.55; box-shadow: none; }
.tf-choice .answer.is-correct { opacity: 1; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 55%, #000), inset 0 0 0 4px #fff; }

.item-row { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.item-row .opt-num { margin-top: 0.6rem; }
.item-inputs { flex: 1; display: grid; gap: 0.4rem; min-width: 0; }
.alt-input { font-size: 0.88rem !important; min-height: 38px !important; background: var(--surface-2) !important; }
.tester { padding: 0.9rem; border-radius: var(--radius-sm); border: 2px dashed var(--line); display: grid; gap: 0.6rem; background: var(--surface); }
.tester-score { font-weight: 800; }
.tester-score.ok { color: var(--ok); }
.tester-score.part { color: var(--part); }
.tester-score.bad { color: var(--bad); }
.tester-result { display: grid; gap: 0.5rem; }

/* ---------------------------------------------------------- tulokset (hallinta) */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.stat { display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat:nth-child(1) .stat-icon { background: var(--red); }
.stat:nth-child(2) .stat-icon { background: var(--green); }
.stat:nth-child(3) .stat-icon { background: var(--blue); }
.stat:nth-child(4) .stat-icon { background: #d99700; }
.stat-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; }
.stat strong { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-weight: 650; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.6rem 0.8rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table-compact td, .table-compact th { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.td-actions { text-align: right; min-width: 220px; }
.td-actions > * { margin: 0.15rem 0 0.15rem 0.3rem; }
.qstats { display: grid; gap: 0.8rem; }
.qstat { display: grid; grid-template-columns: minmax(0, 2fr) minmax(120px, 3fr) 110px; gap: 1rem; align-items: center; }
.qstat-text { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qstat-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.88rem; text-align: right; }
.bar { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; width: calc(var(--w, 0) * 100%); border-radius: 999px; background: var(--ok); }
.bar-fill.part { background: #e8a31a; }
.bar-fill.bad { background: var(--bad); }
.review-card { display: grid; gap: 0.3rem; padding: 0.8rem 1rem; border-radius: 12px; background: var(--surface-2); border-left: 6px solid var(--line); }
.review-card.tone-ok { border-left-color: var(--ok); }
.review-card.tone-part { border-left-color: var(--part); }
.review-card.tone-bad { border-left-color: var(--bad); }
.review-head { display: flex; justify-content: space-between; gap: 1rem; }
.audit summary { cursor: pointer; list-style: none; }
.audit summary::-webkit-details-marker { display: none; }
.audit[open] summary { margin-bottom: 1rem; }
.secret { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 2px dashed var(--brand-3); }
.secret code { font-size: 1.15rem; font-weight: 700; background: transparent; overflow-wrap: anywhere; }

/* ------------------------------------------------------ ohjelmistopäivitys */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); font-weight: 650; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.output { margin: 0.4rem 0 0; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); background: #1b1230; color: #e9e2fb; font: 0.82rem/1.5 var(--mono); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice.ok { background: var(--ok-bg); border-left-color: var(--ok); }
.notice ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.notice p { margin-top: 0.3rem; }

/* ---------------------------------------------------------- modaalit ja ilmoitukset */

dialog.modal { width: min(94vw, 520px); max-height: 90vh; padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal-wide { width: min(94vw, 780px); }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop 0.2s ease-out; }
dialog.modal::backdrop { background: rgb(20 8 45 / 60%); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.modal-body { padding: 1.2rem; overflow-y: auto; display: grid; gap: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.modal-text { color: var(--muted); }

.toasts { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: 0.5rem; max-width: min(92vw, 420px); }
.toast { padding: 0.75rem 1rem; border-radius: 12px; background: #2a1c47; color: #fff; font-weight: 650; box-shadow: var(--shadow-lg); animation: slide 0.25s ease-out; }
.toast-success { background: #1b6e33; }
.toast-error { background: #a82032; }
.toast-out { opacity: 0; transform: translateY(8px); transition: 0.25s; }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }

/* ---------------------------------------------------------------- responsiivisuus */

@media (max-width: 960px) {
  .editor-grid { grid-template-columns: 1fr; }
  .settings-panel { position: static; max-height: none; }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .answers-grid { grid-template-columns: 1fr; }
  .answer { min-height: 68px; }
  .qchips { display: none; }
  .topbar { gap: 0.5rem; }
  .usermenu-name { display: none; }
  .qstat { grid-template-columns: 1fr; gap: 0.3rem; }
  .qstat-text { white-space: normal; }
  .qstat-num { text-align: left; }
  .opt-row { flex-wrap: wrap; }
  .opt-row input[type="text"] { flex: 1 1 140px; }
  .quiz-grid { grid-template-columns: 1fr; }
  .toasts { left: 1rem; right: 1rem; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
