/* ============================================================
 * 美妆狂潮 · 3D版 —— 卡通游戏视觉（移动端优先）
 * 设计语言：贴纸卡片 / 粗描边 / 硬阴影 / 果冻按钮
 * 布局基准：竖屏手机；桌面端用 min-width 媒体查询增强
 * ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
[hidden] { display: none !important; }

:root {
  --ink: #47203c;          /* 深梅紫描边 */
  --cream: #fff9f2;        /* 奶油卡片 */
  --pink: #ff5c8a;
  --purple: #a55eea;
  --yellow: #ffd32a;
  --grad: linear-gradient(135deg, #ff5c8a, #a55eea);
}

body {
  font-family: "Baloo 2", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.14) 0 46px, transparent 47px),
    radial-gradient(circle at 85% 12%, rgba(255,255,255,.10) 0 70px, transparent 71px),
    radial-gradient(circle at 78% 82%, rgba(255,211,42,.16) 0 56px, transparent 57px),
    radial-gradient(circle at 8% 78%, rgba(255,255,255,.10) 0 60px, transparent 61px),
    linear-gradient(140deg, #ff7bac 0%, #c86dd7 45%, #7a5fd0 100%);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(rgba(255,255,255,.5) 2.5px, transparent 3px);
  background-size: 90px 90px;
  animation: drift 26s linear infinite;
  opacity: .5;
}
@keyframes drift { to { transform: translateY(-90px); } }

#app { height: 100dvh; display: flex; flex-direction: column; position: relative; z-index: 1; overflow: hidden; max-width: 100%; }
.screen { display: none; height: 100%; flex-direction: column; align-items: center; justify-content: center; padding: 16px; overflow: auto; max-width: 100%; }
.screen.active { display: flex; }

/* ---------- 标题字体 ---------- */
h1, h2, .cartoon-title {
  font-family: "ZCOOL KuaiLe", "Baloo 2", "PingFang SC", sans-serif;
  font-weight: 400; letter-spacing: 2px;
}

