/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #2c2c3a;
  background: linear-gradient(160deg, #aee3f5 0%, #d9f2e4 50%, #fdf3d8 100%);
  user-select: none;
}
input, button { font-family: inherit; }
input { user-select: text; }
.hint { color: #8a8a98; font-size: 13px; }
.hidden { display: none !important; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; align-items: center; justify-content: center; }
#screen-island.active { display: block; }

/* ============ 按钮 ============ */
.btn {
  border: none; border-radius: 12px; padding: 10px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #ff9f43, #ff6b81); color: #fff; box-shadow: 0 4px 12px rgba(255, 130, 90, .35); }
.btn-soft { background: #4aa3cf; color: #fff; box-shadow: 0 4px 10px rgba(74, 163, 207, .3); }
.btn-ghost { background: rgba(255, 255, 255, .75); color: #5a6b7c; border: 1.5px solid #d5e2ea; }
.btn-small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-buy { background: linear-gradient(135deg, #f4c542, #f59e0b); color: #6b4a00; }
.btn.big { padding: 14px 22px; font-size: 17px; }

/* ============ 登录 ============ */
.login-card {
  background: rgba(255, 255, 255, .92); border-radius: 24px; padding: 40px 44px;
  box-shadow: 0 16px 40px rgba(60, 100, 140, .18);
  display: flex; flex-direction: column; gap: 16px; width: min(92vw, 380px); text-align: center;
}
.login-card h1 { font-size: 34px; }
.login-card input {
  border: 2px solid #d5e2ea; border-radius: 12px; padding: 12px 16px; font-size: 16px; outline: none;
}
.login-card input:focus { border-color: #4aa3cf; }

/* ============ 捏人 ============ */
.creator-full { width: min(96vw, 860px); }
.creator-title { text-align: center; margin-bottom: 12px; }
.creator {
  display: flex; gap: 20px; background: rgba(255, 255, 255, .92);
  border-radius: 24px; padding: 24px; box-shadow: 0 16px 40px rgba(60, 100, 140, .18);
}
.creator-stage { flex: 0 0 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(180deg, #dff2fb, #f9fbe7); border-radius: 18px; padding: 14px; }
.creator-preview svg { overflow: visible; }
.creator-label { font-weight: 700; color: #4a5f7a; }
.creator-panel { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.creator-tabs { display: flex; gap: 8px; }
.creator-tabs button {
  border: none; background: #eef3f7; color: #6a7a8a; border-radius: 10px 10px 0 0;
  padding: 9px 20px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.creator-tabs button.active { background: #4aa3cf; color: #fff; }
.creator-body { flex: 1; overflow-y: auto; max-height: 380px; padding: 4px 2px; }
.style-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.style-tabs button {
  border: 2px solid #d5e2ea; background: #fff; border-radius: 999px; padding: 7px 18px;
  font-size: 15px; font-weight: 700; color: #6a7a8a; cursor: pointer;
}
.style-tabs button.active { border-color: #ff6b81; background: #fff0f3; color: #e8568a; }
.preset-grid { display: flex; gap: 12px; margin-bottom: 14px; }
.preset-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2.5px solid #e2eaf0; background: #f8fbfd; border-radius: 16px; padding: 10px 14px;
  cursor: pointer; font-weight: 700; color: #4a5f7a;
}
.preset-card.active { border-color: #4aa3cf; background: #e8f6fc; }
.skin-title { font-weight: 700; margin-bottom: 8px; }
.skin-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.skin-swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
}
.skin-swatch.active { border-color: #ff6b81; box-shadow: 0 2px 8px rgba(255, 107, 129, .4); }
.skin-custom { background: #fff; border: 2px dashed #b9c8d4; position: relative; overflow: hidden; }
.skin-custom input { position: absolute; inset: -8px; opacity: 0; cursor: pointer; }
.creator-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.creator-ok { min-width: 110px; }
.wear-section { margin-bottom: 12px; }
.wear-title { font-weight: 700; color: #4a5f7a; margin-bottom: 6px; }
.wear-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.wear-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 108px;
  border: 2px solid #e2eaf0; border-radius: 14px; padding: 8px 6px; background: #f8fbfd; font-size: 12px;
}
.wear-card.worn { border-color: #4aa3cf; background: #e8f6fc; }

/* ============ 主菜单 ============ */
.home-card {
  display: flex; gap: 34px; align-items: center;
  background: rgba(255, 255, 255, .92); border-radius: 28px; padding: 36px 44px;
  box-shadow: 0 16px 40px rgba(60, 100, 140, .18); max-width: 92vw;
}
.home-left { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.home-name { font-size: 20px; font-weight: 800; }
.home-coins { font-size: 17px; font-weight: 700; color: #d99a06; }
.home-right { display: flex; flex-direction: column; gap: 14px; max-width: 320px; }
.home-right h1 { font-size: 32px; }
.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1; border: 2px solid #d5e2ea; border-radius: 12px; padding: 12px 16px;
  font-size: 17px; letter-spacing: 4px; text-align: center; outline: none; min-width: 0;
}
.join-row input:focus { border-color: #4aa3cf; }

/* ============ 岛屿 ============ */
#island-host { position: fixed; inset: 0; }
.island-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
}
.island-topbar .topbar-space { flex: 1; }
.island-code { font-weight: 800; letter-spacing: 1px; }
.island-count { font-size: 14px; font-weight: 700; color: #4a5f7a; }
.island-coins { font-weight: 800; color: #d99a06; background: rgba(255,255,255,.8); padding: 6px 12px; border-radius: 999px; }
.island-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.island-world { width: 1200px; height: 700px; position: relative; flex: none; transform-origin: center; }
.island-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.island-players { position: absolute; inset: 0; }

.island-bg g.poi { cursor: pointer; }
.island-bg g.poi:hover { filter: brightness(1.08); }

.player { position: absolute; width: 84px; text-align: center; transition: transform .12s linear; will-change: transform; }
.player.is-self { transition: none; }
.player.is-self .p-avatar { filter: drop-shadow(0 0 6px rgba(74, 163, 207, .9)); }
.player.disconnected { opacity: .35; filter: grayscale(1); }
.player .p-avatar { position: relative; }
.player .p-avatar.flip svg { transform: scaleX(-1); }
.player .p-avatar svg { display: block; overflow: visible; }
.player .p-name {
  font-size: 12px; font-weight: 800; color: #31465c;
  background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 2px 8px;
  display: inline-block; margin-top: -4px; white-space: nowrap;
}
.bubble {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) scale(.6);
  background: #fff; border-radius: 12px; padding: 5px 10px; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 10px rgba(50, 80, 110, .2); opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s; white-space: nowrap; z-index: 5;
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.bubble.emote { background: none; box-shadow: none; font-size: 34px; }

.poi-prompt {
  position: absolute; transform: translate(-50%, -100%); z-index: 40; pointer-events: none;
  background: rgba(30, 40, 55, .82); color: #fff; border-radius: 999px; padding: 7px 16px;
  font-size: 14px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}
.poi-prompt b { color: #ffd36b; }

.chat-log {
  position: fixed; left: 14px; bottom: 96px; z-index: 50; max-width: 320px;
  display: flex; flex-direction: column; gap: 5px; pointer-events: none;
}
.chat-line {
  background: rgba(255, 255, 255, .85); border-radius: 10px; padding: 5px 10px;
  font-size: 13px; width: fit-content; max-width: 100%;
}
.chat-bar { position: fixed; left: 14px; bottom: 14px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.chat-input {
  width: min(78vw, 340px); border: none; border-radius: 999px; padding: 11px 18px;
  font-size: 14px; outline: none; box-shadow: 0 4px 14px rgba(50, 80, 110, .18);
}
.emote-bar { display: flex; gap: 6px; }
.emote-bar button {
  border: none; background: rgba(255, 255, 255, .85); border-radius: 12px;
  font-size: 20px; width: 40px; height: 40px; cursor: pointer; transition: transform .1s;
}
.emote-bar button:hover { transform: scale(1.15); }

.dpad { position: fixed; right: 20px; bottom: 90px; z-index: 50; display: grid;
  grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 6px; }
.dpad button {
  border: none; border-radius: 14px; background: rgba(255, 255, 255, .8); font-size: 20px;
  color: #4a5f7a; touch-action: none;
}
.dpad .d-up { grid-column: 2; }
.dpad .d-left { grid-column: 1; grid-row: 2; }
.dpad .d-down { grid-column: 2; grid-row: 2; }
.dpad .d-right { grid-column: 3; grid-row: 2; }
.act-btn {
  position: fixed; right: 28px; bottom: 20px; z-index: 50; width: 64px; height: 64px;
  border-radius: 50%; border: none; background: #ff6b81; color: #fff;
  font-size: 24px; font-weight: 800; box-shadow: 0 6px 16px rgba(255, 107, 129, .4);
}

/* ============ 弹窗 ============ */
.layer { position: fixed; inset: 0; z-index: 80; }
.modal-layer { background: rgba(20, 35, 50, .45); display: flex; align-items: center; justify-content: center; }
.modal {
  background: #fff; border-radius: 22px; width: min(94vw, 660px); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; font-size: 18px; font-weight: 800; border-bottom: 2px solid #eef3f7;
}
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: #8a8a98; padding: 4px 8px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

/* ============ 商店 ============ */
.shop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.shop-title { font-weight: 800; font-size: 16px; }
.shop-coins { font-weight: 800; color: #d99a06; font-size: 17px; }
.shop-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.shop-tabs button {
  border: 2px solid #d5e2ea; background: #fff; border-radius: 999px; padding: 6px 16px;
  font-weight: 700; color: #6a7a8a; cursor: pointer;
}
.shop-tabs button.active { border-color: #4aa3cf; background: #e8f6fc; color: #2b7fb0; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.shop-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 2px solid #e2eaf0; border-radius: 16px; padding: 10px 8px; background: #f8fbfd;
}
.shop-card.worn { border-color: #4aa3cf; background: #e8f6fc; }
.shop-name { font-size: 13px; font-weight: 700; }
.tag-abstract {
  position: absolute; top: 6px; right: 6px; font-size: 10px; font-style: normal;
  background: #7a4be0; color: #fff; border-radius: 999px; padding: 2px 8px; font-weight: 700;
}
.shop-foot { margin-top: 12px; text-align: center; }

/* ============ 任务 ============ */
.tasks { display: flex; flex-direction: column; gap: 12px; }
.task-card { border: 2px solid #e2eaf0; border-radius: 16px; padding: 12px 14px; background: #f8fbfd; }
.task-card.claimed { opacity: .6; }
.task-line { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 8px; }
.task-bar { height: 10px; border-radius: 999px; background: #e2eaf0; overflow: hidden; }
.task-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4aa3cf, #6bd48f); transition: width .3s; }
.task-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.task-done { color: #3f9b4f; font-weight: 700; }

/* ============ 游戏选择 ============ */
.arcade { display: flex; flex-direction: column; gap: 12px; }
.arcade-card {
  display: flex; align-items: center; gap: 14px; border: 2px solid #e2eaf0;
  border-radius: 16px; padding: 14px 16px; background: #f8fbfd;
}
.arcade-card b { font-size: 17px; }
.arcade-card .hint { flex: 1; }
.arcade > .hint { text-align: center; }

/* ============ 小游戏通用 ============ */
#game-layer { background: rgba(24, 34, 48, .55); display: flex; align-items: center; justify-content: center; }
.game {
  background: rgba(255, 255, 255, .96); border-radius: 24px; padding: 22px 26px;
  width: min(94vw, 720px); max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.game-head { display: flex; align-items: center; gap: 14px; }
.game-name { font-size: 18px; font-weight: 800; }

/* 快问快答 */
.timer-bar { flex: 1; height: 12px; border-radius: 999px; background: #e2eaf0; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #6bd48f, #f4c542, #e8564a); }
.quiz-progress { font-weight: 800; color: #4a5f7a; white-space: nowrap; }
.quiz-q { font-size: 21px; font-weight: 800; text-align: center; padding: 6px 0; min-height: 34px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt {
  border: 2.5px solid #d5e2ea; background: #fff; border-radius: 14px; padding: 13px 14px;
  font-size: 15px; cursor: pointer; text-align: left; transition: border-color .12s, background .12s;
}
.quiz-opt b { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center;
  background: #eef3f7; border-radius: 50%; margin-right: 8px; font-size: 13px; }
.quiz-opt:hover { border-color: #4aa3cf; }
.quiz-opt.picked { border-color: #f4c542; background: #fffbe8; }
.quiz-opt.right { border-color: #6bd48f; background: #ecfaf0; }
.quiz-opt.wrong { border-color: #f0b6b2; background: #fdf3f2; opacity: .7; }
.quiz-scores { display: flex; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.score-chip { background: #eef3f7; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.score-chip.me { background: #e8f6fc; color: #2b7fb0; }
.score-chip.win { background: #ecfaf0; color: #2c8a4a; }
.score-chip.lose { background: #fdf3f2; color: #b04a42; }

/* 金币雨 */
.coins { width: min(96vw, 900px); }
.coins-score { font-weight: 800; color: #d99a06; }
.coins-timer { font-weight: 800; color: #4a5f7a; margin-left: auto; }
.coins-stage-wrap { display: flex; justify-content: center; }
.coins-stage {
  position: relative; width: 100%; aspect-ratio: 1200 / 700; border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, #ffd9a0 0%, #ffb37b 55%, #8fd3f0 100%);
  border: 3px solid #e8b06a;
}
.coin-item { position: absolute; top: 0; font-size: 30px; transform: translate(-50%, -30px); text-shadow: 0 2px 4px rgba(0,0,0,.2); }
.coins-player { position: absolute; }
.coins-player svg { overflow: visible; }
.coins-cover {
  position: absolute; inset: 0; background: rgba(24, 34, 48, .55);
  display: flex; align-items: center; justify-content: center;
}
.coins-cover-text { color: #fff; font-size: 24px; font-weight: 800; }
.coins-controls { display: none; justify-content: center; gap: 18px; }
.coins-controls.show { display: flex; }
.coins-controls .btn { width: 64px; height: 48px; font-size: 20px; touch-action: none; }

/* 反应挑战 */
.react-round { font-weight: 800; color: #4a5f7a; }
.react-light {
  border-radius: 18px; padding: 44px 20px; text-align: center; transition: background .12s;
  border: 3px solid #e2eaf0;
}
.react-light.ready { background: #eef3f7; }
.react-light.wait { background: #fde3e0; border-color: #e8564a; }
.react-light.go { background: #dcf7e5; border-color: #2c8a4a; }
.react-light.result { background: #e8f6fc; border-color: #4aa3cf; }
.react-msg { font-size: 28px; font-weight: 800; min-height: 40px; }
.react-btn {
  align-self: center; width: 130px; height: 130px; border-radius: 50%;
  border: none; background: linear-gradient(135deg, #ff9f43, #ff6b81); color: #fff;
  font-size: 30px; font-weight: 800; cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 130, 90, .45); transition: transform .08s;
}
.react-btn:active { transform: scale(.93); }
.react-status { text-align: center; min-height: 20px; font-weight: 700; }
.react-wins { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 26px; }

/* ============ 结算 ============ */
#results-layer { background: rgba(24, 34, 48, .6); display: flex; align-items: center; justify-content: center; }
.results {
  background: #fff; border-radius: 24px; padding: 26px 30px; width: min(92vw, 460px);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: pop .25s;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.results h2 { font-size: 24px; }
.results-list { display: flex; flex-direction: column; gap: 8px; }
.result-line {
  display: flex; align-items: center; gap: 10px; border: 2px solid #eef3f7;
  border-radius: 14px; padding: 9px 14px; font-weight: 700;
}
.result-line.me { border-color: #4aa3cf; background: #e8f6fc; }
.r-medal { font-size: 20px; }
.r-name { flex: 1; text-align: left; }
.r-coins { color: #d99a06; }
.results-hint { text-align: center; }

/* ============ Toast ============ */
#toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-16px);
  background: rgba(30, 40, 55, .88); color: #fff; border-radius: 999px; padding: 10px 22px;
  font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity .2s, transform .2s; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 移动端 ============ */
@media (max-width: 760px) {
  .creator { flex-direction: column; padding: 16px; gap: 12px; }
  .creator-stage { flex: none; flex-direction: row; padding: 10px; }
  .creator-body { max-height: 300px; }
  .home-card { flex-direction: column; gap: 16px; padding: 24px; }
  .home-right { max-width: none; width: 100%; }
  .quiz-options { grid-template-columns: 1fr; }
  .chat-log { bottom: 130px; }
  .island-topbar { flex-wrap: wrap; gap: 6px; padding: 8px; }
  .game { padding: 16px; }
}
