/* 数学大富翁·中国行 —— 卡通扁平风格 */
:root {
  --bg: #eef7ff;
  --card: #ffffff;
  --ink: #2c3e50;
  --ink-soft: #7f8c9b;
  --primary: #ff7043;
  --primary-dark: #f4511e;
  --good: #43a047;
  --bad: #e53935;
  --line: #dce8f2;
  --radius: 14px;
  --shadow: 0 4px 14px rgba(44, 62, 80, .12);
}

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

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(160deg, #d9f0ff 0%, #eef7ff 45%, #fff3e6 100%);
  color: var(--ink);
  overflow-x: hidden;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, .tile, select, input { touch-action: manipulation; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; border: 2px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; color: var(--ink); }

.btn {
  border: none; border-radius: 12px; padding: 9px 16px; font-size: 15px; font-weight: 600;
  background: #fff; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.btn:not(:disabled):hover { transform: translateY(-2px); }
.btn:not(:disabled):active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn.big { font-size: 18px; padding: 13px 26px; }
.btn.mini { font-size: 12px; padding: 4px 9px; border-radius: 8px; box-shadow: 0 2px 6px rgba(44,62,80,.12); }

/* ============ 主菜单 ============ */
#menu { display: flex; justify-content: center; padding: 20px 12px 48px; min-height: 100%; }
.menu-card { width: 100%; max-width: 560px; }
.title { text-align: center; font-size: clamp(30px, 6vw, 44px); margin-top: 12px; letter-spacing: 2px; }
.title-sub {
  background: linear-gradient(135deg, #ff7043, #ffb300); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; font-size: .8em;
}
.subtitle { text-align: center; color: var(--ink-soft); margin: 6px 0 18px; }

.menu-sec { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.sec-title { font-weight: 700; margin-bottom: 10px; font-size: 15px; }

.p-head, .p-row { display: grid; grid-template-columns: 92px 1fr 92px 76px; gap: 8px; align-items: center; margin-bottom: 7px; }
.p-head { color: var(--ink-soft); font-size: 12px; margin-bottom: 4px; }
.p-row input, .p-row select { width: 100%; }

.radio { display: block; padding: 7px 4px; font-size: 14px; }
.radio select { margin: 0 4px; }

#btn-start { display: block; width: 100%; margin: 4px 0 14px; }

.net-sec .net-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; flex-wrap: wrap; }
#net-addr { width: 170px; }
#net-room { width: 90px; text-align: center; letter-spacing: 3px; }

.menu-foot { display: flex; gap: 10px; justify-content: center; }

/* ============ 游戏画面 ============ */
#game { display: flex; gap: 14px; padding: 12px; max-width: 1500px; margin: 0 auto; align-items: flex-start; justify-content: center; }

#board-wrap {
  position: relative; flex: 0 0 auto;
  width: min(68vw, 94vh, 1040px); height: min(68vw, 94vh, 1040px);
}

#board {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr);
  gap: 2px; background: #cfe3f5; border-radius: 16px; padding: 3px;
  box-shadow: var(--shadow);
}

.tile {
  position: relative; background: var(--card); border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; cursor: pointer; transition: transform .15s;
  user-select: none;
}
.tile:hover { transform: scale(1.06); z-index: 5; }
.t-start { background: #fff59d; }
.t-jail { background: #eceff1; }
.t-park { background: #dcedc8; }
.t-gojail { background: #ffcdd2; }
.t-chance { background: #fff3e0; }
.t-fate { background: #ede7f6; }
.t-math { background: #e0f7fa; }
.t-shop { background: #fce4ec; }
.t-tax { background: #f5f5f5; }

.tl-bar { position: absolute; top: 0; left: 0; right: 0; height: 22%; }
.edge-side .tl-bar { top: 0; bottom: 0; left: 0; right: auto; width: 16%; height: 100%; }
.tl-emoji { font-size: clamp(11px, 2.8vmin, 30px); line-height: 1.1; z-index: 1; }
.tl-name { font-size: clamp(7px, 1.6vmin, 16px); font-weight: 600; z-index: 1; white-space: nowrap; transform-origin: center; }
.tl-tag { font-size: clamp(7px, 1.4vmin, 14px); color: var(--ink-soft); z-index: 1; }
.tl-tag.owned { font-size: clamp(9px, 1.9vmin, 18px); }
.tl-houses { position: absolute; bottom: 1px; font-size: clamp(6px, 1.4vmin, 14px); z-index: 1; letter-spacing: -2px; }
.tl-mark { position: absolute; top: 1px; right: 2px; font-size: clamp(8px, 1.9vmin, 17px); z-index: 2; }
.tile.mortgaged { filter: grayscale(.9); opacity: .68; }
.tile.selectable { outline: 3px dashed var(--primary); outline-offset: -2px; animation: pulse 0.9s infinite alternate; z-index: 6; }
.tile.dimmed { opacity: .35; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* 棋子 */
#tokens { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.token {
  position: absolute; width: 5.5%; height: 5.5%;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: clamp(10px, 2.4vmin, 20px);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  transform: translate(-50%, -50%);
  transition: left .18s ease, top .18s ease;
}
.token.no-anim { transition: none; }

/* 中央面板 */
#center-panel {
  position: absolute; left: 11%; top: 11%; width: 78%; height: 78%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(4px, 1.2vmin, 12px); text-align: center; padding: 2%;
  z-index: 10;
}
.c-top { display: flex; gap: 10px; font-size: clamp(10px, 1.8vmin, 14px); color: var(--ink-soft); font-weight: 600; flex-wrap: wrap; justify-content: center; }
.c-infl { color: var(--bad); }
.c-pot { color: var(--good); }
.c-banner {
  font-size: clamp(14px, 2.6vmin, 22px); font-weight: 800;
  background: var(--card); border-radius: 999px; padding: 6px 18px;
  box-shadow: var(--shadow); border: 3px solid var(--pc, var(--primary));
}
.dice-box { display: flex; gap: 6px; min-height: clamp(30px, 6vmin, 52px); align-items: center; }
.die { font-size: clamp(30px, 6vmin, 52px); line-height: 1; }
.die.dim { opacity: .4; }
.c-hint { font-size: clamp(11px, 2vmin, 16px); background: rgba(255,255,255,.92); border-radius: 10px; padding: 6px 12px; box-shadow: var(--shadow); max-width: 95%; }
.c-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.c-actions .btn { font-size: clamp(11px, 2vmin, 16px); }
.c-wait { color: var(--ink-soft); font-size: clamp(11px, 2vmin, 15px); }

/* 右侧栏 */
#side { flex: 1 1 260px; min-width: 240px; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }

#players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pl-card {
  background: var(--card); border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow);
  border-left: 5px solid var(--pc); font-size: 13px; transition: transform .2s;
}
.pl-card.active { transform: scale(1.04); box-shadow: 0 0 0 3px var(--pc), var(--shadow); }
.pl-card.dead { opacity: .45; filter: grayscale(1); }
.pl-head { display: flex; align-items: center; gap: 5px; }
.pl-avatar { font-size: 18px; }
.pl-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pl-grade { font-size: 10px; color: var(--ink-soft); background: var(--bg); padding: 1px 5px; border-radius: 6px; }
.pl-money { font-size: 17px; font-weight: 800; color: var(--good); margin-top: 2px; }
.pl-worth { font-size: 11px; color: var(--ink-soft); }
.pl-badges span { font-size: 10px; background: #fff3e0; border-radius: 6px; padding: 1px 4px; margin-right: 3px; }
.pl-items { margin-top: 4px; min-height: 20px; }
.no-items { font-size: 10px; color: var(--ink-soft); }
.item-chip { font-size: 16px; margin-right: 4px; opacity: .55; }
.item-chip.usable { opacity: 1; cursor: pointer; filter: drop-shadow(0 0 4px rgba(255,112,67,.8)); }
.item-chip.usable:hover { transform: scale(1.25); display: inline-block; }

#log {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 8px 10px; height: 220px; overflow-y: auto; font-size: 12px; line-height: 1.7;
}
.log-line { border-bottom: 1px dashed var(--line); padding: 1px 0; }

/* ============ 浮层 ============ */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: var(--card); border-radius: 999px; padding: 7px 18px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); animation: toast-in .25s ease; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.good { border: 2px solid var(--good); }
.toast.bad { border: 2px solid var(--bad); }
.toast.info { border: 2px solid #90caf9; }
.toast.out { opacity: 0; transition: opacity .45s; }
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } }

.overlay-root { position: fixed; inset: 0; z-index: 200; }
.overlay-root:not(.hidden) { display: flex; align-items: center; justify-content: center; background: rgba(30, 45, 60, .45); }
#quiz-root:not(.hidden) { z-index: 220; }
.modal-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(30,45,60,.45); }
.modal-overlay.no-dim { background: transparent; pointer-events: none; }

.modal-card {
  background: var(--card); border-radius: 18px; box-shadow: 0 12px 40px rgba(20,35,50,.3);
  padding: 20px 22px; max-width: min(480px, 94vw); max-height: 86vh; overflow-y: auto;
  animation: pop-in .28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } }

/* 答题 */
.quiz-card { width: min(460px, 94vw); text-align: center; }
.quiz-ctx { font-size: 14px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.quiz-who { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.quiz-text { font-size: clamp(20px, 4.6vw, 28px); font-weight: 800; margin: 10px 0 14px; line-height: 1.4; }
.timer-wrap { position: relative; height: 12px; background: var(--bg); border-radius: 999px; margin-bottom: 14px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #66bb6a, #9ccc65); border-radius: 999px; transition: width .2s linear; }
.timer-bar.urgent { background: linear-gradient(90deg, #ef5350, #ff7043); }
.timer-txt { position: absolute; right: 8px; top: -2px; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt {
  border: 3px solid var(--line); border-radius: 14px; background: #fff;
  font-size: clamp(17px, 4vw, 22px); font-weight: 700; padding: 14px 8px;
  transition: all .12s;
}
.quiz-opt:not(:disabled):hover { border-color: var(--primary); background: #fff8f5; }
.quiz-opt.picked { border-color: var(--primary); background: #ffe0d3; }
.quiz-opt.removed { opacity: .25; text-decoration: line-through; }
.quiz-hint-note { margin-top: 10px; font-size: 12px; color: var(--good); }
.quiz-waiting { font-size: 16px; padding: 18px 6px; }
.handover-big { font-size: 56px; }
.handover-name { font-size: 18px; margin: 10px 0 16px; }
.rush-stat { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.rush-stat .combo { color: var(--primary-dark); }
.rush-stat .bonus { color: var(--good); }

/* 卡牌 */
.game-card { text-align: center; width: min(320px, 88vw); pointer-events: auto; }
.gc-deck { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.gc-emoji { font-size: 62px; margin: 12px 0; animation: card-wobble .6s ease; }
.gc-text { font-size: 17px; font-weight: 700; line-height: 1.5; }
@keyframes card-wobble { 0% { transform: rotate(-8deg) scale(.6); } 60% { transform: rotate(4deg) scale(1.1); } }

/* 选择器/资产/商店/信息 */
.chooser, .tile-info, .assets, .shop, .report { text-align: center; }
.ch-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.ch-opts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.ch-opt { font-size: 18px; }
.ti-head { font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.ti-row { font-size: 14px; margin-bottom: 7px; color: var(--ink); }
.ti-color { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.tile-info .btn { margin-top: 8px; }

.as-list { text-align: left; max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.as-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.as-acts { display: flex; gap: 5px; flex-wrap: wrap; }

.shop-list { text-align: left; max-height: 46vh; overflow-y: auto; margin: 12px 0; }
.shop-item { display: grid; grid-template-columns: 30px 66px 1fr 74px; align-items: center; gap: 7px; padding: 7px 2px; border-bottom: 1px dashed var(--line); }
.si-emoji { font-size: 20px; }
.si-name { font-size: 13px; font-weight: 700; }
.si-desc { font-size: 11px; color: var(--ink-soft); }
.discount { color: var(--bad); font-size: 13px; }
#shop-quiz { margin-bottom: 4px; }

/* 结算 */
.settle { width: min(440px, 94vw); text-align: center; }
.settle-title { font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.settle-reason { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.rank-list { margin-bottom: 16px; }
.rank-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 6px; align-items: center; padding: 8px 6px; border-bottom: 1px dashed var(--line); font-size: 14px; text-align: left; }
.rank-row .rk { font-size: 20px; }
.rank-row .rk-quiz { grid-column: 2 / 4; font-size: 11px; color: var(--ink-soft); }
.rank-row.champ { background: #fff8e1; border-radius: 10px; }

/* 学习报告 */
.report { width: min(460px, 94vw); }
.rp-list { text-align: left; max-height: 56vh; overflow-y: auto; margin-bottom: 12px; }
.rp-grade { font-weight: 800; margin: 10px 0 6px; }
.rp-row { display: grid; grid-template-columns: 110px 1fr 88px; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 5px; }
.rp-bar-wrap { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.rp-bar { display: block; height: 100%; background: linear-gradient(90deg, #66bb6a, #9ccc65); border-radius: 999px; }

/* 联机大厅 */
.lobby { width: min(420px, 94vw); text-align: center; }
.lobby-code { font-size: 34px; font-weight: 900; letter-spacing: 8px; color: var(--primary-dark); margin: 8px 0 2px; }
.lobby-tip { font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; }
.lobby-seats { text-align: left; margin-bottom: 14px; }
.seat-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px dashed var(--line); font-size: 15px; }
.seat-row .host-tag { font-size: 11px; background: #fff3e0; padding: 1px 6px; border-radius: 6px; color: var(--primary-dark); }
.seat-row .off { color: var(--ink-soft); }
.lobby-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ============ 移动端 ============ */
@media (max-width: 860px) {
  #game { flex-direction: column; align-items: center; padding: 6px; gap: 8px; }
  #board-wrap { width: 97vw; height: 97vw; }
  #side { width: 100%; max-width: none; min-width: 0; gap: 8px; }
  #players { grid-template-columns: 1fr 1fr; gap: 6px; }
  #log { height: 120px; font-size: 11px; }
  .p-head, .p-row { grid-template-columns: 84px 1fr 84px 68px; }
  .c-actions .btn { padding: 10px 14px; }
  .btn.mini { padding: 6px 10px; }
  .toast { font-size: 12px; padding: 6px 14px; }
}
@media (max-width: 480px) {
  .title { letter-spacing: 0; }
  .menu-sec { padding: 12px 12px; }
  .p-head, .p-row { grid-template-columns: 78px 1fr 78px 60px; gap: 5px; }
  .p-row input, .p-row select, input, select { font-size: 16px; } /* iOS 聚焦不放大 */
  .radio { font-size: 13px; }
  .tl-name { transform: scale(.92); }
  .quiz-options { grid-template-columns: 1fr 1fr; gap: 7px; }
  .quiz-opt { padding: 15px 6px; }
  .pl-money { font-size: 15px; }
  .pl-card { font-size: 12px; padding: 6px 8px; }
  .pl-worth { font-size: 10px; }
  .c-banner { padding: 4px 14px; }
  .modal-card { padding: 16px 14px; }
  .net-row { font-size: 13px; }
  #net-addr { width: 150px; }
  #center-panel { left: 10%; top: 10%; width: 80%; height: 80%; }
}
/* 手机横屏:棋盘限高,侧栏并排 */
@media (max-height: 520px) and (orientation: landscape) {
  #game { flex-direction: row; align-items: flex-start; }
  #board-wrap { width: 92vh; height: 92vh; }
  #log { height: 100px; }
}