/* ---------- 果冻按钮 ---------- */
.btn {
  position: relative; border: 3px solid var(--ink); border-radius: 999px;
  padding: 10px 24px; font-size: 15px; font-weight: 800; cursor: pointer;
  font-family: inherit; color: var(--ink);
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
  overflow: hidden;
}
.btn::after { /* 高光 */
  content: ""; position: absolute; left: 8%; right: 8%; top: 3px; height: 38%;
  border-radius: 999px; background: rgba(255,255,255,.45); pointer-events: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary {
  background: var(--grad); color: #fff;
  text-shadow: 0 2px 0 rgba(71,32,60,.35);
}
.btn.big { font-size: 20px; padding: 14px 48px; font-family: "ZCOOL KuaiLe", sans-serif; letter-spacing: 3px; }
.btn.ghost.on, .btn[aria-pressed="true"] {
  background: var(--grad); color: #fff;
  text-shadow: 0 2px 0 rgba(71,32,60,.35);
}
.btn.sm { font-size: 13px; padding: 6px 12px; box-shadow: 0 3px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- 贴纸卡片 ---------- */
.sticker {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 10px 0 rgba(71,32,60,.9), 0 18px 40px rgba(71,32,60,.35);
}

/* ---------- 开始屏 ---------- */
.start-card { text-align: center; max-width: 520px; width: min(520px, 100%); padding: 20px 22px 24px; }
.lang-row { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 8px; }
.sample-note { font-size: 12px; font-weight: 700; color: #8a4a72; margin: -8px 0 12px; }
.mode-box {
  border: 3px solid var(--ink); border-radius: 16px; background: #fff; text-align: left;
  padding: 8px 12px; margin: 0 0 14px; font-weight: 700; font-size: 13px;
}
.mode-box legend { padding: 0 6px; }
.mode-box label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 10px 4px 0; }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.home-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.home-footer { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(71,32,60,.4); margin: 10px 0 0; }
.example-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.example-row figure { margin: 0; width: 92px; }
.example-row img {
  width: 92px; height: 122px; object-fit: cover; border: 3px solid var(--ink); border-radius: 12px; background: #f0d9e4;
}
.example-row figcaption { font-size: 11px; font-weight: 700; margin-top: 4px; }
.criteria-note { font-size: 12px; font-weight: 700; color: #8a4a72; margin: 0 0 14px; }
.hero-img {
  width: 100%; max-height: 240px; object-fit: cover; object-position: top;
  border: 4px solid var(--ink); border-radius: 22px; margin-bottom: 12px;
  box-shadow: 0 6px 0 var(--ink);
}
.game-logo { font-size: 46px; margin: 0; color: var(--ink); line-height: 1.15; }
.game-logo .logo-pop {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ver-badge {
  display: inline-block; font-size: 15px; vertical-align: middle; margin-left: 10px;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px;
  padding: 3px 14px; box-shadow: 0 3px 0 var(--ink); letter-spacing: 2px;
  font-family: "ZCOOL KuaiLe", sans-serif; color: var(--ink);
}
.tagline { margin: 6px 0 16px; font-weight: 700; color: #8a4a72; }
.how { display: flex; gap: 10px; margin-bottom: 16px; }
.how div {
  flex: 1; background: #ffeef5; border: 3px solid var(--ink); border-radius: 18px;
  padding: 10px 6px; font-size: 13px; font-weight: 700; box-shadow: 0 4px 0 var(--ink);
}
.how b {
  display: block; width: 28px; height: 28px; line-height: 24px; margin: 0 auto 6px;
  border-radius: 50%; background: var(--grad); color: #fff; font-size: 15px;
  border: 3px solid var(--ink);
}
.wallet {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 800; margin-bottom: 18px;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 18px; box-shadow: 0 4px 0 var(--ink);
}
.wallet .ic { vertical-align: -6px; }
.tip { color: #fff; font-size: 13px; margin-top: 14px; font-weight: 700;
  text-shadow: 0 2px 0 rgba(71,32,60,.4); }

/* ---------- 主题屏 ---------- */
.theme-card { text-align: center; max-width: 440px; padding: 30px 34px 34px; }
.round-label {
  display: inline-block; letter-spacing: 4px; font-size: 14px; font-weight: 800;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 5px 18px 5px 22px;
}
.theme-ic-wrap {
  width: 96px; height: 96px; margin: 14px auto 6px;
  background: var(--grad); border: 4px solid var(--ink); border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 var(--ink);
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.theme-card h2 { font-size: 38px; margin: 6px 0 8px; }
.theme-card p { color: #8a4a72; font-weight: 600; line-height: 1.6; margin: 0 0 14px; }
.theme-palette { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; }
.theme-palette span {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}

/* ============================================================
 * 绘画屏 —— 移动端优先
 * 纵向：顶栏 / 状态条 / 3D视口(主导) / 工具横滑条 / 色板
 * 设置面板为底部弹出层
 * ============================================================ */
#screen-paint { justify-content: flex-start; padding: 0; height: 100dvh; width: 100%; max-width: 100%; overflow: hidden; }

#paint-topbar {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; z-index: 5; flex: 0 0 auto;
  background: var(--cream); border-bottom: 4px solid var(--ink);
}
.theme-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #ffeef5; border: 3px solid var(--ink); border-radius: 999px;
  padding: 4px 12px 4px 6px; font-weight: 800; font-size: 13px; white-space: nowrap;
  max-width: 36vw; overflow: hidden; text-overflow: ellipsis;
}
.theme-chip .ic { background: var(--grad); border-radius: 50%; padding: 2px; }
#paint-timer {
  font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums;
  margin-left: auto; background: var(--ink); color: #fff; white-space: nowrap;
  border-radius: 12px; padding: 5px 12px; letter-spacing: 1px;
}
#paint-timer.urgent { background: #e63d5f; animation: blink .8s infinite; }
@keyframes blink { 50% { transform: scale(1.08); } }
.wallet.small { font-size: 13px; margin: 0; padding: 5px 12px; }
#btn-finish { min-height: 44px; padding: 8px 20px; font-size: 15px; white-space: nowrap; }

#status-bar {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 6px 10px; width: 100%; max-width: 100%;
  font-size: 12px; font-weight: 800; color: var(--ink);
}
#status-mode { background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 10px; }
#status-hint { opacity: .8; flex: 1 1 120px; min-width: 0; }
#zoom-presets { display: flex; gap: 6px; flex-wrap: wrap; }

/* 3D 视口：占主导（flex 吃掉剩余高度） */
#screen-start.active { justify-content: flex-start; }
#viewport-wrap {
  position: relative; width: 100%; flex: 1 1 auto; min-height: 0; min-width: 0;
  background: radial-gradient(circle at 50% 30%, #3a3348 0%, #232030 70%);
  border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  overflow: hidden;
}
#viewport { position: absolute; inset: 0; touch-action: none; }
#viewport canvas {
  display: block; width: 100% !important; height: 100% !important;
  touch-action: none; cursor: crosshair;
}
#view-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: #fff; font-size: 18px; background: rgba(35,32,48,.85); z-index: 6;
  font-family: "ZCOOL KuaiLe", "Baloo 2", sans-serif; padding: 16px; text-align: center;
}
#load-bar { width: min(240px, 70%); height: 10px; background: #3a3348; border: 2px solid #fff; border-radius: 99px; overflow: hidden; }
#load-bar-fill { display: block; height: 100%; width: 0; background: var(--grad); }
#guide-bar, #look-start {
  flex: 0 0 auto; width: 100%; z-index: 7;
  background: var(--cream); border-bottom: 3px solid var(--ink);
  padding: 8px 12px; color: var(--ink); font-weight: 700; font-size: 13px;
}
#guide-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#guide-text { margin: 0; flex: 1 1 140px; min-width: 0; }
.tut-actions { display: flex; gap: 8px; justify-content: flex-end; }
#look-start p { margin: 0 0 6px; }
.look-start-row { display: flex; flex-wrap: wrap; gap: 8px; }
.look-start-row .btn { min-height: 44px; min-width: 44px; }

