/* ==========================================================
   学生端：加入页 + 实验台（投掷 / 记录 / 分析）
   ========================================================== */

.app {
  position: relative; z-index: 1;
  height: 100vh;                       /* 所有浏览器兜底 */
  height: 100dvh;                      /* 支持 dvh 的浏览器更准 */
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
}

/* ================= 加入页 ================= */
.join-wrap {
  height: 100%; padding: 24px;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
  overflow: auto;
}
.join-card {
  width: 100%;
  max-width: 680px;
  background: #fff; border-radius: 36px; padding: 44px 48px 40px;
  min-width: 0;
  box-shadow: var(--sh-4); border: 1px solid rgba(255,255,255,.7);
  animation: up .45s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { opacity: 0; transform: translateY(18px); } }

.brand-line { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-logo {
  width: 58px; height: 58px; border-radius: 18px;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
  -ms-flex-negative: 0; flex-shrink: 0;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  box-shadow: 0 10px 20px -8px rgba(4, 120, 87, .8), inset 0 1px 0 rgba(255,255,255,.4);
}
.brand-logo svg { width: 32px; height: 32px; }
.brand-line .t1 { font-size: 15px; color: var(--ink-500); letter-spacing: 3px; font-weight: 600; }
.brand-line .t2 { font-size: 30px; font-weight: 800; letter-spacing: 1px; margin-top: 2px; }

.join-title { font-size: 22px; color: var(--ink-700); margin: 0 0 6px; font-weight: 700; }
.join-sub { font-size: 16px; color: var(--ink-500); margin: 0 0 26px; line-height: 1.6; }

.field { margin-bottom: 20px; }
.field label { display: block; font-size: 16px; font-weight: 700; color: var(--ink-700); margin-bottom: 10px; }
.input {
  width: 100%; height: 66px; padding: 0 22px; border-radius: 18px;
  border: 2px solid var(--ink-100); background: var(--ink-50);
  font-size: 24px; font-weight: 600; color: var(--ink-900);
  transition: border-color .18s, background .18s, box-shadow .18s;
  outline: none;
}
.input::placeholder { color: #9aa7b8; font-weight: 500; font-size: 19px; }
.input:focus { border-color: var(--brand-500); background: #fff; box-shadow: 0 0 0 5px rgba(52, 211, 153, .18); }
.input.code { letter-spacing: 12px; font-size: 34px; text-align: center; font-family: var(--ff-num); }
.join-actions { display: flex; gap: 14px; margin-top: 8px; }
.join-actions .btn { flex: 1; height: 68px; font-size: 22px; }
.join-tip { margin-top: 18px; font-size: 15px; color: var(--ink-500); text-align: center; line-height: 1.7; }
.join-tip b { color: var(--brand-700); }
.join-err { color: var(--danger); font-size: 16px; font-weight: 600; margin-top: -6px; margin-bottom: 12px; min-height: 20px; }

/* 最近一次身份 */
.recent-chip {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 20px;
  border-radius: 16px; background: var(--brand-50); border: 1px dashed var(--brand-100);
  font-size: 16px; color: var(--brand-800);
}
.recent-chip .grow { text-align: left; }

/* ================= 实验台 ================= */
.stage {
  -webkit-box-flex: 1; -ms-flex: 1; flex: 1; min-height: 0;
  padding: 18px 22px 16px;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  gap: 14px;
}

/* 顶部信息条 */
.topbar {
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  flex-wrap: nowrap; gap: 14px; padding: 12px 20px; min-width: 0;
  background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 22px; box-shadow: var(--sh-1); border: 1px solid rgba(15,23,42,.04);
}
.topbar .logo-sm {
  width: 44px; height: 44px; border-radius: 14px; -ms-flex-negative: 0; flex-shrink: 0;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
}
.topbar .logo-sm svg { width: 24px; height: 24px; }
.topbar .who { line-height: 1.25; min-width: 0; }
.topbar .who .n, .topbar .who .c { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar .who .n { font-size: 19px; font-weight: 800; }
.topbar .who .c { font-size: 13px; color: var(--ink-500); }
.chip {
  display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -ms-flex-negative: 0; flex-shrink: 0;
  gap: 8px; padding: 9px 16px; border-radius: 999px;
  background: var(--ink-50); font-size: 16px; font-weight: 700; color: var(--ink-700);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-500); box-shadow: 0 0 0 4px rgba(52,211,153,.22); }
.chip.off .dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,.18); }
.chip.gold { background: var(--gold-100); color: #92400e; }
.chip.sky { background: var(--sky-100); color: #075985; }

/* 主内容区：左骰子区 / 右操作区 */
.stage-main {
  -webkit-box-flex: 1; -ms-flex: 1; flex: 1; min-height: 0; gap: 18px;
  display: -ms-grid; display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  -ms-grid-columns: minmax(0, 1fr) 280px;
}
.stage-main > .dice-zone { -ms-grid-column: 1; -ms-grid-row: 1; }
.stage-main > .side { -ms-grid-column: 2; -ms-grid-row: 1; }

/* 骰子舞台 */
.dice-zone {
  position: relative;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 46%, #fff 0%, #fff 42%, rgba(255,255,255,0) 72%),
    linear-gradient(180deg, #f0fdf8 0%, #ffffff 100%);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  overflow: hidden; min-height: 0; padding: 18px;
}
.dice-zone::before {
  content: ""; position: absolute; top: 14px; right: 14px; bottom: 14px; left: 14px; border-radius: 24px;
  border: 2px dashed rgba(16, 185, 129, .18); pointer-events: none;
}
.zone-head { position: absolute; top: 22px; left: 0; right: 0; text-align: center; }
.zone-head h2 { margin: 0; font-size: 22px; color: var(--ink-700); font-weight: 700; }
.zone-head p { margin: 6px 0 0; font-size: 15px; color: var(--ink-500); }

/* 旧版 2D 骰子样式已由 css/dice.css 的 3D 骰子取代，
   这里只保留点数和浮条与旧徽章的兼容留白 */
.sum-float.pop { animation: pop .42s cubic-bezier(.2, .9, .3, 1.6); }
@keyframes pop { 0% { transform: translateX(-50%) scale(.86); } 60% { transform: translateX(-50%) scale(1.06); } 100% { transform: translateX(-50%) scale(1); } }

/* 底部进度 */
.progress-wrap { position: absolute; bottom: 20px; left: 0; right: 0;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; }
.progress {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px; border-radius: 999px;
  background: rgba(255,255,255,.94); box-shadow: var(--sh-2); border: 1px solid var(--ink-100);
}
.progress .track { width: clamp(150px, 26vw, 320px); height: 12px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.progress .fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
  transition: width .45s cubic-bezier(.2,.9,.3,1);
}
.progress .txt { font-size: 16px; font-weight: 700; color: var(--ink-700); white-space: nowrap; }
.progress.done .fill { background: linear-gradient(90deg, var(--gold-400), var(--gold-500)); }
.progress.done .txt { color: #b45309; }

/* 右侧按钮区 */
.side {
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  gap: 14px; min-height: 0;
}
.roll-btn {
  height: 130px; height: clamp(96px, 17vh, 150px);
  border-radius: 28px; gap: 4px; -ms-flex-negative: 0; flex-shrink: 0;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  font-size: 30px; font-size: clamp(24px, 3.4vh, 34px); font-weight: 800;
}
.roll-btn small { font-size: 14px; font-weight: 600; opacity: .85; letter-spacing: 2px; }
.roll-btn .ic { font-size: 30px; line-height: 1; }
.panel-btns { display: -ms-grid; display: grid; grid-template-columns: 1fr 1fr; -ms-grid-columns: 1fr 1fr; gap: 12px; }
.panel-btn {
  height: 76px; height: clamp(64px, 9vh, 86px); border-radius: 22px; gap: 4px;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  font-size: 19px; font-weight: 800;
  background: #fff; border: 1.5px solid var(--ink-100); box-shadow: var(--sh-1);
  color: var(--ink-700); transition: .18s;
}
.panel-btn .ic { font-size: 22px; line-height: 1; }
.panel-btn:hover { border-color: var(--brand-500); color: var(--brand-800); box-shadow: var(--sh-2); }
.panel-btn.active { background: linear-gradient(180deg, var(--brand-50), #fff); border-color: var(--brand-500); color: var(--brand-800); box-shadow: 0 0 0 4px rgba(52,211,153,.16); }
.mini-btns { display: -ms-grid; display: grid; grid-template-columns: 1fr 1fr; -ms-grid-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.mini-btn {
  height: 56px; height: clamp(50px, 7vh, 62px); border-radius: 18px; font-size: 16px; font-weight: 700;
  background: var(--ink-50); color: var(--ink-700);
  display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; gap: 6px;
}
.mini-btn:hover { background: var(--ink-100); }
.quick-stats { display: -ms-grid; display: grid; grid-template-columns: 1fr 1fr; -ms-grid-columns: 1fr 1fr; gap: 12px; }
.qs {
  background: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: var(--sh-1); border: 1px solid rgba(15,23,42,.04);
}
.qs .k { font-size: 13px; color: var(--ink-500); font-weight: 600; }
.qs .v { font-size: 28px; font-weight: 800; font-family: var(--ff-num); color: var(--ink-900); line-height: 1.15; }
.qs .v span { font-size: 14px; color: var(--ink-500); font-weight: 600; margin-left: 2px; }

/* ================= 抽屉面板：记录 / 分析 ================= */
.drawer-mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 800; background: rgba(15, 23, 42, .35);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn .2s ease;
}
.panel {
  position: fixed; z-index: 801; right: 0; top: 0; bottom: 0;
  width: 94vw; max-width: 94vw; max-width: min(94vw, 1120px); background: #fff;
  border-radius: 32px 0 0 32px; box-shadow: -20px 0 60px rgba(15, 23, 42, .18);
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
  animation: slideIn .32s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideIn { from { transform: translateX(60px); opacity: .4; } }
.panel-head {
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 14px; padding: 22px 26px 16px;
  border-bottom: 1px solid var(--ink-100);
}
.panel-head h3 { margin: 0; font-size: 26px; font-weight: 800; }
.panel-head .sub { font-size: 15px; color: var(--ink-500); }
.panel-close {
  width: 52px; height: 52px; border-radius: 16px; background: var(--ink-50);
  font-size: 24px; color: var(--ink-700); -ms-flex-negative: 0; flex-shrink: 0;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
.panel-close:hover { background: var(--ink-100); }
.panel-body { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 22px 26px 26px; }

/* 统计表（课本样式，青绿配色升级版） */
.stat-table-wrap { overflow-x: auto; padding-bottom: 6px; }
.stat-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 860px; }
.stat-table th, .stat-table td {
  height: 78px; text-align: center; font-size: 26px; font-weight: 700;
  border-right: 1.5px solid #cfe9e0; border-bottom: 1.5px solid #cfe9e0;
  font-family: var(--ff-num);
}
.stat-table thead th:first-child,
.stat-table tbody th:first-child {
  width: 200px; font-family: var(--ff); font-size: 22px; text-align: left; padding-left: 22px;
  background: linear-gradient(90deg, #eafaf3, #f6fffb); color: var(--brand-900);
}
.stat-table thead th {
  background: linear-gradient(180deg, #f0fdf9, #dcfce7);
  color: var(--brand-900); font-size: 24px;
  border-top: 1.5px solid #cfe9e0;
}
.stat-table thead th:first-child { border-top-left-radius: 14px; }
.stat-table thead th:last-child { border-top-right-radius: 14px; }
.stat-table tbody th {
  border-left: 1.5px solid #cfe9e0; color: var(--brand-800); font-size: 20px;
}
.stat-table tbody td {
  color: var(--ink-900); background: #fff; transition: background .3s;
}
.stat-table tbody td.zero { color: var(--ink-300); }
.stat-table tbody td.hot { background: #fff7e6; color: #b45309; }
.stat-table tbody td.hit { animation: hit .8s ease-out; }
@keyframes hit { 0% { background: #fde68a; } 100% { background: #fff; } }
.stat-table tbody th:first-child { border-left: 1.5px solid #cfe9e0; border-bottom-left-radius: 14px; }
.stat-table tbody td:last-child { border-bottom-right-radius: 14px; }
.stat-summary {
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -ms-flex-wrap: wrap; flex-wrap: wrap; gap: 12px; margin-top: 18px;
}
.pill {
  display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 8px; padding: 10px 18px; border-radius: 999px;
  background: var(--ink-50); font-size: 17px; font-weight: 700; color: var(--ink-700);
}
.pill b { font-family: var(--ff-num); font-size: 21px; color: var(--brand-800); }
.pill.gold { background: #fffbeb; color: #92400e; }
.pill.gold b { color: #b45309; }

/* 分析页 */
.analysis-tools { display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -ms-flex-wrap: wrap; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.seg { display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex; background: var(--ink-50); border-radius: 14px; padding: 4px; }
.seg button {
  padding: 9px 18px; border-radius: 11px; font-size: 16px; font-weight: 700; color: var(--ink-500);
  transition: .18s;
}
.seg button.on { background: #fff; color: var(--brand-800); box-shadow: var(--sh-1); }
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100%; display: block; }
.insight {
  margin-top: 16px; padding: 16px 20px; border-radius: 18px;
  background: linear-gradient(120deg, var(--brand-50), #fff);
  border: 1px solid var(--brand-100); font-size: 17px; line-height: 1.75; color: var(--ink-700);
}
.insight b { color: var(--brand-800); }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .stage { padding: 12px; gap: 10px; }
  .stage-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; gap: 12px; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: stretch; }
  .roll-btn { flex: 1 1 100%; height: 92px; border-radius: 24px; flex-direction: row; gap: 12px; }
  .roll-btn small { display: none; }
  .panel-btns { flex: 1 1 100%; }
  .quick-stats { flex: 1 1 100%; }
  .mini-btns { flex: 1 1 100%; margin-top: 0; }
  .topbar .chip.opt { display: none; }
  .join-card { padding: 32px 26px 28px; }
  .join-card .brand-line .t2 { font-size: 24px; }
  .panel { width: 100vw; border-radius: 24px 24px 0 0; top: 8vh; }
  .panel-body { padding: 16px; }
  .stat-table th, .stat-table td { height: 58px; font-size: 20px; }
  .stat-table thead th { font-size: 18px; }
  .stat-table thead th:first-child, .stat-table tbody th:first-child { width: 120px; font-size: 16px; padding-left: 12px; }
}

@media (max-height: 620px) and (min-width: 900px) {
  .zone-head { top: 12px; }
  .zone-head p { display: none; }
  .progress-wrap { bottom: 10px; }
}
