:root {
  --bg: #2f524c;
  --bg-deep: #25433e;
  --ink: #f6f3ee;
  --muted: #c9d5d1;
  --peach: #f3c9b6;
  --peach-2: #e9b79f;
  --beige: #cbb6a4;
  --radio: #6f9a8c;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 40px rgba(12, 24, 22, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: #1a2c29;
  color: var(--ink);
  font-family: Onest, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
}

button,
input {
  font-family: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.phone {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}

.screen.is-active {
  display: flex;
}

.hero {
  height: min(42dvh, 340px);
  overflow: hidden;
  position: relative;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  filter: grayscale(1) contrast(1.08);
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  background: linear-gradient(180deg, transparent, var(--bg));
}

.welcome-body,
.panel-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 22px calc(22px + var(--safe-b));
}

.welcome-body h1,
.panel-title {
  font-weight: 800;
  font-size: clamp(28px, 8.4vw, 36px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: #fff;
}

.eyebrow {
  color: #d7c2b4;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.lead {
  margin-top: 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
  max-width: 34ch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  width: 100%;
}

.btn-peach {
  margin-top: auto;
  background: linear-gradient(180deg, #f7d3c3 0%, var(--peach) 55%, var(--peach-2) 100%);
  color: #3b3b3b;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.btn-peach::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.5), transparent 42%);
  pointer-events: none;
}

.btn-peach:active {
  transform: scale(0.985);
}

.btn-ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
}

.btn-next {
  background: #d4c3b3;
  color: #3a322c;
  min-height: 52px;
  min-width: 0;
  width: auto;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 15px;
  flex: 1;
}

.btn-back {
  width: 52px;
  min-width: 52px;
  min-height: 52px;
  border-radius: 12px;
  background: #1f3531;
  color: #fff;
  border: 1px solid var(--line);
  font-size: 20px;
}

.btn-back:disabled {
  opacity: 0.35;
}

.host-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  color: #9fb4ae;
  font-size: 13px;
  text-decoration: none;
}

.join-form {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 14px;
  padding: 0 16px;
  font-size: 16px;
  outline: none;
}

.field textarea {
  min-height: 120px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.4;
}

.field select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 14px;
  padding: 0 16px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
  appearance: none;
}

.field select option {
  background: #2f524c;
  color: #fff;
}

.field select:focus {
  border-color: var(--peach);
}

.form-error {
  color: #f3b4b4;
  font-size: 14px;
  margin-bottom: 10px;
}

.hidden {
  display: none !important;
}

.lobby-screen {
  padding-top: calc(28px + var(--safe-t));
}

.counter {
  margin: 18px 0 12px;
  font-size: 14px;
  color: var(--peach);
}

.players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: 42dvh;
}

.players li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--peach);
  color: #3b3b3b;
  font-weight: 700;
  flex: 0 0 auto;
}

.player-name {
  font-weight: 600;
}

.player-tag {
  margin-left: auto;
  font-size: 12px;
  color: #d7c2b4;
}

.lobby-actions {
  margin-top: auto;
  padding-top: 16px;
}

.wait-note {
  text-align: center;
  color: var(--muted);
  min-height: 24px;
}

.wait-note:not(.hidden) {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

.question-scroll {
  flex: 1;
  overflow: auto;
  padding: calc(18px + var(--safe-t)) 18px 16px;
}

.question-text {
  font-size: clamp(20px, 5.6vw, 24px);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.question-media {
  margin: 16px 0 18px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.question-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 34dvh;
  object-fit: contain;
  background: #fff;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.option {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.option.is-selected {
  border-color: rgba(243, 201, 182, 0.7);
  background: rgba(243, 201, 182, 0.08);
}

.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #5e8379;
  flex: 0 0 auto;
  margin-top: 2px;
  box-shadow: inset 0 0 0 7px var(--bg);
}

.option.is-selected .radio {
  background: var(--radio);
  box-shadow: inset 0 0 0 4px var(--bg);
}

.option-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.option.is-best {
  border-color: rgba(226, 181, 74, 0.7);
  background: rgba(226, 181, 74, 0.1);
}

.opt-points {
  color: var(--peach);
  font-size: 13px;
  font-weight: 700;
}

.opt-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.opt-people em {
  font-style: normal;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(243, 201, 182, 0.16);
  color: var(--ink);
}

.opt-people.is-empty {
  color: var(--muted);
  font-size: 12px;
}

.q-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px calc(12px + var(--safe-b));
  background: #243f3a;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 92px;
}

.progress svg {
  width: 38px;
  height: 38px;
  transform: rotate(-90deg);
}

.progress-bg,
.progress-fg {
  fill: none;
  stroke-width: 3.4;
}

.progress-bg {
  stroke: rgba(255, 255, 255, 0.14);
}

.progress-fg {
  stroke: var(--peach);
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  stroke-dashoffset: 97.4;
  transition: stroke-dashoffset 0.35s ease;
}

.progress-label span,
.progress-label strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.progress-label strong {
  font-style: normal;
  color: #fff;
}

.q-footer-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.answered-note {
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  flex: 1 0 100%;
}