#brush-preview {
  position: absolute; pointer-events: none; z-index: 4;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%; box-shadow: 0 0 0 1px rgba(71,32,60,.45);
}
#paint-loupe {
  position: absolute; pointer-events: none; z-index: 6;
  width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--ink); background: #232030;
  box-shadow: 0 4px 0 rgba(71,32,60,.4);
}
#paint-loupe canvas { width: 100%; height: 100%; display: block; }

#canvas-ops {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: stretch; justify-content: center;
  padding: 6px 8px; background: rgba(255,249,242,.97);
  border-bottom: 2px solid var(--ink); z-index: 5;
}
#canvas-ops .btn {
  min-width: 44px; min-height: 44px; padding: 6px 12px; font-size: 12px;
  display: inline-flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 4px; line-height: 1.1;
}
#canvas-ops .redo [data-ic] { transform: scaleX(-1); }
#rec-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
#rec-swatches .sw { width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; }
#guide-bar .btn, #look-start .btn, #btn-guide { min-height: 44px; }

/* 拇指区：作画/旋转 + 设置（右下，易够到） */
#thumb-zone {
  position: absolute; right: 10px; bottom: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
#mode-toggle { display: flex; gap: 6px; }
#mode-toggle .btn, #btn-panel {
  min-height: 48px; padding: 10px 18px; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
#mode-toggle .btn.on { background: var(--grad); color: #fff; }

/* 工具条：底部横向滑动 */
#tool-rail {
  flex: 0 0 auto; display: flex; gap: 8px; width: 100%;
  overflow-x: auto; overflow-y: hidden; padding: 10px 12px;
  background: rgba(255,249,242,.97); border-top: 4px solid var(--ink);
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#tool-rail::-webkit-scrollbar { display: none; }
.tool {
  scroll-snap-align: start; flex: 0 0 auto;
  width: 62px; min-height: 66px; border-radius: 18px; border: 3px solid var(--ink);
  background: #fff; cursor: pointer; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  box-shadow: 0 3px 0 var(--ink); font-family: inherit;
  font-size: 12px; font-weight: 800; color: var(--ink);
  transition: transform .1s;
}
.tool em { font-style: normal; line-height: 1.1; }
.tool:active { transform: scale(.93); }
.tool.on {
  background: var(--grad); color: #fff;
  transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink);
}

