:root {
  --ink: #25324a;
  --muted: #8992a6;
  --purple: #7669e8;
  --purple-dark: #6256d9;
  --purple-soft: #f0eefe;
  --pink: #e78bb6;
  --green: #42b994;
  --line: #edf0f6;
  --surface: rgba(255, 255, 255, 0.92);
  --shadow: 0 24px 70px rgba(63, 69, 112, 0.11), 0 3px 12px rgba(63, 69, 112, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: #f5f7fc; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 10% 5%, rgba(206, 218, 255, 0.45), transparent 30%),
    radial-gradient(circle at 95% 90%, rgba(245, 215, 234, 0.42), transparent 32%),
    linear-gradient(145deg, #f7f9fd 0%, #f1f4fb 100%);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(118, 105, 232, 0.2);
  outline-offset: 3px;
}
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ambient { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; opacity: 0.7; }
.ambient-one { width: 240px; height: 240px; left: -100px; top: 36%; background: rgba(218, 214, 255, 0.28); }
.ambient-two { width: 180px; height: 180px; right: -70px; top: 12%; background: rgba(255, 222, 235, 0.3); }

.page-shell { width: min(100% - 32px, 440px); margin: 0 auto; padding: 42px 0 24px; position: relative; }
.brand { display: flex; align-items: center; justify-content: center; gap: 13px; margin-bottom: 26px; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; position: relative;
  color: #fff; font-size: 25px; font-weight: 800; transform: rotate(-4deg);
  background: linear-gradient(145deg, #8a7cf1, #6d5dde);
  box-shadow: 0 10px 24px rgba(112, 94, 220, 0.26);
}
.brand-mark:after { content: ""; position: absolute; width: 12px; height: 12px; right: -4px; bottom: 5px; background: #7160df; clip-path: polygon(0 0, 100% 100%, 0 75%); }
.brand-mark i { position: absolute; width: 9px; height: 9px; right: -12px; top: 1px; border-radius: 50%; background: #efa4c6; box-shadow: 7px -7px 0 -2px #f2c2d8; }
.brand h1 { font-size: 25px; line-height: 1.2; margin: 0 0 6px; letter-spacing: 3px; font-weight: 800; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 1px; }

.card {
  background: var(--surface); border: 1px solid rgba(255, 255, 255, 0.9); border-radius: 28px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.home-card { padding: 32px 28px 24px; animation: rise-in 0.5s ease both; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: #8a7edc; font-size: 11px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 16px; }
.eyebrow span { width: 16px; height: 2px; border-radius: 2px; background: #9a8fe8; }
.home-card h2 { font-size: 29px; line-height: 1.42; margin: 0 0 12px; letter-spacing: 0.5px; font-weight: 800; }
.intro { color: var(--muted); font-size: 14px; line-height: 1.85; margin: 0 0 27px; }
.field-label { display: block; color: #606c82; font-size: 12px; font-weight: 650; margin: 0 0 9px 2px; }
.input-wrap { position: relative; }
input {
  width: 100%; height: 52px; border: 1.5px solid #e8ebf2; background: #f8f9fc; border-radius: 15px;
  color: var(--ink); padding: 0 16px; outline: none; font-size: 15px; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
input::placeholder { color: #b0b7c5; }
input:focus { background: #fff; border-color: #9b91ee; box-shadow: 0 0 0 4px rgba(118, 105, 232, 0.08); }
.input-wrap input { padding-right: 54px; }
.input-count { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #b2b9c7; font-size: 11px; pointer-events: none; }
.btn {
  border: 0; border-radius: 15px; min-height: 51px; padding: 0 18px; display: flex; align-items: center; justify-content: center;
  gap: 9px; cursor: pointer; font-weight: 700; font-size: 15px; transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(2px); }
.btn:disabled { cursor: default; opacity: 0.58; transform: none; box-shadow: none; }
.btn-primary {
  color: #fff; background: linear-gradient(135deg, #8476ee, #6b5bd8); box-shadow: 0 9px 20px rgba(107, 91, 216, 0.23);
}
.btn-primary:hover { box-shadow: 0 11px 25px rgba(107, 91, 216, 0.3); }
.home-card > .btn { width: 100%; }
#createBtn { margin-top: 17px; }
.btn-soft { min-height: 44px; margin-top: 9px; color: #7c70d5; background: transparent; font-size: 13px; }
.btn-soft:hover { background: #f5f3fe; }
.btn-soft svg { width: 16px; height: 16px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: #a2aaba; font-size: 11px; }
.divider:before, .divider:after { content: ""; height: 1px; background: var(--line); flex: 1; }
.join-row { display: grid; grid-template-columns: 1fr 91px; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 2px; font-size: 14px; }
.btn-join { min-height: 52px; background: #eef1fb; color: #61718e; font-size: 14px; }
.btn-join:hover { background: #e7eaf7; }
.online-stats { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 19px 0 0; color: #a0a8b8; font-size: 11px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #61c5a5; box-shadow: 0 0 0 3px rgba(97, 197, 165, 0.12); }
footer { display: flex; justify-content: center; align-items: center; gap: 12px; color: #a6adbb; font-size: 11px; padding: 23px 0 0; }
footer button { border: 0; background: transparent; color: #8f98aa; cursor: pointer; padding: 4px; font-size: 11px; }
footer button:hover { color: var(--purple); }

.room-card { padding: 22px; animation: rise-in 0.45s ease both; }
.room-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 21px; }
.room-code { display: flex; align-items: center; gap: 7px; background: transparent; border: 0; padding: 0; cursor: pointer; color: var(--ink); }
.room-code > span { color: #9aa3b4; font-size: 10px; }
.room-code strong { font-size: 14px; letter-spacing: 1px; }
.room-code svg { width: 14px; height: 14px; color: #a0a8b8; }
.room-code.copied svg { color: var(--green); }
.round-badge { margin-left: auto; white-space: nowrap; background: #f3f2fb; color: #8b82b9; border-radius: 20px; padding: 6px 10px; font-size: 10px; }
.round-badge b { color: #7065bc; }
.text-btn { border: 0; background: transparent; color: #b0a0aa; font-size: 11px; padding: 5px 0 5px 3px; cursor: pointer; }
.text-btn:hover { color: #dc7f91; }
.topic-panel { display: flex; align-items: center; padding: 14px; gap: 11px; background: linear-gradient(120deg, #f7f4ff, #fbf8ff); border: 1px solid #eeebfa; border-radius: 17px; }
.topic-icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; background: #eae5fd; color: #8273de; border-radius: 12px; }
.topic-icon svg { width: 18px; height: 18px; }
.topic-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.topic-copy span { font-size: 10px; color: #a39ab9; }
.topic-copy strong { font-size: 14px; color: #66558e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { margin-left: auto; width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 10px; color: #8d7fd4; background: rgba(255,255,255,0.7); cursor: pointer; }
.icon-btn:hover { background: #fff; }
.icon-btn svg { width: 15px; height: 15px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 12px; }
.section-heading > span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #6d788c; font-weight: 650; }
.section-heading svg { width: 15px; height: 15px; color: #929caf; }
.section-heading b { color: #929caf; font-weight: 500; }
.section-heading small { font-size: 10px; color: #a4acba; }
.players-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.player-card { min-width: 0; position: relative; padding: 13px 5px 11px; text-align: center; background: #fafbfc; border: 1.5px solid #f0f2f5; border-radius: 15px; transition: all 0.25s; }
.player-card.self { background: #f8f6ff; border-color: #cfc7f6; }
.player-card.submitted { background: #f4fbf8; border-color: #cceadd; }
.player-card.revealed { background: #fffaf3; border-color: #f1dfbd; }
.player-avatar { width: 34px; height: 34px; margin: 0 auto 7px; display: grid; place-items: center; border-radius: 12px; color: #7b719a; background: #eae7f2; font-size: 13px; font-weight: 800; }
.player-card.self .player-avatar { color: #fff; background: linear-gradient(145deg, #a294ed, #7e6ed5); }
.player-card.submitted .player-avatar { color: #fff; background: #77c7ab; }
.player-card.revealed .player-avatar { color: #fff; background: #dcb677; }
.player-name { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 3px; color: #596578; font-size: 11px; font-weight: 700; }
.player-status { display: flex; justify-content: center; align-items: center; gap: 3px; margin-top: 4px; color: #a3abba; font-size: 9px; }
.player-card.submitted .player-status { color: #58aa8d; }
.player-card.revealed .player-status { color: #c69a55; }
.player-status svg { width: 10px; height: 10px; }
.host-tag { position: absolute; right: -3px; top: -5px; padding: 2px 5px; border-radius: 5px; background: #fff2d9; color: #b38a43; font-size: 8px; font-weight: 700; box-shadow: 0 2px 5px rgba(80,60,20,0.06); }
.play-area { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.play-area .btn { width: 100%; margin-top: 13px; }
.privacy-tip { margin: 11px 0 0; text-align: center; color: #a7afbd; font-size: 10px; }
.waiting-area { margin-top: 23px; padding: 28px 16px 20px; text-align: center; border-top: 1px solid var(--line); }
.waiting-symbol { display: flex; justify-content: center; gap: 6px; height: 22px; align-items: center; }
.waiting-symbol span { width: 7px; height: 7px; background: #9b8de7; border-radius: 50%; animation: bounce 1.2s infinite ease-in-out; }
.waiting-symbol span:nth-child(2) { animation-delay: 0.15s; }
.waiting-symbol span:nth-child(3) { animation-delay: 0.3s; }
.waiting-area h3 { margin: 10px 0 7px; font-size: 18px; }
.waiting-area p { color: var(--muted); font-size: 12px; margin: 0; }
.answer-preview { display: inline-block; margin-top: 17px; padding: 8px 14px; border-radius: 10px; background: #f6f4fc; color: #9990b0; font-size: 11px; }
.answer-preview strong { color: #7566b7; margin-left: 4px; }

.result-area { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.result-hero { text-align: center; padding: 4px 0 18px; }
.result-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 6px 11px; color: #9c75b9; background: #f6ebfa; font-size: 10px; font-weight: 700; }
.result-badge.missed { color: #8994a7; background: #f0f2f6; }
.result-badge svg { width: 12px; height: 12px; }
.result-hero h3 { margin: 11px 0 7px; font-size: 23px; letter-spacing: 1px; }
.result-hero p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.match-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 13px; }
.match-word { background: linear-gradient(135deg, #fff2f8, #f7f0ff); color: #b067a0; border: 1px solid #f1deef; padding: 7px 12px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.answer-list { display: flex; flex-direction: column; gap: 7px; }
.answer-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #f8f9fb; }
.answer-row.match { background: #fff6fb; }
.answer-row .mini-avatar { width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center; border-radius: 9px; background: #e9e7f0; color: #817795; font-size: 10px; font-weight: 800; }
.answer-row.match .mini-avatar { color: #b56c9e; background: #f4ddec; }
.answer-name { max-width: 95px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #8992a3; font-size: 11px; }
.answer-word { margin-left: auto; max-width: 190px; overflow-wrap: anywhere; text-align: right; color: #4b566c; font-size: 13px; font-weight: 700; }
.answer-row.match .answer-word { color: #b35e98; }
#nextRoundBtn { width: 100%; margin-top: 16px; }
.history-box { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 15px; }
.history-box summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; color: #939cad; font-size: 11px; padding: 3px 2px; }
.history-box summary::-webkit-details-marker { display: none; }
.history-box summary > span { display: flex; align-items: center; gap: 6px; }
.history-box summary svg { width: 13px; height: 13px; }
.history-box .chevron { transition: transform 0.2s; }
.history-box[open] .chevron { transform: rotate(180deg); }
.history-list { padding-top: 11px; }
.history-item { padding: 12px 2px; border-bottom: 1px dashed #eceef3; }
.history-item:last-child { border-bottom: 0; }
.history-meta { display: flex; justify-content: space-between; color: #a0a8b6; font-size: 9px; margin-bottom: 8px; }
.history-meta .has-match { color: #b47ba5; }
.history-answers { display: flex; flex-wrap: wrap; gap: 5px; }
.history-answer { padding: 5px 8px; border-radius: 7px; background: #f5f6f9; color: #778195; font-size: 10px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; background: rgba(33, 38, 57, 0.36); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
.modal-card { width: min(100%, 380px); position: relative; padding: 29px 25px 25px; border-radius: 24px; background: #fff; box-shadow: 0 30px 80px rgba(30,35,60,0.2); animation: modal-in 0.25s ease both; }
.modal-close { position: absolute; top: 15px; right: 15px; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 10px; background: #f5f6f9; color: #929aac; cursor: pointer; }
.modal-close svg { width: 15px; height: 15px; }
.modal-kicker { color: #9589d7; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.modal-card h2 { margin: 7px 0 7px; font-size: 21px; }
.modal-card > p { margin: 0 0 19px; color: #a0a8b6; font-size: 11px; }
.topic-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 22px; }
.topic-option { border: 1px solid #e8e4f5; border-radius: 10px; background: #f8f6fd; color: #8073b2; padding: 8px 13px; font-size: 12px; cursor: pointer; }
.topic-option:hover, .topic-option.active { background: #ebe6fc; border-color: #cfc4f2; color: #6b59bb; }
.modal-input-row { display: grid; grid-template-columns: 1fr 72px; gap: 8px; }
.modal-input-row input { height: 45px; font-size: 13px; }
.modal-input-row .btn { min-height: 45px; padding: 0; font-size: 13px; }
.rules-list { list-style: none; padding: 0; margin: 22px 0; display: flex; flex-direction: column; gap: 20px; }
.rules-list li { display: flex; gap: 13px; }
.rules-list li > b { color: #c7bfeb; font-size: 18px; line-height: 1.3; font-style: italic; }
.rules-list strong { font-size: 13px; }
.rules-list p { margin: 5px 0 0; color: #939cad; font-size: 11px; line-height: 1.65; }
.help-card > .btn { width: 100%; }
.toast { position: fixed; z-index: 100; left: 50%; top: 24px; transform: translate(-50%, -12px); max-width: calc(100% - 40px); padding: 11px 18px; border-radius: 13px; background: rgba(38, 44, 61, 0.92); color: #fff; box-shadow: 0 8px 25px rgba(20,25,40,0.16); font-size: 12px; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -15px; width: 8px; height: 13px; border-radius: 2px; animation: confetti-fall 1.8s ease-in forwards; }

@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-6px); opacity: 1; } }
@keyframes confetti-fall { to { transform: translate3d(var(--drift), 105vh, 0) rotate(640deg); opacity: 0.2; } }

@media (max-width: 380px) {
  .page-shell { width: min(100% - 24px, 440px); padding-top: 28px; }
  .home-card { padding: 27px 22px 22px; }
  .home-card h2 { font-size: 26px; }
  .room-card { padding: 18px; }
  .players-grid { gap: 7px; }
  .room-code > span { display: none; }
}
@media (min-width: 700px) {
  .page-shell { padding-top: 6vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