@media (min-width: 720px) {
  .phone {
    width: 430px;
    height: min(860px, calc(100dvh - 32px));
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.admin-body {
  background: var(--bg);
  overflow: auto;
}

.admin-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(20px + var(--safe-t)) 18px calc(28px + var(--safe-b));
}

.admin-screen {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.admin-screen.is-active {
  display: flex;
}

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-head .panel-title {
  font-size: 28px;
}

.admin-logout,
.admin-head .btn-ghost {
  width: auto;
  min-height: 40px;
  padding: 0 12px;
  margin-top: 0;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.q-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.q-card-thumb img,
.thumb-empty {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #1c2f2c;
}

.thumb-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.q-card-body strong {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
}

.q-card-body p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.q-card-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.q-card-actions button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 14px;
}

.admin-screen .join-form {
  flex: none;
  margin-top: 8px;
}

.admin-screen .btn-peach {
  margin-top: 12px;
}

.admin-form {
  display: flex;
  flex-direction: column;
}

.image-picker {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.image-picker img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #fff;
}

.option-row {
  display: grid;
  grid-template-columns: 36px 1fr 64px 36px 36px;
  grid-template-areas:
    "label text points clear remove"
    "label photo photo photo photo";
  gap: 8px;
  margin-bottom: 14px;
  align-items: start;
}

.option-label { grid-area: label; }
.option-text { grid-area: text; }
.option-points { grid-area: points; }
.option-photo { grid-area: photo; justify-self: start; }
.option-clear-photo { grid-area: clear; }
.option-remove { grid-area: remove; }

.option-label {
  display: grid;
  place-items: center;
  min-height: 44px;
  color: var(--peach);
  font-weight: 700;
}

.option-text,
.option-points {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  padding: 10px;
  font-family: inherit;
}

.option-points {
  min-height: 44px;
  text-align: center;
}

.option-photo,
.option-clear-photo,
.option-remove {
  min-height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  cursor: pointer;
}

.option-photo {
  grid-area: photo;
  justify-self: start;
}

.option-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
}

.option-remove {
  font-size: 22px;
  width: 40px;
  padding: 0;
  justify-self: end;
}

.round-block {
  padding: 14px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.round-head h2 {
  font-size: 18px;
  font-weight: 700;
}

.round-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.round-actions button,
.round-add-q {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 13px;
  width: auto;
  margin-top: 0;
}

.round-empty {
  color: var(--muted);
  font-size: 14px;
}

.question-scroll .eyebrow {
  margin-bottom: 8px;
}

.results-scroll {
  flex: 1;
  overflow: auto;
  padding: calc(18px + var(--safe-t)) 18px 16px;
}

.results-scroll .panel-title {
  font-size: clamp(26px, 7vw, 34px);
  margin-bottom: 18px;
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  min-height: 188px;
  margin-bottom: 22px;
}

.podium-col {
  flex: 1;
  max-width: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.podium-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 6px;
  background: var(--peach);
  color: #3b3b3b;
}

.place-1 .podium-avatar {
  width: 58px;
  height: 58px;
  background: linear-gradient(180deg, #ffe7a3, #e2b54a);
  box-shadow: 0 0 0 3px rgba(226, 181, 74, 0.35);
}

.place-2 .podium-avatar {
  background: linear-gradient(180deg, #eef2f4, #b7c2c8);
}

.place-3 .podium-avatar {
  background: linear-gradient(180deg, #f0c9a4, #c8844d);
}

.podium-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  margin: 4px 0 8px;
  font-size: 18px;
  font-weight: 800;
  color: var(--peach);
}

.place-1 .podium-score {
  font-size: 22px;
  color: #ffe7a3;
}

.podium-bar {
  width: 100%;
  border-radius: 12px 12px 4px 4px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #2a2010;
}

.place-1 .podium-bar {
  height: 96px;
  background: linear-gradient(180deg, #ffe7a3, #d7a63a);
}

.place-2 .podium-bar {
  height: 72px;
  background: linear-gradient(180deg, #edf1f4, #9eafb8);
}

.place-3 .podium-bar {
  height: 56px;
  background: linear-gradient(180deg, #f0c9a4, #c07a3e);
}

.podium-col.is-me .podium-name {
  color: var(--peach);
}

.ranking {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.rank-place {
  font-weight: 800;
  color: var(--muted);
}

.rank-name {
  font-weight: 700;
}

.rank-points {
  color: var(--peach);
  font-size: 13px;
  font-weight: 700;
}

.rank-row.place-1 {
  border-color: rgba(226, 181, 74, 0.55);
  background: rgba(226, 181, 74, 0.1);
}

.rank-row.place-1 .rank-place {
  color: #ffe7a3;
}

.rank-row.place-2 {
  border-color: rgba(186, 198, 206, 0.45);
  background: rgba(186, 198, 206, 0.08);
}

.rank-row.place-3 {
  border-color: rgba(200, 132, 77, 0.45);
  background: rgba(200, 132, 77, 0.1);
}

.rank-row.is-me {
  box-shadow: inset 0 0 0 1px rgba(243, 201, 182, 0.45);
}

#screen-results .q-footer .btn-peach {
  width: auto;
  margin-top: 0;
  min-height: 52px;
  padding: 0 16px;
  flex: 1;
}

#screen-results .q-footer .answered-note {
  flex: 1 0 100%;
}

