:root {
  --bg: #f3f3f5;
  --card: #ffffff;
  --ink: #1c1c1e;
  --muted: #8a8a92;
  --line: #e8e8ec;
  --accent: #ff9a66;
  --accent-deep: #ff7f45;
  --accent-soft: #fff0e6;
  --mint: #7fd8a4;
  --sky: #7cc4ff;
  --lemon: #ffd166;
  --danger: #e5484d;
  --black: #1c1c1e;
  --radius: 20px;
  --shadow: 0 2px 14px rgba(28, 28, 30, 0.07);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  min-height: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  transition: background 0.4s ease;
}

body.has-wallpaper {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.hidden { display: none !important; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffab75, #ff8f56);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  box-shadow: 0 4px 14px rgba(255, 138, 80, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(255, 138, 80, 0.2);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.secondary {
  background: var(--black);
  color: #fff;
  box-shadow: 0 3px 10px rgba(28, 28, 30, 0.18);
}

.btn.secondary:active {
  box-shadow: 0 1px 5px rgba(28, 28, 30, 0.12);
}

.btn.danger {
  background: var(--danger);
  box-shadow: 0 4px 14px rgba(229, 72, 77, 0.25);
}

.btn.small {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  margin-top: 0;
  border-radius: 10px;
  box-shadow: none;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(28, 28, 30, 0.05);
}

body.has-wallpaper .card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.title {
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  margin: 22px 0 6px;
  letter-spacing: 2px;
  color: var(--black);
}

.title .dot {
  color: var(--accent-deep);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 22px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 13px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fafafc;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--accent);
  background: #fff;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(28, 28, 30, 0.12);
  flex: none;
}

.avatar.small {
  width: 46px;
  height: 46px;
}

.avatar.editable {
  cursor: pointer;
}

.avatar.emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  border: 2px solid #fff;
}

.avatar.small.emoji {
  font-size: 22px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.player-card {
  background: #fafafc;
  border-radius: 16px;
  padding: 10px 6px;
  text-align: center;
  position: relative;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.2s;
}

.player-card .name {
  font-size: 13px;
  margin-top: 6px;
  word-break: break-all;
  line-height: 1.3;
  color: var(--ink);
}

.player-card.offline {
  opacity: 0.55;
  border-style: dashed;
  border-color: var(--line);
}

.player-card.dead {
  filter: grayscale(1);
  opacity: 0.5;
}

.player-card .badge {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--black);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(28, 28, 30, 0.25);
}

.player-card.votable {
  cursor: pointer;
}

.player-card.votable.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: pop 0.28s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.code-big {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 10px;
  text-align: center;
  margin: 6px 0;
  color: var(--black);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}

.link-row {
  background: #fafafc;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  word-break: break-all;
  margin-top: 8px;
  text-align: center;
  color: var(--ink);
}

.phase-banner {
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: #6b3413;
  font-weight: 700;
  margin-bottom: 12px;
  border: 1px solid #ffd9bd;
}

.word-box {
  background: linear-gradient(135deg, #fff6ef, #ffeadd);
  border: 1.5px solid #ffd4b5;
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  margin: 14px 0;
  position: relative;
}

.word-box.deal {
  animation: flipIn 0.55s ease;
}

@keyframes flipIn {
  0% { transform: perspective(500px) rotateY(90deg); opacity: 0; }
  100% { transform: perspective(500px) rotateY(0); opacity: 1; }
}

.word-box .word {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 5px;
  color: var(--black);
}

.word-box .label {
  font-size: 13px;
  font-weight: 600;
  color: #b06a38;
  margin-bottom: 10px;
}

.ring-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 12px auto 4px;
}

.ring {
  width: 92px;
  height: 92px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: #ffe3cd;
  stroke-width: 7;
}

.ring-fg {
  fill: none;
  stroke: var(--accent-deep);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}

.ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-text .num {
  font-size: 26px;
  font-weight: 900;
  color: var(--black);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ring-text .unit {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.v-bar {
  margin: 8px 0;
}

.v-bar .top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.v-bar .track {
  height: 9px;
  background: #f0f0f3;
  border-radius: 5px;
  overflow: hidden;
}

.v-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb37a, #ff8f56);
  border-radius: 5px;
  transition: width 0.35s ease;
}

.winner-box {
  text-align: center;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--black);
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(28, 28, 30, 0.22);
}

.winner-box .w {
  font-size: 28px;
  font-weight: 900;
  color: var(--lemon);
}

.winner-box .small {
  color: rgba(255, 255, 255, 0.65);
}

.reveal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fafafc;
  border-radius: 14px;
  padding: 8px 12px;
  margin-top: 8px;
  animation: fadeUp 0.4s ease both;
}

.reveal-row:nth-child(2) { animation-delay: 0.08s; }
.reveal-row:nth-child(3) { animation-delay: 0.16s; }
.reveal-row:nth-child(4) { animation-delay: 0.24s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal-row .info {
  font-size: 14px;
  line-height: 1.5;
}

.role-tag {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: #0d3b22;
  font-weight: 800;
  margin-left: 6px;
}

.role-tag.undercover {
  background: var(--danger);
  color: #fff;
}

.role-tag.blank {
  background: #cfcfd6;
  color: #333;
}

.seg {
  display: flex;
  gap: 8px;
}

.seg .opt {
  flex: 1;
  text-align: center;
  padding: 11px 4px;
  border-radius: 13px;
  background: #f4f4f6;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.seg .opt.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #7a3c14;
  font-weight: 700;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 12px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fafafc;
  border-radius: 12px;
  padding: 9px 12px;
  margin-top: 8px;
  font-size: 14px;
}

.wp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.wp-swatch {
  height: 52px;
  border-radius: 12px;
  border: 2.5px solid transparent;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 10px;
  color: rgba(28, 28, 30, 0.75);
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(28, 28, 30, 0.08);
  transition: transform 0.12s ease, border-color 0.12s ease;
  background-size: cover;
  background-position: center;
}

.wp-swatch:active {
  transform: scale(0.95);
}

.wp-swatch.on {
  border-color: var(--accent-deep);
  transform: scale(1.03);
}

.wp-swatch .wp-name {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  padding: 1px 6px;
}

.wp-preview {
  width: 100%;
  height: 90px;
  border-radius: 12px;
  margin-top: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}

#toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: var(--black);
  color: #fff;
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 99;
  max-width: 88vw;
  text-align: center;
  box-shadow: 0 6px 20px rgba(28, 28, 30, 0.25);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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