:root {
  --bg: #111115;
  --panel: #1b1b22;
  --panel-2: #24242d;
  --text: #f7f5ee;
  --muted: #aaa6b5;
  --line: rgba(255, 255, 255, .1);
  --hot: #ff5c7a;
  --mint: #55d6be;
  --sun: #ffd166;
  --sky: #8ec5ff;
  --violet: #c77dff;
  --ok: #90be6d;
  --bad: #f3725b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 92, 122, .2), transparent 28%),
    radial-gradient(circle at 90% 16%, rgba(85, 214, 190, .18), transparent 26%),
    linear-gradient(160deg, #101015 0%, #17171d 46%, #111115 100%);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(86px + env(safe-area-inset-bottom));
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 2px 12px;
}

.topbar h1,
.modal-panel h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 11px;
  color: var(--mint);
  text-transform: uppercase;
  letter-spacing: 0;
}

.main {
  display: grid;
  gap: 14px;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 170px;
  padding: 20px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 92, 122, .95), rgba(199, 125, 255, .78) 48%, rgba(85, 214, 190, .8)),
    #222;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
}

.hero::after {
  content: "";
  position: absolute;
  right: -44px;
  bottom: -46px;
  width: 172px;
  height: 172px;
  border: 18px solid rgba(255, 255, 255, .23);
  transform: rotate(18deg);
}

.hero h2 {
  position: relative;
  z-index: 1;
  width: 78%;
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.hero p {
  position: relative;
  z-index: 1;
  max-width: 310px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, .88);
  line-height: 1.55;
}

.panel,
.game-card,
.prompt-card,
.qr-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 27, 34, .88);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
}

.panel {
  padding: 14px;
}

.action-panel {
  border-color: rgba(255, 209, 102, .5);
  background: rgba(255, 209, 102, .08);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111116;
  color: var(--text);
  outline: none;
}

.textarea {
  min-height: 92px;
  padding-top: 12px;
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.secondary,
.ghost,
.danger,
.icon-btn {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: linear-gradient(135deg, var(--hot), #f8961e);
  color: white;
}

.secondary {
  background: var(--mint);
  color: #071816;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
}

.danger {
  background: rgba(243, 114, 91, .18);
  color: #ffb5a7;
}

.full {
  width: 100%;
}

.icon-btn {
  width: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
}

.stats,
.category-grid,
.quick-grid,
.player-grid,
.score-grid {
  display: grid;
  gap: 10px;
}

.stats {
  grid-template-columns: repeat(3, 1fr);
}

.stat {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
}

.stat strong {
  display: block;
  font-size: 20px;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
}

.quick-grid {
  grid-template-columns: repeat(2, 1fr);
}

.quick-game {
  min-height: 74px;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
}

.quick-game.active {
  border-color: rgba(85, 214, 190, .75);
  background: rgba(85, 214, 190, .12);
}

.quick-game b,
.quick-game span {
  display: block;
}

.quick-game span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .08);
  color: var(--muted);
}

.category-tabs button.active {
  background: var(--sun);
  color: #241900;
  font-weight: 800;
}

.game-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.game-card {
  padding: 14px;
  text-align: left;
}

.game-card.active {
  border-color: rgba(255, 209, 102, .75);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, .14);
}

.ended-banner {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ffe3a1;
  background: rgba(255, 209, 102, .12);
  border: 1px solid rgba(255, 209, 102, .22);
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 0 8px;
  background: rgba(255, 255, 255, .08);
  color: var(--muted);
  font-size: 12px;
}

.tag.hot {
  background: rgba(255, 92, 122, .16);
  color: #ff9caf;
}

.game-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.room-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #0f0f14;
}

.room-code strong {
  font-size: 30px;
  letter-spacing: 0;
}

.qr-box {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.qr-box img {
  width: 116px;
  height: 116px;
  border-radius: 8px;
  background: white;
  padding: 6px;
}

.player-grid {
  grid-template-columns: repeat(2, 1fr);
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #111;
  font-weight: 900;
}

.player b {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player small {
  color: var(--muted);
}

.prompt-card {
  position: relative;
  overflow: hidden;
  min-height: 230px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  background:
    linear-gradient(145deg, rgba(36, 36, 45, .96), rgba(17, 17, 21, .96)),
    #1b1b22;
}

.prompt-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 8px;
  pointer-events: none;
}

.prompt-card h2 {
  position: relative;
  margin: 0 0 12px;
  font-size: 22px;
}

.prompt-card p {
  position: relative;
  margin: 0;
  color: #efedf8;
  font-size: 17px;
  line-height: 1.65;
}

.prompt-card .challenge {
  position: relative;
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 209, 102, .1);
  color: #ffe3a1;
  font-size: 14px;
}

.timer-face {
  width: 178px;
  height: 178px;
  margin: 8px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--hot), var(--sun), var(--mint), var(--sky), var(--hot)),
    #222;
  box-shadow: inset 0 0 0 12px rgba(0, 0, 0, .32), 0 20px 38px rgba(0, 0, 0, .28);
}

.timer-face strong {
  width: 122px;
  height: 122px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  font-size: 42px;
}

.card-face {
  width: 148px;
  height: 198px;
  margin: 8px auto 14px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, #f1efe6);
  color: #16161b;
  font-size: 42px;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.dice-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 14px;
}

.dice-row span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f7f5ee;
  color: #111115;
  font-size: 28px;
  font-weight: 900;
}

.wheel-face {
  width: 188px;
  height: 188px;
  margin: 8px auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--hot) 0 20%, var(--sun) 20% 40%, var(--mint) 40% 60%, var(--sky) 60% 80%, var(--violet) 80% 100%);
  transition: transform .8s cubic-bezier(.2, .8, .2, 1);
  box-shadow: inset 0 0 0 12px rgba(0, 0, 0, .24), 0 18px 38px rgba(0, 0, 0, .26);
}

.wheel-face strong {
  width: 104px;
  min-height: 64px;
  padding: 8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  text-align: center;
  background: rgba(17, 17, 21, .88);
}

.reaction-target {
  min-height: 88px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  color: var(--sun);
  font-size: 24px;
  font-weight: 900;
}

.vote-list {
  display: grid;
  gap: 8px;
}

.vote-btn,
.score-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, .06);
}

.vote-btn {
  grid-template-columns: 1fr auto;
  text-align: left;
}

.vote-btn em {
  font-style: normal;
  color: var(--sun);
}

.score-grid {
  grid-template-columns: 1fr;
}

.mini {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .09);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  transform: translateX(-50%);
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(14, 14, 18, .88);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

.bottom-nav button {
  min-height: 44px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.bottom-nav button.active {
  background: rgba(255, 255, 255, .1);
  color: var(--text);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 30;
  transform: translate(-50%, 20px);
  width: min(calc(100% - 28px), 492px);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .84);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .72);
}

.modal[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(100%, 430px);
  padding: 20px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.modal-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.empty {
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 460px) {
  .game-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 360px) {
  .hero h2 {
    width: 86%;
    font-size: 26px;
  }

  .stats,
  .row,
  .quick-grid,
  .player-grid {
    grid-template-columns: 1fr;
  }

  .qr-box {
    grid-template-columns: 1fr;
  }
}