#color-rail {
  display: flex; align-items: center; gap: 8px; width: 100%; flex: 0 0 auto;
  padding: 4px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--cream); border-top: 2px solid var(--ink);
}
#color-rail > label { flex: 0 0 auto; font-size: 13px; font-weight: 800; }
#quick-color {
  flex: 0 0 44px; width: 44px; height: 44px; padding: 2px;
  border: 3px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer;
}
#quick-swatches {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  overflow-x: auto; padding: 6px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#quick-swatches::-webkit-scrollbar { display: none; }
#quick-swatches .sw { flex: 0 0 44px; width: 44px; height: 44px; }

/* 设置面板：底部弹出层 */
#sheet-scrim {
  position: fixed; inset: 0; background: rgba(40,18,32,.45); z-index: 18;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#sheet-scrim.show { opacity: 1; pointer-events: auto; }
#panel.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--cream); border: 4px solid var(--ink); border-bottom: none;
  border-radius: 26px 26px 0 0; box-shadow: 0 -8px 30px rgba(71,32,60,.35);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.9,.3,1.08);
  max-height: 56dvh; overflow-y: auto; color: var(--ink);
  display: flex; flex-direction: column; gap: 10px;
}
#panel.sheet.open { transform: none; }
.sheet-handle {
  width: 52px; height: 6px; border-radius: 99px; background: #d9b8c9;
  margin: 0 auto 2px; flex: 0 0 auto;
}
.panel-label { font-size: 14px; font-weight: 800; display: block; margin-bottom: 6px; }
.panel-label b { color: #d63d6e; }
#swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(28px, 1fr)); gap: 6px; }
.sw {
  aspect-ratio: 1; border-radius: 50%; cursor: pointer; padding: 0;
  border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
  min-width: 0; min-height: 28px; transition: transform .1s;
}
.sw:active { transform: scale(.9); }
.sw.on { outline: 3px solid var(--pink); outline-offset: 2px; transform: scale(1.12); }
.custom-color { display: flex; align-items: center; gap: 10px; }
.custom-color .panel-label { margin: 0; }
#custom-color {
  width: 56px; height: 44px; border: 3px solid var(--ink); border-radius: 10px;
  background: #fff; padding: 2px; cursor: pointer; box-shadow: 0 2px 0 var(--ink);
}
input[type=range] { width: 100%; accent-color: var(--pink); min-height: 44px; }
.panel-row.btns { display: flex; gap: 8px; }
.panel-row.btns .btn {
  flex: 1; min-height: 58px; padding: 8px 2px; font-size: 13px;
  box-shadow: 0 4px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; line-height: 1.2;
}
#brush-feel { font-size: 13px; font-weight: 800; color: #b0437a; }
.panel-hint {
  font-size: 12.5px; font-weight: 600; line-height: 1.55; color: #8a4a72;
  background: #fff; border: 3px dashed #e8a8c4; border-radius: 14px; padding: 8px 10px;
  min-height: 40px;
}

/* Keep the phone header focused on the current look and finishing. */
@media (max-width: 860px) {
  #paint-topbar { padding: 6px 10px; }
  #paint-topbar .wallet { display: none; }
  #screen-paint[data-timed="false"] #paint-timer { display: none; }
  #paint-topbar .theme-chip { min-width: 0; max-width: none; flex: 0 1 auto; }
  #paint-theme-name { overflow: hidden; text-overflow: ellipsis; }
  #paint-timer { flex-shrink: 0; }
  #btn-finish { margin-left: auto; flex-shrink: 0; }
}

