/* Player (phone) layout – designed for 360–430px, scales up gracefully */
body.player {
  overscroll-behavior-y: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + var(--safe-top)) calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  background: var(--bg);
  border-bottom: 1px solid rgba(116, 116, 128, 0.5);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.me-chip {
  font-size: 14px;
  color: var(--muted);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sound-btn .mute {
  display: none;
}
#sound-btn[aria-pressed='false'] .waves {
  display: none;
}
#sound-btn[aria-pressed='false'] .mute {
  display: inline;
}
#sound-btn[aria-pressed='false'] {
  color: var(--muted);
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px calc(18px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(18px + var(--safe-left));
  outline: none;
}

.screen {
  display: grid;
  gap: 18px;
  animation: fade-up 0.42s var(--ease) both;
}
.screen-head {
  display: grid;
  gap: 8px;
}
.stack {
  display: grid;
  gap: 14px;
}
.lede {
  color: var(--muted);
  font-size: 17px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 14px;
}
.center {
  text-align: center;
}
.h3 {
  font-size: 19px;
}
.hint {
  font-size: 15px;
  color: var(--muted);
}
.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.eyebrow.small {
  font-size: 12px;
}
.row-actions {
  display: grid;
  gap: 8px;
  justify-items: center;
}

/* loading */
.screen-loading {
  min-height: 50vh;
  place-content: center;
  justify-items: center;
}
.loader {
  display: flex;
  gap: 8px;
}
.loader span {
  width: 10px;
  height: 10px;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
.loader span:nth-child(2) {
  animation-delay: 0.15s;
}
.loader span:nth-child(3) {
  animation-delay: 0.3s;
}

/* name */
.hero {
  display: grid;
  gap: 14px;
  padding: 18px 0 8px;
}
.hero-title {
  font-size: clamp(36px, 11vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.hl {
  position: relative;
  display: inline-block;
}
.hl::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 4px;
  background: var(--accent);
  transform-origin: left;
  animation: draw-line 0.8s 0.2s var(--ease) both;
}

/* teams */
.team-list {
  display: grid;
  gap: 10px;
}
.team-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.team-option.is-mine {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}
.team-option-body {
  flex: 1;
  min-width: 0;
  display: grid;
}
.team-option-body strong {
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-option-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-emoji {
  font-size: 28px;
  line-height: 1;
  width: 40px;
  text-align: center;
  flex: none;
}
.team-emoji.big {
  font-size: 48px;
  width: auto;
}
.create-form {
  margin-top: 4px;
}
.emoji-pick {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.emoji-pick legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}
.emoji-grid label {
  position: relative;
  display: grid;
  place-items: center;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 24px;
  cursor: pointer;
}
.emoji-grid input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.emoji-grid label:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: rgba(26, 154, 250, 0.12);
}
.emoji-grid label.is-checked {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: rgba(26, 154, 250, 0.12);
}
.emoji-grid label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.emoji-grid label.is-used {
  opacity: 0.35;
}

/* lobby */
.team-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}
.team-hero h1 {
  font-size: clamp(28px, 8vw, 36px);
  overflow-wrap: anywhere;
}
.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.member-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  animation: fade-up 0.3s var(--ease) both;
}
.member-list .m-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-list .you {
  color: var(--muted);
  font-size: 14px;
}
.status-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border-left: 4px solid var(--accent);
  background: var(--bg-deep);
  border-radius: var(--radius);
}
.status-card .dot {
  margin-top: 8px;
}

