/* Page-specific layouts */

/* ============ Landing ============ */
.landing { overflow-x: hidden; }
.landing-hero {
  position: relative;
  padding: 80px 24px 32px;
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
}
.landing-hero .eyebrow {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}
.landing-hero h1 {
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.landing-hero h1 .accent {
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing-hero .sub {
  margin-top: 18px;
  font-size: 17px;
  color: var(--text-body);
}

.landing-main {
  max-width: 980px;
  margin: 24px auto 0;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  padding: 0 24px 80px;
}
@media (max-width: 800px) {
  .landing-main { grid-template-columns: 1fr; }
}

.landing-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.landing-panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 22px;
}
.landing-panel h2 .marker {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--primary);
  border-radius: 50%;
}
.landing-panel.host h2 .marker { background: var(--amber); }
.landing-panel .desc {
  color: var(--text-body);
  font-size: 14px;
  margin-bottom: 20px;
}

#join-form { display: grid; gap: 12px; }
#join-form input { font-size: 16px; }
#join-form input#pin {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 18px 14px;
}
.landing-panel button, .landing-panel .btn { width: 100%; }

/* ============ Dashboard ============ */
.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.dashboard-head h1 small {
  display: block;
  font-size: 14px;
  color: var(--text-body);
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.dashboard-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar .search {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.toolbar .search input {
  padding-left: 40px;
}
.toolbar .search::before {
  content: '⌕';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

.quiz-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.quiz-item {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.quiz-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--primary-ring);
}
.quiz-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.quiz-title:hover { color: var(--primary-dark); }
.quiz-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.quiz-item .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}
.quiz-item .actions .btn {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
}
.quiz-title-input {
  font-size: 18px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--primary);
  background: #fff;
  width: 100%;
}

/* ============ Editor ============ */
.editor-head {
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.title-input {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 900;
  letter-spacing: -0.02em;
  border: 0;
  background: transparent;
  padding: 4px 0;
  color: var(--text);
}
.title-input:focus {
  outline: none;
  box-shadow: 0 2px 0 var(--primary);
  border-radius: 0;
}
#description {
  border: 1px solid var(--border);
  margin-top: 12px;
  font-size: 15px;
  color: var(--text-body);
}

.questions-list { list-style: none; display: grid; gap: 16px; }
.question-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.18s ease;
}
.question-item:hover {
  box-shadow: var(--shadow-card-hover);
}
.q-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.q-num {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex: 0 0 auto;
}
.q-text {
  flex: 1;
  font-weight: 500;
  font-size: 16px;
}
.q-time-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.q-time-wrap .q-time {
  width: 60px;
  border: 0;
  background: transparent;
  padding: 8px 4px;
  text-align: center;
  font-weight: 700;
}
.q-time-wrap .q-time:focus { box-shadow: none; }
.q-time-wrap .q-time-unit {
  align-self: center;
  padding: 0 10px 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  border-left: 1px solid var(--border);
  height: 100%;
  display: grid;
  place-items: center;
}