/* ============================================================
 * 桌面端增强（≥861px）：视口左、工具+面板右
 * ============================================================ */
@media (min-width: 861px) {
  /* Only the active paint screen is a grid. #screen-paint {display:grid} used to un-hide it on desktop. */
  #screen-paint.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    grid-template-rows: auto auto auto auto minmax(0, .45fr) minmax(0, .55fr);
    gap: 10px; padding: 10px;
    align-items: stretch; justify-items: stretch;
    height: 100dvh; max-height: 100dvh; overflow: hidden;
  }
  #paint-topbar { grid-column: 1 / -1; grid-row: 1; border: 4px solid var(--ink); border-radius: 18px; }
  #status-bar { grid-column: 1 / -1; grid-row: 2; }
  #guide-bar { grid-column: 1 / -1; grid-row: 3; border: 3px solid var(--ink); border-radius: 14px; }
  #look-start { grid-column: 1 / -1; grid-row: 4; border: 3px solid var(--ink); border-radius: 14px; }
  #viewport-wrap {
    grid-column: 1; grid-row: 5 / 7;
    border: 4px solid var(--ink); border-radius: 18px;
    box-shadow: 0 6px 0 rgba(71,32,60,.25);
    min-height: 0;
  }
  #tool-rail {
    grid-column: 2; grid-row: 5;
    flex-direction: column; overflow-y: auto; overflow-x: hidden;
    border-top: none; border: 4px solid var(--ink); border-radius: 18px;
    padding: 10px; align-items: stretch; scroll-snap-type: none;
    max-height: 36vh;
  }
  .tool {
    width: 100%; min-height: 48px; scroll-snap-align: none;
    flex-direction: row; justify-content: flex-start; padding: 6px 12px; gap: 10px;
    font-size: 14px;
  }
  #panel.sheet {
    position: static; transform: none; z-index: auto;
    grid-column: 2; grid-row: 6;
    border: 4px solid var(--ink); border-radius: 18px; box-shadow: none;
    max-height: none; min-height: 0; overflow-y: auto; padding: 12px;
  }
  #btn-panel, #sheet-scrim, .sheet-handle, #color-rail { display: none; }
  #thumb-zone { flex-direction: row; align-items: center; }
  #canvas-ops {
    grid-column: 1; grid-row: 7;
    border: 3px solid var(--ink); border-radius: 14px;
    background: var(--cream);
  }
  #viewport-wrap { grid-row: 5 / 7; }
  #screen-paint.active {
    grid-template-rows: auto auto auto auto minmax(0, 1fr) minmax(0, .4fr) auto;
  }
}