/* question */
.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.q-timer {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.q-timer svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.q-timer circle {
  fill: none;
  stroke-width: 3;
}
.q-timer .track {
  stroke: var(--gray-2);
}
.q-timer .ring {
  stroke: var(--accent);
  stroke-dasharray: 106.8;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear;
}
.q-timer.urgent span {
  animation: pulse 0.6s ease-in-out infinite;
}
.q-timer.done span {
  font-size: 12px;
}
.progress {
  height: 2px;
  background: rgba(116, 116, 128, 0.5);
  margin-top: -10px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.6s var(--ease);
}
.morph {
  margin: 0;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-deep);
  aspect-ratio: 1 / 1;
  width: min(100%, 48vh);
  margin-inline: auto;
  border: 1px solid rgba(116, 116, 128, 0.6);
}
.morph img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}
.morph img.loaded {
  opacity: 1;
  animation: image-in 1.1s var(--ease) both;
}
.q-prompt {
  font-size: 18px;
  font-weight: 600;
}
.q-prompt .num {
  color: var(--accent);
}
.allin {
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 600;
  text-align: center;
  animation: pulse 1.2s ease-in-out infinite;
}
.lead-area {
  display: grid;
  gap: 14px;
}
.lead-note {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 15px;
  color: var(--muted);
}
.answer-form fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.answer-form legend {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.answer-form .input {
  scroll-margin: 120px 0 160px;
}
.submit-bar {
  display: grid;
  gap: 4px;
  padding-top: 4px;
}
.locked {
  display: grid;
  gap: 14px;
  border-color: var(--accent);
}
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
}
.stamp .tick {
  background: var(--accent);
  font-size: 18px;
  width: 34px;
  height: 34px;
}
.stamp.animate {
  animation: pop 0.55s var(--ease) both;
}
.answer-summary {
  display: grid;
  gap: 6px;
  margin: 0;
}
.answer-summary dt {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.answer-summary dd {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.answer-summary .blank {
  color: var(--gray-2);
  font-weight: 400;
}
.team-status {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip.is-mine {
  box-shadow: inset 0 0 0 1px var(--fg);
}

/* reveal */
.answer-panel {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
}
.r-thumb {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.answer-text {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.answer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.answer-list li {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
  animation: fade-up 0.5s var(--ease) both;
}
.answer-list li small {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.my-result {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  animation: fade-up 0.5s 0.25s var(--ease) both;
}
.points {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 700;
}
.points .plus,
.points .num {
  font-size: 56px;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.points .pts-label {
  font-size: 18px;
  margin-left: 6px;
  color: var(--muted);
}
.my-answers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.my-answers li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.my-answers .blank {
  color: var(--gray-2);
}

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.board-row {
  display: grid;
  grid-template-columns: 30px 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(116, 116, 128, 0.6);
  border-radius: var(--radius);
  background: var(--bg);
  position: relative;
}
.board-row.is-mine {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}
.board-row .rank {
  font-weight: 700;
  font-size: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.board-row .team-emoji {
  font-size: 24px;
  width: 34px;
}
.board-row .b-body {
  min-width: 0;
  display: grid;
}
.board-row .b-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-row .b-answers {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}
.board-row .b-answers span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}
.board-row .b-answers .tick,
.board-row .b-answers .cross {
  font-size: 10px;
}
.board-row .b-score {
  display: grid;
  justify-items: end;
  font-variant-numeric: tabular-nums;
}
.board-row .total {
  font-size: 22px;
  font-weight: 700;
}
.board-row .gain {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.board-row .gain.zero {
  color: var(--gray-2);
}
.waiting-line {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  padding: 8px 0;
}

/* final */
.final-title {
  font-size: clamp(34px, 10vw, 44px);
}
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 8px;
  min-height: 250px;
  padding-top: 10px;
}
.podium-col {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  min-width: 0;
}
.podium-col .p-emoji {
  font-size: 34px;
  animation: pop 0.6s var(--ease) both;
}
.podium-col .p-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.podium-col .p-score {
  font-size: 14px;
  color: var(--muted);
}
.podium-block {
  width: 100%;
  display: grid;
  place-items: start center;
  padding-top: 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 28px;
  font-weight: 700;
  transform-origin: bottom;
  animation: rise 0.9s var(--ease) both;
}
.podium-col.p1 .podium-block {
  height: 150px;
  border-color: var(--accent);
  border-top: 4px solid var(--accent);
  color: var(--accent);
  animation-delay: 0.9s;
}
.podium-col.p2 .podium-block {
  height: 110px;
  animation-delay: 0.45s;
}
.podium-col.p3 .podium-block {
  height: 80px;
}
.podium-col.p1 .p-emoji {
  animation-delay: 1.5s;
  font-size: 44px;
}
.podium-col.p2 .p-emoji {
  animation-delay: 1.05s;
}
.podium-col.p3 .p-emoji {
  animation-delay: 0.6s;
}
.podium-col.is-mine .p-name {
  color: var(--accent);
}
.f-mine {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
@keyframes rise {
  from {
    transform: scaleY(0);
  }
}

@media (min-width: 700px) {
  .app {
    padding-top: 32px;
  }
}
