:root {
  color-scheme: light;
  --paper: #efe6d4;
  --sheet: #f7f3ea;
  --card: #fffdf8;
  --ink: #1c2430;
  --muted: #5e675f;
  --line: #e3d8c4;
  --green: #0e6b52;
  --green-dark: #0a4f3c;
  --ok: #e5f5ee;
  --bad: #9d2c2c;
  --bad-bg: #fde8e4;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 0% 0%, #d7ebe3, transparent 55%),
    var(--paper);
  color: var(--ink);
  font: 16px/1.4 system-ui, "Segoe UI", sans-serif;
}

a { color: var(--green-dark); }

button, input, textarea, select { font: inherit; color: inherit; }
form { margin: 0; }

.app-shell {
  width: min(100%, 440px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--sheet);
  display: flex;
  flex-direction: column;
}

.desk { display: none; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}

.brand {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  font-size: 1.15rem;
}

main {
  flex: 1;
  padding: 8px 16px calc(28px + 64px);
}

h1 {
  margin: 0 0 12px;
  font-size: 1.7rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h2 { margin: 0 0 8px; font-size: 1.15rem; }

.card, .mode {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  margin: 0 0 12px;
}

.mode {
  position: relative;
  width: 100%;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

a.mode {
  color: inherit;
  text-decoration: none;
}

.mode strong { font-size: 1.25rem; }

.mode span, .hint, .summary { color: var(--muted); }

.summary { margin: 0 0 12px; }

.hero { padding-top: 12vh; }

.mark {
  margin: 0 0 8px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  font-weight: 650;
}

input, textarea, select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

textarea { min-height: 88px; resize: vertical; }

.btn, .text-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  margin: 0 0 10px;
  border-radius: 16px;
  border: 0;
  background: var(--green);
  color: white;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.btn.secondary, .text-btn {
  background: transparent;
  color: var(--green-dark);
  border: 2px solid var(--green);
}

.text-btn {
  min-height: 44px;
  border: 0;
  width: auto;
  padding: 0;
  margin: 8px 0 0;
}

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair .btn { margin: 0; }

.stack, .grid-2 { display: grid; gap: 10px; margin: 0 0 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }

.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 14px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: white;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.flag-option {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 10px;
}

.flag-option img { width: 100%; height: 72px; object-fit: contain; }

.stage {
  height: 220px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.admin-shot {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  margin: 0 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.clip { display: block; width: 100%; margin: 0 0 12px; }

.option.is-correct { border-color: var(--green); background: var(--ok); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-bg); }

h1.prompt {
  min-height: 2.8em;
  margin: 0 0 12px;
  font-size: 1.35rem;
  line-height: 1.4;
}

.eyebrow { margin: 0 0 8px; color: var(--muted); font-weight: 700; }

.play-card { position: relative; }
.play-card strong { display: block; font-size: 1.2rem; margin-bottom: 4px; }
.play-card > span { display: block; margin-bottom: 8px; color: var(--muted); }
.card-tools, .title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-tools strong { flex: 1; margin-bottom: 0; }
.title-row { position: relative; }
.title-row h1, .title-row h2 { flex: 1; padding-right: 44px; margin-bottom: 0; }
.card-tools { padding-right: 44px; }
form.fav {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  margin: 0;
}
.title-row form.fav { top: 0; right: 0; }
.mode-main {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding-right: 40px;
}
.star {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b5a88c;
  cursor: pointer;
}
.star svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}
.star.is-on { color: var(--green); }
.star.is-on svg { fill: currentColor; }
.star:hover::after,
.star:focus-visible::after {
  content: attr(title);
  position: absolute;
  z-index: 4;
  top: calc(100% + 4px);
  right: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}
.status { display: block; font-weight: 700; font-size: 0.92rem; color: var(--muted); }
.status.is-mid { color: var(--ink); }
.status.is-done { color: var(--green-dark); }
.bar.meter { margin: 8px 0 4px; }
.timer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}
.timer i {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.timer i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--left, 100%);
  background: var(--green);
}
.timer.is-low i::before { background: var(--bad); }
.timer b { font-variant-numeric: tabular-nums; min-width: 1.6rem; text-align: right; }

