/* ==============================================================
   等式填充 · 游戏专属样式
   选择器统一以 .g-equationfill / .ef-* 前缀限定
   ============================================================== */

.g-equationfill {
  --ef-line: rgba(255, 255, 255, 0.08);
  gap: 10px;
}

/* ------------------------------ 顶部状态 ------------------------------ */

.ef-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}
.ef-hud .badge { font-size: 11px; padding: 4px 10px; }
.ef-qidx {
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.ef-hints {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.ef-time {
  margin-left: auto;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ------------------------------ 单式 ------------------------------ */

.ef-single-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ef-single-panel {
  width: 100%;
  padding: 20px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--ef-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.ef-eq {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 74px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.ef-num {
  font-size: min(10.5vw, 42px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.ef-op {
  font-size: min(8.5vw, 34px);
  color: var(--dim);
  font-weight: 600;
  padding: 0 1px;
}
.ef-eq-sign {
  font-size: min(8.5vw, 34px);
  color: var(--faint);
  font-weight: 600;
  padding: 0 2px;
}
.ef-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  min-height: 1.3em;
  padding: 0 0.14em;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, rgba(255, 255, 255, 0.02));
  color: var(--accent);
  font-family: var(--mono);
  font-size: min(10.5vw, 42px);
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.ef-blank .ef-blank-v { pointer-events: none; }
.ef-blank.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 32%, transparent);
  transform: translateY(-1px);
}
.ef-blank.filled { color: #fff6ea; background: color-mix(in srgb, var(--accent) 18%, rgba(255, 255, 255, 0.03)); }
.ef-blank.bad {
  border-color: #ff7684;
  color: #ffb0b8;
  background: rgba(255, 95, 110, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 95, 110, 0.4);
}
.ef-single-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}

/* ------------------------------ 数字矩阵 ------------------------------ */

.ef-board-holder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ef-board {
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  display: grid;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  box-shadow: 0 22px 48px -28px rgba(0, 0, 0, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  touch-action: manipulation;
}
.ef-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 2px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
  color: #fff8f0;
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.ef-cell.given {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.025));
  border-color: rgba(255, 255, 255, 0.13);
}
.ef-cell.blank {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, rgba(255, 255, 255, 0.02));
}
.ef-cell.blank.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 13%, rgba(255, 255, 255, 0.025));
}
.ef-cell.sel {
  z-index: 2;
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent), 0 0 16px color-mix(in srgb, var(--accent) 28%, transparent);
  transform: scale(0.97);
}
.ef-cell.bad {
  border-style: solid;
  border-color: #ff7684;
  background: rgba(255, 95, 110, 0.16);
  box-shadow: 0 0 0 2px rgba(255, 95, 110, 0.55), 0 0 16px rgba(255, 95, 110, 0.2);
}
.ef-cell.sel.bad { border-color: #ff5c6c; box-shadow: 0 0 0 2.5px #ff5c6c, 0 0 18px rgba(255, 92, 108, 0.35); }
.ef-blank.sel.bad { border-color: #ff5c6c; box-shadow: 0 0 0 2px rgba(255, 92, 108, 0.6); }
.ef-cell:active { transform: scale(0.95); }
.ef-v {
  font-family: var(--mono);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ef-n3 .ef-v { font-size: min(10.5vw, 42px); }
.ef-n4 .ef-v { font-size: min(9vw, 34px); }
.ef-cell.blank:not(.filled) .ef-v { color: transparent; }
.ef-cell.blank:not(.filled)::after {
  content: '?';
  position: absolute;
  font-size: 12px;
  color: color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0.55;
  pointer-events: none;
}
.ef-cell.bad.blank:not(.filled)::after { color: #ffb0b8; }

.ef-op-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  user-select: none;
}
.ef-n4 .ef-op-cell { font-size: 10.5px; }
.ef-n4 .ef-op-cell.eq { font-size: 11.5px; }
.ef-op-cell.eq { color: var(--dim); font-size: 15px; font-weight: 700; }
.ef-op-cell.vert .ef-op-sym { transform: rotate(90deg); }
.ef-op-cross { min-width: 0; min-height: 0; }

/* ------------------------------ 工具 / 键盘 ------------------------------ */

.ef-tools {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ef-tools .btn {
  min-height: 42px;
  gap: 7px;
  font-size: 13px;
}
.ef-tool-i { display: inline-flex; width: 17px; height: 17px; }
.ef-tool-i svg { width: 17px; height: 17px; }
.ef-tools .ef-tool[data-act="hint"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.ef-pad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.ef-pad .pad-key {
  min-height: 46px;
  font-size: 20px;
  font-weight: 700;
  padding: 0;
}
.ef-pad .ef-back,
.ef-pad .ef-clear {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dim);
}
.ef-pad .ef-back { color: var(--dim); }
.ef-pad .ef-clear { color: #ff9aa4; }
.ef-tip {
  flex: none;
  min-height: 17px;
  text-align: center;
  font-size: 10.5px;
  color: var(--faint);
}

/* ------------------------------ 开始页 ------------------------------ */

.ef-start { gap: 12px; }
.ef-startp { display: flex; flex-direction: column; }
.ef-start .seg-item { min-height: 42px; font-size: 13px; }
.ef-desc {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--faint);
}
.ef-info { display: flex; flex-direction: column; margin-top: 2px; }
.ef-irow {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
}
.ef-irow:last-child { border-bottom: 0; }
.ef-irow .n { font-size: 12.5px; color: var(--dim); }
.ef-irow .b { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ef-irow.best .n { color: var(--faint); }
.ef-start-btn { margin-top: 14px; min-height: 48px; }
.ef-foot.hint { margin-top: auto; padding-top: 8px; text-align: center; font-size: 11px; }

/* ------------------------------ 结算 ------------------------------ */

.ef-resultwrap { gap: 12px; }
.ef-result {
  flex: none;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, var(--line));
  background: linear-gradient(165deg,
      color-mix(in srgb, var(--ok) 10%, transparent),
      rgba(255, 255, 255, 0.02));
  padding: 14px var(--pad) 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: efUp 0.32s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}
.ef-result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.ef-result-k {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.ef-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  flex: none;
}
.ef-result-time {
  margin-top: 2px;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.06;
}
.ef-result-meta {
  text-align: right;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.ef-best { color: var(--dim); }
.ef-best.new { color: var(--ok); font-weight: 700; }
.ef-result .btn-row .btn { min-height: 44px; }
.ef-result-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ef-result-sub .btn { min-height: 38px; }

/* ------------------------------ 动画 ------------------------------ */

@keyframes efUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ 矮屏 / 小屏 ------------------------------ */

@media (max-height: 710px) {
  .g-equationfill { gap: 8px; }
  .ef-hud { min-height: 26px; }
  .ef-single-panel { padding: 14px 10px; }
  .ef-eq { min-height: 60px; }
  .ef-num, .ef-blank { font-size: min(9.5vw, 40px); }
  .ef-n3 .ef-v { font-size: min(9.5vw, 40px); }
  .ef-n4 .ef-v { font-size: min(8vw, 32px); }
  .ef-tools .btn { min-height: 40px; }
  .ef-pad .pad-key { min-height: 43px; }
  .ef-start { gap: 10px; }
  .ef-startp { padding: 12px; }
  .ef-start-btn { margin-top: 10px; }
  .ef-foot.hint { display: none; }
  .ef-result { padding: 12px var(--pad) 13px; gap: 10px; }
  .ef-result-time { font-size: 32px; }
}

@media (max-width: 365px) {
  .g-equationfill { gap: 8px; }
  .ef-eq { gap: 3px; }
  .ef-pad { gap: 5px; }
  .ef-pad .pad-key { min-height: 44px; }
  .ef-cell { margin: 1.5px; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .ef-result { animation: none; }
  .ef-cell, .ef-blank { transition: none; }
}