.q-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 600px) {
  .q-options { grid-template-columns: 1fr; }
}
.q-option {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  color: #fff;
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  cursor: pointer;
}
.q-option.opt-0 { background: linear-gradient(135deg, var(--opt-0) 0%, #ff8559 100%); }
.q-option.opt-1 { background: linear-gradient(135deg, var(--opt-1) 0%, #fbbf24 100%); }
.q-option.opt-2 { background: linear-gradient(135deg, var(--opt-2) 0%, #f97316 100%); }
.q-option.opt-3 { background: linear-gradient(135deg, var(--opt-3) 0%, #fdba74 100%); }
.q-option input[type=radio] {
  width: auto;
  flex: 0 0 auto;
  accent-color: #fff;
  cursor: pointer;
}
.q-option .q-opt-text {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-weight: 600;
  padding: 6px 10px;
}
.q-option .q-opt-text:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
  border-color: #fff;
}
.q-option .q-opt-text::placeholder {
  color: rgba(255, 255, 255, 0.7);
}
.q-option:has(input[type=radio]:checked) {
  box-shadow: 0 0 0 3px var(--success), var(--shadow-lift);
  transform: scale(1.02);
}
.q-option:has(input[type=radio]:checked)::after {
  content: '✓ 正解';
  position: absolute;
  top: -10px;
  right: 10px;
  background: var(--success);
  color: #fff;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
  box-shadow: 0 4px 10px -2px rgba(46, 184, 114, 0.4);
}
.question-item .btn.danger {
  font-size: 18px;
  padding: 4px 12px;
  line-height: 1;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

/* ============ Host stage ============ */
.host {
  min-height: 100dvh;
}
.host .stage {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* Lobby */
.lobby { display: grid; gap: 28px; }
.lobby-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  background: var(--surface);
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
@media (max-width: 700px) {
  .lobby-head { grid-template-columns: 1fr; }
}
.lobby-quiz-title {
  font-size: clamp(22px, 3.5vw, 36px);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.lobby-quiz-title small {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}
.pin-display {
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-1) 100%);
  border: 1px solid var(--primary-ring);
  border-radius: var(--radius-lg);
  padding: 20px 32px;
  display: inline-block;
  text-align: center;
  box-shadow: 0 8px 24px -8px var(--primary-ring);
}
.pin-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-body);
  font-weight: 700;
}
.pin {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  font-size: clamp(40px, 7vw, 72px);
  letter-spacing: 0.04em;
  line-height: 1;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pin-hint {
  font-size: 13px;
  margin-top: 10px;
  color: var(--text-body);
}
.pin-hint strong {
  color: var(--text);
  font-weight: 700;
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.players {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.players-count {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 16px;
}
.players-count::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--success-bg);
}
.start-row {
  display: flex;
  justify-content: center;
}

/* Question stage */
.q-stage { display: grid; gap: 24px; }
.q-header-stage {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.q-header-stage > span:first-child {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-body);
  letter-spacing: 0.04em;
}
.timer {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  padding: 8px 22px;
  border-radius: var(--radius-pill);
  font-size: 24px;
  min-width: 72px;
  text-align: center;
  box-shadow: 0 6px 18px -6px var(--primary-ring);
}
.q-text-stage {
  font-weight: 900;
  font-size: clamp(24px, 4.5vw, 44px);
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-align: center;
  padding: 32px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.q-options-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 700px) {
  .q-options-stage { grid-template-columns: 1fr; }
}

/* Results / leaderboard layout */
.results-stage { display: grid; gap: 24px; }
.results-stage h2 {
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Final */
.ended-stage { text-align: center; }
.ended-stage h1 {
  font-size: clamp(48px, 8vw, 88px);
  margin: 24px 0 32px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 16px;
}
.ended-stage h1 .yellow-circle {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  background: var(--amber-light);
  border-radius: 50%;
  -webkit-text-fill-color: var(--amber-light);
}
.final-list {
  list-style: none;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
}
.final-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px;
  gap: 18px;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.final-row .rank {
  font-weight: 900;
  font-size: 24px;
  color: var(--text-muted);
}
.final-row .who {
  font-weight: 700;
  font-size: 17px;
  text-align: left;
  color: var(--text);
}
.final-row .score {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  font-size: 22px;
  text-align: right;
  color: var(--primary-dark);
}
.final-row.rank-1 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: var(--amber);
  box-shadow: var(--shadow-card);
}
.final-row.rank-1 .rank { color: var(--amber); }
.final-row.rank-2 {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-color: var(--border-strong);
}
.final-row.rank-2 .rank { color: var(--text-body); }
.final-row.rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  border-color: var(--light-orange);
}
.final-row.rank-3 .rank { color: var(--primary-dark); }

/* ============ Player ============ */
.player {
  min-height: 100dvh;
}
.player .stage {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
  display: grid;
}
.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  align-self: center;
  text-align: center;
  display: grid;
  gap: 16px;
  align-content: center;
  box-shadow: var(--shadow-card);
}
.player-nick {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  margin: 0 auto;
  box-shadow: 0 4px 12px -2px var(--primary-ring);
}
.player-q-text {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  line-height: 1.3;
  padding: 12px 0;
  color: var(--text);
}
.player-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.player-options .opt-tile {
  min-height: 130px;
  padding: 18px;
  font-size: 16px;
  cursor: pointer;
}
.player-options .opt-tile:active { transform: scale(0.97); }
.player-card.good {
  background: linear-gradient(135deg, var(--success-bg) 0%, var(--success-bg-2) 100%);
  border-color: var(--success);
}
.player-card.good h1 { color: var(--success); }
.player-card.bad {
  background: linear-gradient(135deg, var(--danger-bg) 0%, #fee2e2 100%);
  border-color: var(--danger);
}
.player-card.bad h1 { color: var(--danger); }
.player-card h1 {
  font-size: clamp(48px, 12vw, 80px);
  margin: 8px 0;
  font-weight: 900;
}
.big-score {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  font-size: 56px;
  color: var(--primary-dark);
  margin: 8px 0 0;
}

/* Player — full-bleed when answering */
body.player .stage:has(.with-options) {
  max-width: 100%;
  padding: 0;
}
body.player .player-card.with-options {
  border: 0;
  border-radius: 0;
  padding: 12px;
  min-height: 100dvh;
  align-content: start;
  gap: 12px;
  box-shadow: none;
  background: transparent;
}
body.player .player-card.with-options .player-options {
  flex: 1;
  gap: 10px;
  align-content: stretch;
  min-height: calc(100dvh - 200px);
}
body.player .player-card.with-options .player-options .opt-tile {
  min-height: 0;
  height: 100%;
  font-size: clamp(20px, 5vw, 28px);
  padding: 24px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  border-radius: var(--radius-lg);
}
body.player .player-card.with-options .player-options .opt-tile .opt-letter {
  font-size: clamp(28px, 7vw, 48px);
  width: clamp(56px, 12vw, 80px);
  height: clamp(56px, 12vw, 80px);
}

/* ============ Host disconnect screens ============ */
.host-disconnect {
  display: grid;
  gap: 18px;
  place-items: center;
  text-align: center;
  padding: 60px 24px;
  max-width: 480px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.host-disconnect.warn h2 { color: var(--text-body); }
.host-disconnect.bad h2 { color: var(--danger); }

/* ============ History page ============ */
.history-list {
  list-style: none;
  display: grid;
  gap: 12px;
}
.history-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.history-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--primary-ring);
}
@media (max-width: 700px) {
  .history-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
.history-pin {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 800;
  font-size: 18px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}
.history-title {
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
}
.history-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* Detail block */
.history-detail {
  margin-top: 28px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 22px;
}
.history-detail h2 { font-size: 22px; margin-bottom: 4px; }
.history-detail .summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--text-body);
}
.history-detail .summary .chip { font-size: 13px; }

.history-q-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface-soft);
}
.history-q-text {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 14px;
  color: var(--text);
}
.history-q-bars { display: grid; gap: 8px; }
.history-bar {
  display: grid;
  grid-template-columns: 28px 1fr 50px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.history-bar .opt-letter-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
}
.history-bar .opt-letter-mini.opt-0 { background: var(--opt-0); }
.history-bar .opt-letter-mini.opt-1 { background: var(--opt-1); }
.history-bar .opt-letter-mini.opt-2 { background: var(--opt-2); }
.history-bar .opt-letter-mini.opt-3 { background: var(--opt-3); }
.history-bar.is-correct .opt-text { color: var(--success); font-weight: 700; }
.history-bar.is-correct .opt-text::after {
  content: ' ✓';
  color: var(--success);
}
.history-bar-track {
  height: 22px;
  background: var(--border-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.history-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--amber) 100%);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  min-width: 8px;
  transition: width 0.6s ease;
}
.history-bar.is-correct .history-bar-fill {
  background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
}
.history-bar .opt-text {
  font-size: 13px;
  color: var(--text);
}
.history-bar .count {
  text-align: right;
  font-weight: 700;
  color: var(--text-body);
  font-size: 13px;
}

.history-top3 {
  display: grid;
  gap: 8px;
}
.history-top3 .leader-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-1);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.history-top3 .leader-row .rank-num {
  font-weight: 800;
  color: var(--primary-dark);
  margin-right: 10px;
}