.progress { margin: 0 0 12px; }
.progress span { display: block; margin-top: 6px; color: var(--muted); font-size: 0.92rem; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar::before { content: ""; display: block; height: 100%; width: 0; background: var(--green); }
.bar.p1::before { width: 10%; } .bar.p2::before { width: 20%; } .bar.p3::before { width: 30%; }
.bar.p4::before { width: 40%; } .bar.p5::before { width: 50%; } .bar.p6::before { width: 60%; }
.bar.p7::before { width: 70%; } .bar.p8::before { width: 80%; } .bar.p9::before { width: 90%; }
.bar.p10::before { width: 100%; }

.flash { border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.explain {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  line-height: 1.45;
}
.flash.ok { background: var(--ok); color: var(--green-dark); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

.score-num { margin: 0; font-size: 4rem; font-weight: 800; letter-spacing: -0.05em; line-height: 0.95; }
.score-num span { font-size: 1.4rem; font-weight: 650; color: var(--muted); }

.nav {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav a {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.trio { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trio .btn { margin: 0; }
.trio .wide { grid-column: 1 / -1; }
.trio form, .trio a.btn { margin: 0; }

.who { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: #d9e7e1; display: inline-grid; place-items: center; overflow: hidden;
}
.avatar.xl { width: 84px; height: 84px; font-size: 2rem; }
.avatar.letter { color: var(--green-dark); font-weight: 800; }
.profile-head { display: flex; gap: 14px; align-items: center; }
.profile-head h1 { margin: 0 0 4px; }
.score-num.small { font-size: 1.6rem; margin: 6px 0; }

.lives { margin: 0 0 8px; font-size: 1.35rem; letter-spacing: 2px; }
.lives b { color: #b42318; font-weight: 700; }
.lives i { color: #d9cfc3; font-style: normal; }
.lives span { letter-spacing: 0; font-size: 0.95rem; color: var(--muted); font-weight: 700; }
.diff { margin: 8px 0; font-weight: 800; color: var(--green-dark); }

.medals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.medal { border: 1px solid var(--line); border-radius: 14px; padding: 10px; color: #b7b1a6; }
.medal b { display: block; font-size: 1.2rem; }
.medal strong, .medal span { display: block; }
.medal span { font-size: 0.78rem; }
.medal.is-on { color: var(--green-dark); background: #e7f6ef; border-color: #b7dfcf; }
.tier { display: flex; gap: 4px; }
.tier i { color: #d9cfc3; font-style: normal; }
.tier i.is-on { color: #c8962e; }

.heat { display: grid; grid-template-columns: 28px repeat(16, 1fr); gap: 3px; align-items: center; }
.heat span { font-size: 0.68rem; color: var(--muted); }
.heat i.cell { display: block; aspect-ratio: 1; border-radius: 3px; background: #e7e1d6; }
.heat i.is-on { background: #7dbea8; }
.heat i.is-hot { background: #0e6b52; }
.heat i.is-future { background: transparent; }

.board { display: grid; gap: 8px; }
.board-row {
  display: grid; grid-template-columns: 28px 36px 1fr auto auto; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px;
  color: inherit; text-decoration: none;
}
.board-row strong { color: var(--green-dark); }
.board-row em { color: var(--muted); font-style: normal; }

.nav a.active { color: var(--green-dark); }

.choice-edit { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 8px; }
.choice-edit input[type="radio"] { width: 22px; height: 22px; min-height: 0; }
.stat-list, .recent, .choice-list { list-style: none; padding: 0; margin: 0 0 16px; }
.stat-list li, .recent li, .choice-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.recent li { display: block; }
.recent li span { display: inline-block; margin-right: 8px; }
.recent li span, .choice-list em { color: var(--green-dark); font-style: normal; font-weight: 700; }
.center { text-align: center; }

.photo-btn { gap: 10px; margin: 0; position: relative; }
.photo-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.photo-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.auth-providers { margin-top: 4px; }
.auth-providers .btn { margin-bottom: 8px; }
.link-list { display: grid; }
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.link-row:first-child { border-top: 0; padding-top: 0; }
.link-row strong, .link-row .hint { display: block; }
.link-row .hint { margin: 2px 0 0; }
.link-actions { flex: 0 0 148px; }
.link-actions .btn { min-height: 44px; margin: 0; }
.link-actions .text-btn { display: block; margin: 6px 0 0; text-align: center; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

@media (min-width: 960px) {
  html { overflow-y: scroll; }
  body {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 440px minmax(32px, 1fr);
    align-items: start;
  }
  .desk {
    display: flex;
    grid-column: 1;
    position: sticky;
    top: 0;
    height: 100dvh;
    align-items: center;
    justify-content: flex-end;
    padding: 48px;
  }
  .desk div { max-width: 320px; }
  .desk h2 { font-size: 2rem; line-height: 1.1; }
  .app-shell {
    grid-column: 2;
    width: 440px;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
