/* 睫毛保卫战 · 居家木作 UI（theme tokens 见 design.md） */
:root {
  --ink: #3A2A33;
  --cream: #FFF6EA;
  --linen: #F4E7D6;
  --wood: #B9773F;
  --wood-dark: #7A4A26;
  --flame: #FF6B3D;
  --mint: #5FD0C8;
  --sage: #9CB89A;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(58, 42, 51, .35);
  --t-in: 180ms;
  --t-out: 380ms;
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

#ui { position: fixed; inset: 0; pointer-events: none; color: var(--ink); font-family: var(--yoroll-font-body); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#ui .hidden { display: none !important; }

/* ---------- panel-frame（UI-PANEL；外壳图到位前为木框代码兜底） ---------- */
/* 木相框外壳：角饰占切片 24%，border-width 只给木框留位，border-image-width 覆盖到角饰，内容再留白 */
.panel {
  position: relative; box-sizing: border-box; pointer-events: auto;
  border: 30px solid transparent;
  border-image-source: url("assets/ui_panel.webp");
  border-image-slice: 24% 24% 24% 24% fill;
  border-image-width: 74px;
  border-image-repeat: stretch;
  background: none;
  filter: drop-shadow(0 8px 18px rgba(58,42,51,.35));
}
.panel-inner { padding: 22px 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.panel-title { margin: 0; font-size: clamp(22px, 4vw, 34px); color: var(--ink); }
.panel-title.big { font-size: clamp(28px, 5.5vw, 46px); }
.panel-sub { margin: 0; font-size: 15px; opacity: .85; }

/* ---------- 按钮（UI-BTN） ---------- */
.btn-col { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: stretch; }
.btn {
  pointer-events: auto; cursor: pointer; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  min-height: 54px; padding: 4px 14px; width: 100%;
  font-size: 19px; color: #fff; letter-spacing: 1px;
  /* 釉面陶瓷按钮外壳：左右木端头 16%、上下木边 22% */
  border: solid transparent; border-width: 12px 26px;
  border-image-source: url("assets/ui_button.webp");
  border-image-slice: 22% 16% 22% 16% fill;
  border-image-width: 12px 26px;
  background: none;
  text-shadow: 0 1px 0 rgba(120,30,10,.6), 0 0 4px rgba(120,30,10,.35);
  transition: transform var(--t-in) ease-out, filter var(--t-in);
}
.btn-secondary { filter: saturate(.3) sepia(.45) brightness(.98); color: #fff; }
.btn:active { transform: scale(.95) translateY(2px); }
.btn:disabled { filter: grayscale(.8) opacity(.65); cursor: default; transform: none; }

/* ---------- 圆形图标钮 ---------- */
.icon-btn {
  pointer-events: auto; cursor: pointer; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0;
  border: 3px solid var(--wood); background: var(--cream); box-shadow: 0 3px 0 var(--wood-dark);
}
.icon-btn svg { fill: var(--ink); stroke: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.close-x { position: absolute; top: -8px; right: -8px; z-index: 2; }

/* ---------- 屏幕 ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.screen.overlay { background: rgba(58, 42, 51, .45); pointer-events: auto; animation: fadeIn var(--t-in) ease-out; }
.screen.overlay > .panel { animation: popIn var(--t-out) var(--ease-pop); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#screen-title { justify-content: flex-start; padding-left: calc(4vw + var(--safe-l)); background: linear-gradient(90deg, rgba(58,42,51,.35), rgba(58,42,51,0) 55%); }
.title-panel { width: min(400px, 40vw); max-height: calc(100% - 32px); }
.game-title { margin: 0; font-size: clamp(32px, 5vw, 52px); color: var(--flame); text-shadow: 0 3px 0 var(--wood-dark); }
.subtitle { margin: 0; font-size: 15px; line-height: 1.55; }
.best-line { margin: 0; font-size: 14px; opacity: .8; min-height: 1em; }

.result-panel, .modal-panel { width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 24px); }
.upgrade-panel { width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.help-panel .panel-inner { max-height: calc(100vh - 120px); }
.help-body { overflow-y: auto; text-align: left; font-size: 15px; line-height: 1.6; max-height: 50vh; padding-right: 4px; }
.help-body p { margin: 0 0 6px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.stat { background: var(--cream); border-radius: 12px; padding: 6px 8px; display: flex; flex-direction: column; box-shadow: inset 0 0 0 2px rgba(185,119,63,.35); }
.stat-k { font-size: 13px; opacity: .75; }
.stat-v { font-size: 24px; font-family: var(--yoroll-font-title); color: var(--ink); }

/* ---------- 强化卡 ---------- */
.cards { display: flex; gap: 14px; width: 100%; justify-content: center; }
.card {
  pointer-events: auto; cursor: pointer; flex: 1 1 0; max-width: 250px; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 10px;
  border: 3px solid var(--wood); border-radius: var(--radius); background: var(--cream); color: var(--ink);
  box-shadow: 0 4px 0 var(--wood-dark); transition: transform var(--t-in);
}
.card:hover { transform: translateY(-4px); }
.card:active { transform: scale(.96); }
.card-icon { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; line-height: 1; color: #fff; background: var(--flame); box-shadow: inset 0 3px 0 rgba(255,255,255,.4), 0 3px 0 var(--wood-dark); }
.card-icon.tone-mint { background: var(--mint); }
.card-icon.tone-sage { background: var(--sage); }
.card-icon.tone-ink { background: var(--ink); }
.card-text { display: flex; flex-direction: column; gap: 4px; align-items: inherit; }
.card-name { font-family: var(--yoroll-font-title); font-size: 19px; }
.card-desc { font-size: 14px; opacity: .85; line-height: 1.4; }

/* ---------- 受击红闪 / 飘字 ---------- */
#hurt-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(216,74,38,.75); }
#hurt-flash.on { animation: hurtFlash .55s ease-out; }
@keyframes hurtFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
/* 奶油糊眼：整屏奶油遮挡（中间稍透，仍能隐约看到自己），随剩余时间变淡并下滑 */
#cream-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(255,250,240,.62), rgba(255,246,232,.9) 70%, rgba(250,236,214,.97)); transition: opacity .4s; }
#cream-overlay.hidden { display: none; }
#cream-overlay.splat { animation: creamSplat .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes creamSplat { 0% { transform: scale(1.25); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
#cream-overlay.falling { animation: creamFall .7s ease-in forwards; }
@keyframes creamFall { to { transform: translateY(110%); opacity: 0; } }
.cream-blob { position: absolute; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFFFFF, #FFF3E2 45%, #F3DDBF 100%); box-shadow: inset -10px -14px 0 rgba(214,180,140,.35); }
.cream-blob.b1 { width: 46vmax; height: 40vmax; left: -12vmax; top: -10vmax; }
.cream-blob.b2 { width: 42vmax; height: 38vmax; right: -14vmax; top: -6vmax; }
.cream-blob.b3 { width: 50vmax; height: 36vmax; left: -6vmax; bottom: -18vmax; }
.cream-blob.b4 { width: 40vmax; height: 34vmax; right: -10vmax; bottom: -14vmax; }
.cream-blob.b5 { width: 5vmax; height: 5vmax; left: 18vmax; top: 18vmax; background: radial-gradient(circle at 35% 30%, #FF8A8A, #D8213F 60%, #8E1225); box-shadow: none; }
.cream-timer { position: absolute; left: 50%; bottom: max(18%, calc(env(safe-area-inset-bottom) + 90px)); transform: translateX(-50%); padding: 8px 18px; border-radius: 999px; background: rgba(58,42,51,.78); color: var(--cream); font-family: var(--yoroll-font-title); font-size: 20px; white-space: nowrap; }
#floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-txt { position: absolute; transform: translate(-50%, -50%); font-family: var(--yoroll-font-title); font-size: 18px; color: var(--cream); text-shadow: 0 2px 0 var(--wood-dark), 0 0 6px rgba(58,42,51,.6); white-space: nowrap; animation: floatUp .8s ease-out forwards; }
.float-txt.big { font-size: 30px; color: #FFE1A0; }
.float-txt.good { color: #BFF3EE; text-shadow: 0 2px 0 #2C7F79, 0 0 6px rgba(58,42,51,.6); }
.float-txt.bad { color: #FFD0C2; text-shadow: 0 2px 0 #8E2A12, 0 0 6px rgba(58,42,51,.6); }
@keyframes floatUp { 0% { opacity: 0; margin-top: 6px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -42px; } }
.meter-fill.boss { background: linear-gradient(90deg, #E5402A, var(--flame)); }

/* ---------- HUD（UI-HUD） ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; font-family: var(--yoroll-font-hud); }
.hud-plate {
  box-sizing: border-box; border: solid transparent; border-width: 10px 24px;
  border-image-source: url("assets/ui_hud.webp");
  border-image-slice: 17% 15% 17% 15% fill;
  border-image-width: 10px 24px;
  background: none; filter: drop-shadow(0 3px 4px rgba(58,42,51,.3));
  padding: 3px 6px; min-height: 62px; display: flex; flex-direction: column; justify-content: center;
}
.hud-left { min-width: 170px; }
.hud-center { flex: 0 1 300px; align-items: stretch; text-align: center; }
.hud-right { min-width: 130px; margin-right: 56px; }
.hud-row { display: flex; align-items: center; gap: 8px; font-size: 15px; line-height: 1.35; }
.hud-label { opacity: .7; font-size: 13px; white-space: nowrap; }
.hud-num { font-family: var(--yoroll-font-title); font-size: 18px; }
.hud-icons { display: flex; gap: 2px; flex-wrap: nowrap; }
.hud-icons i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--flame); }
.hud-icons i.off { background: rgba(58,42,51,.18); }
.hud-icons.lash i { width: 5px; height: 14px; border-radius: 3px; background: var(--ink); }
.hud-icons.lash i.off { background: rgba(58,42,51,.15); }
.hud-round { font-size: 16px; }
.meter { height: 8px; border-radius: 6px; background: rgba(58,42,51,.15); overflow: hidden; margin: 3px 0; }
.meter-fill { height: 100%; width: 0%; background: var(--sage); border-radius: 6px; transition: width 120ms linear; }
.meter-heat { height: 6px; }
.heat-fill { background: linear-gradient(90deg, #FFB25C, var(--flame)); }
.heat-fill.overheat { animation: blinkHeat .25s steps(2) infinite; }
@keyframes blinkHeat { 50% { opacity: .3; } }
#btn-pause { position: absolute; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); }

/* ---------- 横幅 / 提示 ---------- */
.banner { position: absolute; top: 32%; left: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 92vw; text-align: center; animation: popIn var(--t-out) var(--ease-pop); }
.banner-title { font-size: clamp(26px, 7vw, 56px); color: var(--cream); text-shadow: 0 3px 0 var(--wood-dark), 0 0 18px rgba(58,42,51,.6); white-space: nowrap; }
.banner-title.danger { color: #FFD9C9; text-shadow: 0 3px 0 #8E2A12, 0 0 20px rgba(255,107,61,.8); }
.banner-sub { font-size: 16px; color: var(--cream); text-shadow: 0 1px 4px rgba(58,42,51,.8); }
.toast { position: absolute; bottom: calc(18% + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--cream); border: 3px solid var(--mint); border-radius: 999px; padding: 6px 18px; font-size: 16px; white-space: nowrap; box-shadow: var(--shadow); animation: popIn var(--t-out) var(--ease-pop); }

/* ---------- 虚拟摇杆 ---------- */
.stick { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; border: 3px solid rgba(255,246,234,.75); background: rgba(58,42,51,.18); pointer-events: none; }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255,246,234,.9); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.stick-aim { border-color: rgba(255,107,61,.8); }
.stick-aim .stick-knob { background: rgba(255,154,114,.95); }

/* ---------- 标题插画：眼睛模型加载期间铺底，加载完成后淡出露出 3D 客厅 ---------- */
#splash { position: absolute; inset: 0; background: #3A2A33 url("assets/title_key_art.webp") center / cover no-repeat; transition: opacity 900ms ease-out; pointer-events: none; }
#splash.gone { opacity: 0; }

/* ---------- 加载/失败 ---------- */
.load-error { color: #B23A1A; font-size: 14px; margin: 0; }

/* ---------- 响应式 ---------- */
@media (orientation: portrait) {
  #screen-title { justify-content: center; align-items: flex-end; padding: 0 0 calc(18px + var(--safe-b)); background: linear-gradient(0deg, rgba(58,42,51,.4), rgba(58,42,51,0) 55%); }
  .title-panel { width: min(400px, calc(100vw - 32px)); }
  #hud { flex-wrap: wrap; }
  .hud-center { order: 3; flex: 1 1 100%; margin-right: 0; }
  .hud-right { margin-right: 54px; }
  .cards { flex-direction: column; align-items: stretch; }
  .card { flex: 0 0 auto; max-width: none; min-height: 0; flex-direction: row; justify-content: flex-start; text-align: left; padding: 10px 12px; }
  .card-icon { font-size: 28px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .panel { border-width: 22px; border-image-width: 54px; }
  .panel-inner { padding: 12px 16px; gap: 6px; }
  .btn { min-height: 44px; font-size: 17px; }
  .subtitle { font-size: 13px; }
  .hud-plate { min-height: 48px; border-width: 8px 20px; border-image-width: 8px 20px; padding: 0 2px; }
  .hud-row { font-size: 13px; line-height: 1.25; }
  .help-body { max-height: 40vh; font-size: 14px; }
  .card { min-height: 110px; padding: 8px; }
  .stat-v { font-size: 20px; }
}