.breakdown { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; }
.breakdown li {
  display: flex; justify-content: space-between; padding: 8px 10px; margin-bottom: 6px;
  background: #fff; border: 3px solid var(--ink); border-radius: 12px; font-weight: 800;
}
.result-shots {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.result-shots figure { margin: 0; }
.result-shots img {
  display: block; border: 3px solid var(--ink); border-radius: 12px; background: #f0d9e4;
  object-fit: contain;
}
.shot-after img { width: min(100%, 340px); height: auto; aspect-ratio: 4 / 5; }
.shot-before { align-self: flex-start; }
.shot-before img { width: 88px; height: auto; aspect-ratio: 4 / 5; }
.result-shots figcaption { font-size: 12px; font-weight: 800; margin-top: 4px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#result-score-box { text-align: left; margin: 0 0 12px; }
#result-score-box summary {
  cursor: pointer; font-weight: 800; min-height: 44px;
  display: flex; align-items: center; gap: 8px;
  list-style: none;
}
#result-score-box summary::-webkit-details-marker { display: none; }
#result-reward-wrap { margin-bottom: 12px; }
#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 13px;
  padding: 8px 16px; border-radius: 999px; opacity: 0; pointer-events: none;
  z-index: 50; transition: opacity .2s, transform .2s; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.dlg { border: 4px solid var(--ink); border-radius: 24px; max-width: 440px; width: calc(100% - 24px); padding: 18px; color: var(--ink); }
.dlg::backdrop { background: rgba(40,18,32,.45); }
.shop-item, .gal-item {
  display: flex; gap: 10px; align-items: center; border: 3px solid var(--ink);
  border-radius: 14px; padding: 8px; margin-bottom: 8px; background: #fff; text-align: left;
}
.shop-item .meta { flex: 1; min-width: 0; }
.gal-item img { width: 54px; height: 72px; object-fit: cover; border-radius: 8px; border: 2px solid var(--ink); }
.stats-pre { white-space: pre-wrap; font-size: 12px; background: #fff; border: 2px dashed #e8a8c4; padding: 8px; border-radius: 10px; }

/* ---------- 结算屏 ---------- */
.result-card { width: 100%; max-width: 460px; text-align: center; padding: 26px 24px 28px; }
.result-title-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.result-card h2 { margin: 0; font-size: 34px; }
.result-theme { font-weight: 700; color: #8a4a72; font-size: 14px; margin: 6px 0 14px; }
.result-theme .ic { vertical-align: -7px; }
.result-theme b { color: var(--ink); }
#result-list { list-style: none; margin: 0 0 16px; padding: 0; text-align: left; }
#result-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 16px; margin-bottom: 8px; font-size: 15px; font-weight: 700;
  background: #fff; border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
#result-list li.me { background: #ffe3ee; transform: scale(1.02); }
#result-list img {
  width: 46px; height: 69px; object-fit: cover; border-radius: 10px;
  border: 3px solid var(--ink);
}
#result-list .rname { flex: 1; }
#result-list .rscore { color: #b97e0e; font-weight: 800; font-size: 17px; }
.rank-medal {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
  border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.rank-1 { background: linear-gradient(135deg,#ffd32a,#ff9d2e); }
.rank-2 { background: linear-gradient(135deg,#dfe6f2,#a9b6cc); }
.rank-3 { background: linear-gradient(135deg,#ffb35c,#e07b39); }
.rank-other { background: #c9b8d6; }
.result-reward {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 19px; margin-bottom: 18px; font-weight: 800; color: #b97e0e;
  background: #fff7dd; border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 20px; box-shadow: 0 4px 0 var(--ink);
}
.result-card .btn { margin: 4px; }

/* 结算排名徽章 */
.rk { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  font-weight: 800; font-size: 16px; border: 3px solid #47203c; background: #fff; color: #47203c; flex-shrink: 0; }
.rk1 { background: #ffd32a; } .rk2 { background: #e8e8ee; } .rk3 { background: #f0b27a; }

/* ---------- 小屏微调 ---------- */
@media (max-width: 380px) {
  .game-logo { font-size: 36px; }
  .theme-chip { font-size: 12px; }
  #paint-timer { font-size: 17px; }
  #canvas-ops .btn { padding: 6px 8px; font-size: 11px; }
  #status-hint { display: none; }
}

#guide-bar { font-size: 12px; }
#chk-region-assist { width: 20px; height: 20px; accent-color: var(--pink); vertical-align: middle; }
.panel-row .panel-label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
#swatches { flex-wrap: wrap; }
@media(min-width:861px) { #tool-rail { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-content:start; max-height:none; } .tool { min-height:44px; font-size:12px; padding:5px; } }

.tip, .home-footer { color: #754864; text-shadow: none; }

.screen:not(#screen-paint) { justify-content:flex-start; }
.screen > .sticker { margin-block:auto; flex-shrink:0; }
.example-download { color:var(--ink); font-size:11px; }

/* Real gameplay renders on the first visit, without loading the model. */
.start-card { width:min(1050px,100%); max-width:1050px; display:grid; grid-template-columns:1fr 1fr; gap:16px 28px; padding:24px; }
.lang-row { grid-column:1/-1; }
.home-visual { align-self:center; min-width:0; }
.home-content { min-width:0; }
.home-visual .example-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.home-visual figure { margin:0; min-width:0; width:100%; }
.home-visual img { width:100%; height:auto; aspect-ratio:4/5; object-fit:cover; }
.home-visual figure:nth-child(2) { transform:translateY(22px); }
.home-visual figcaption { font-size:12px; }
.eyebrow { font-weight:800; letter-spacing:3px; color:#8a4a72; }
.home-content .game-logo { margin-top:0; font-size:40px; }
.home-content .how { font-size:12px; }
.home-content .tip { font-size:11px; }
@media(max-width:700px) {
 .start-card { display:flex; flex-direction:column; padding:16px; gap:10px; }
 .lang-row { width:100%; }
 .home-visual { width:100%; }
 .home-visual .example-row { max-width:320px; margin:0 auto 8px; }
 .home-visual img { max-height:132px; }
 .home-visual figure:nth-child(2) { transform:translateY(8px); }
 .eyebrow { margin:0 0 8px; font-size:11px; }
 .home-content .game-logo { font-size:32px; margin:5px 0 12px; }
}

@media(max-width:700px) { .home-content .how { display:none; } .result-card h2 {font-size:26px;} .result-card {padding:20px 16px;} }

/* Compact studio controls: keep the portrait clear and secondary controls in settings. */
#paint-topbar { padding: 3px 8px; border-bottom-width: 2px; }
#paint-topbar .theme-chip { border-width: 2px; padding: 2px 8px; }
#btn-finish { padding: 4px 14px; font-size: 13px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
#canvas-ops { padding: 2px 6px; gap: 4px; background: var(--cream); }
#canvas-ops .btn { flex: 1; min-width: 44px; padding: 3px 4px; border-width: 1px; border-radius: 9px; box-shadow: none; font-size: 11px; gap: 2px; }
#canvas-ops .btn [data-ic] { display: none; }
#btn-mode-rotate.on { background: var(--grad); color: white; }
#tool-rail { padding: 4px 6px; gap: 5px; border-top-width: 1px; }
#tool-rail .tool { min-height: 48px; width: 55px; border-width: 1px; border-radius: 10px; padding: 3px 2px; box-shadow: none; font-size: 10px; gap: 0; }
#tool-rail .tool .ic { width: 22px; height: 22px; }
#tool-rail .tool.on { transform: none; box-shadow: none; }
#color-rail { padding: 1px 6px calc(1px + env(safe-area-inset-bottom)); gap: 5px; border-top-width: 1px; }
#color-rail > label { display: none; }
#quick-color { border-width: 2px; border-radius: 9px; }
#quick-swatches { padding: 3px; gap: 8px; }
#quick-swatches .sw { border-width: 2px; box-shadow: none; }
#status-bar { padding: 0; gap: 6px; }
#status-mode, #status-hint { display: none; }
#zoom-presets { gap: 5px; }
#panel #status-bar .btn { padding: 4px 8px; border-width: 1px; border-radius: 9px; box-shadow: none; }
#btn-panel-close { align-self: flex-end; min-height: 44px; padding: 4px 10px; }
#guide-bar, #look-start { padding: 4px 8px; border-bottom-width: 1px; }
#guide-bar .btn, #look-start .btn { border-width: 1px; border-radius: 9px; box-shadow: none; padding: 4px 10px; }
#look-start p { margin-bottom: 2px; }
.look-start-row { gap: 5px; }
@media (min-width: 861px) {
 #screen-paint.active { grid-template-rows: auto auto auto minmax(0, .35fr) minmax(0, .65fr) auto; }
 #guide-bar { grid-row: 2; }
 #look-start { grid-row: 3; }
 #viewport-wrap { grid-row: 4 / 6; }
 #tool-rail { grid-row: 4; }
 #panel.sheet { grid-row: 5; }
 #canvas-ops { grid-row: 6; }
 #tool-rail .tool { width: 100%; font-size: 12px; }
 #btn-panel-close { display: none; }
}

@media (min-width:861px) { #canvas-ops #btn-panel { display:none; } }

/* Extra home copy scrolls inside the start screen only. */
#screen-start {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  justify-content: flex-start;
}
#screen-start > .start-card { margin-block: 0; }
