/* ===== 单词割草 像素风样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

:root {
  --ink: #1a1428;
  --panel: #241c3a;
  --panel-lite: #342a52;
  --gold: #ffd75e;
  --green: #6ee06e;
  --red: #ff5e6c;
  --blue: #6ec3ff;
  --text: #f0ecff;
  --dim: #9a90c0;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--ink); }
body {
  font-family: "Microsoft YaHei", "PingFang SC", monospace, sans-serif;
  color: var(--text);
}

#wrap { position: fixed; inset: 0; }
#game {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none; /* 阻止移动端滚动/缩放手势 */
}

.hidden { display: none !important; }

/* ---- 像素边框面板通用 ---- */
.pixel-panel, .modal-box, #target-panel, #hud-top-left, #hud-top-right, #boss-panel {
  background: rgba(26, 20, 40, 0.88);
  border: 3px solid #4a3d78;
  box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 2px #15102a;
  border-radius: 2px;
}

/* ================= HUD ================= */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }

#hud-top-left { position: absolute; top: 10px; left: 10px; padding: 8px; width: 220px; }
.bar { position: relative; height: 18px; background: #120d22; border: 2px solid #000; margin-bottom: 6px; }
.bar > div { position: absolute; inset: 0; width: 100%; transition: width .15s steps(8); }
.bar.hp > div { background: linear-gradient(#ff7a85, #d92e44); }
.bar.xp > div { background: linear-gradient(#7ee8ff, #2e7ad9); width: 0; }
.bar.boss > div { background: linear-gradient(#c07aff, #7a2ed9); }
.bar span {
  position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 15px;
  font-weight: bold; text-shadow: 1px 1px 0 #000; color: #fff;
}
#weapon-icons { font-size: 14px; letter-spacing: 3px; min-height: 18px; text-shadow: 1px 1px 0 #000; }

#target-panel {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; font-size: 22px; font-weight: bold; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
#target-panel .t-label { font-size: 18px; }
#target-zh { color: var(--gold); text-shadow: 2px 2px 0 #000; }
.speak-btn {
  background: var(--panel-lite); border: 2px solid #000; color: #fff; font-size: 16px;
  cursor: pointer; padding: 2px 8px; border-radius: 2px;
}
.speak-btn:active { transform: translateY(2px); }

#hud-top-right { position: absolute; top: 10px; right: 10px; padding: 8px 12px; text-align: right; font-weight: bold; }
#hud-top-right div { font-size: 15px; text-shadow: 1px 1px 0 #000; margin: 2px 0; }
#stat-time { color: var(--blue); font-size: 18px !important; }
#btn-pause {
  margin-top: 4px; background: var(--panel-lite); border: 2px solid #000; color: #fff;
  font-size: 16px; padding: 4px 14px; cursor: pointer; border-radius: 2px;
}
#btn-pause:active { transform: translateY(2px); }

#combo {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  font-size: 20px; font-weight: bold; color: var(--gold);
  text-shadow: 2px 2px 0 #000; animation: pop .25s steps(4);
}
@keyframes pop { 0% { transform: translateX(-50%) scale(1.8); } 100% { transform: translateX(-50%) scale(1); } }

#boss-panel {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  min-width: 340px; max-width: 90vw; padding: 10px 18px; text-align: center;
}
#boss-name { color: var(--red); font-weight: bold; font-size: 15px; margin-bottom: 4px; text-shadow: 1px 1px 0 #000; }
#boss-word-hint { font-size: 18px; color: var(--gold); font-weight: bold; margin-bottom: 6px; }
#boss-word-hint .speak-btn { font-size: 13px; }
#boss-spell { font-size: 26px; font-weight: bold; letter-spacing: 8px; font-family: Consolas, monospace; margin-bottom: 8px; }
#boss-spell .done { color: var(--green); }
#boss-spell .todo { color: var(--dim); }

#announce {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%);
  font-size: 34px; font-weight: bold; color: var(--gold); text-align: center;
  text-shadow: 3px 3px 0 #000; pointer-events: none; animation: announce 2.4s steps(12) forwards;
  white-space: pre-line;
}
@keyframes announce {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  25% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ================= 全屏界面 ================= */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; background: radial-gradient(ellipse at 50% 30%, #2a2148 0%, var(--ink) 70%);
  overflow-y: auto; padding: 24px; z-index: 10;
}
.pixel-title {
  font-size: clamp(26px, 7vw, 60px); color: var(--gold); letter-spacing: clamp(2px, 1vw, 8px);
  text-shadow: 3px 3px 0 #7a2ed9, 6px 6px 0 #000; text-align: center;
}
.small-title { font-size: clamp(30px, 6vw, 48px); }
.subtitle { color: var(--blue); font-size: 16px; letter-spacing: 4px; font-weight: bold; }
.tip { color: var(--dim); font-size: 14px; text-align: center; max-width: 640px; }
.tip.small { font-size: 12px; }

#tier-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; width: min(880px, 94vw); margin: 8px 0; }
.tier-card {
  background: var(--panel); border: 3px solid #4a3d78; padding: 14px 12px; cursor: pointer;
  text-align: center; transition: transform .08s; position: relative;
}
.tier-card:hover { transform: translateY(-4px); border-color: var(--gold); background: var(--panel-lite); }
.tier-card h2 { font-size: 22px; color: var(--text); margin-bottom: 4px; }
.tier-card .t-desc { font-size: 12px; color: var(--dim); margin-bottom: 8px; min-height: 30px; }
.tier-card .t-best { font-size: 12px; color: var(--gold); }
.tier-card .t-badge { font-size: 26px; display: block; margin-bottom: 4px; }

/* ================= 弹窗 ================= */
.modal { position: absolute; inset: 0; background: rgba(10, 6, 20, .72); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { width: min(560px, 92vw); padding: 22px; text-align: center; }
.quiz-type { font-size: 15px; color: var(--blue); font-weight: bold; letter-spacing: 2px; margin-bottom: 12px; }
#quiz-prompt { font-size: 34px; font-weight: bold; color: var(--gold); margin-bottom: 18px; text-shadow: 2px 2px 0 #000; word-break: break-all; }
#quiz-prompt .speak-btn { font-size: 20px; vertical-align: middle; }
#quiz-choices, #upgrade-choices { display: flex; flex-direction: column; gap: 10px; }
.choice-btn, .pixel-btn {
  font-family: inherit; font-size: 19px; font-weight: bold; color: var(--text);
  background: var(--panel-lite); border: 3px solid #4a3d78; padding: 12px; cursor: pointer;
  text-align: center; transition: background .08s;
}
.choice-btn:hover, .pixel-btn:hover { background: #45387a; border-color: var(--gold); }
.choice-btn.correct { background: #1f5c2d; border-color: var(--green); }
.choice-btn.wrong { background: #6b1f2a; border-color: var(--red); }
.choice-btn:disabled { cursor: default; opacity: .9; }
#quiz-feedback { margin-top: 14px; font-size: 17px; font-weight: bold; }
#quiz-feedback.good { color: var(--green); }
#quiz-feedback.bad { color: var(--red); }

.upg-btn { display: flex; align-items: center; gap: 14px; text-align: left; }
.upg-btn .upg-icon { font-size: 30px; }
.upg-btn .upg-name { font-size: 18px; color: var(--gold); }
.upg-btn .upg-desc { font-size: 13px; color: var(--dim); font-weight: normal; margin-top: 2px; }

.pixel-btn { padding: 12px 28px; }
.pixel-btn.alt { background: #3a2430; border-color: #7a4055; }
.btn-row { display: flex; gap: 14px; justify-content: center; margin-top: 10px; }

/* ================= 结算 ================= */
#over-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px;
  width: min(720px, 92vw);
}
#over-stats .st { background: var(--panel); border: 3px solid #4a3d78; padding: 10px; text-align: center; }
#over-stats .st b { display: block; font-size: 24px; color: var(--gold); }
#over-stats .st span { font-size: 12px; color: var(--dim); }
#over-stats .st.record b { color: var(--green); }
#over-words { width: min(720px, 92vw); background: var(--panel); border: 3px solid #4a3d78; padding: 12px; max-height: 30vh; overflow-y: auto; }
#over-words h3 { font-size: 15px; color: var(--blue); margin-bottom: 8px; }
#wrong-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wrong-item {
  background: var(--panel-lite); border: 2px solid #6b1f2a; padding: 5px 10px; font-size: 14px;
  cursor: pointer;
}
.wrong-item b { color: var(--gold); }
.wrong-item:hover { border-color: var(--red); }
.no-wrong { color: var(--green); font-size: 14px; }

/* ================= 菜单工具栏 / 新界面 ================= */
.menu-toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pixel-btn.tool { font-size: 14px; padding: 8px 14px; }

.panel-list {
  width: min(680px, 92vw); max-height: 46vh; overflow-y: auto;
  background: var(--panel); border: 3px solid #4a3d78; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.review-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-lite); padding: 8px 10px; border: 2px solid #4a3d78;
}
.review-item b { color: var(--gold); font-size: 17px; min-width: 110px; }
.review-item .r-zh { flex: 1; font-size: 14px; }
.review-item .r-n { font-size: 12px; color: var(--dim); }
.review-item .r-del { border-color: #7a4055; }

.stat-row { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.stat-row .s-name { min-width: 110px; font-weight: bold; font-size: 15px; }
.stat-row .s-bar { flex: 1; height: 16px; background: #120d22; border: 2px solid #000; position: relative; }
.stat-row .s-fill { position: absolute; inset: 0; width: 0; background: linear-gradient(#7ee8a0, #2ed96e); }
.stat-row .s-num { min-width: 76px; text-align: right; font-size: 13px; color: var(--gold); }

.achv-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-lite); padding: 8px 12px; border: 2px solid #4a3d78; opacity: .55;
}
.achv-item.done { opacity: 1; border-color: var(--gold); }
.achv-item .a-icon { font-size: 26px; }
.achv-item b { color: var(--text); font-size: 15px; }
.achv-item.done b { color: var(--gold); }
.achv-item .a-desc { font-size: 12px; color: var(--dim); }

/* 进化选项(金色) */
.upg-btn.evo { border-color: var(--gold); background: #4a3a12; }
.upg-btn.evo .upg-name { color: #ffe9a0; }
.upg-btn.evo:hover { background: #5c4a18; }

/* ================= Toast ================= */
#toasts {
  position: absolute; right: 14px; bottom: 14px; display: flex;
  flex-direction: column; gap: 8px; z-index: 40; pointer-events: none;
}
.toast {
  background: rgba(26, 20, 40, .95); border: 3px solid var(--gold); color: var(--gold);
  font-weight: bold; font-size: 15px; padding: 10px 16px;
  animation: toast-in .3s steps(6); box-shadow: 0 0 0 3px var(--ink);
}
.toast.out { transition: opacity .4s, transform .4s; opacity: 0; transform: translateX(30px); }
@keyframes toast-in { 0% { transform: translateX(60px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ================= 摇杆 ================= */
#joystick {
  position: absolute; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: 3px solid rgba(255,255,255,.25); z-index: 5;
  pointer-events: none;
}
#stick {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.35); left: 32px; top: 32px;
}

@media (max-width: 700px) {
  #hud-top-left { width: 140px; transform: scale(.8); transform-origin: top left; }
  #target-panel { font-size: 16px; top: 4px; padding: 5px 8px; gap: 6px; max-width: 52vw; }
  #target-panel .t-label { font-size: 14px; }
  #hud-top-right { transform: scale(.8); transform-origin: top right; }
  #quiz-prompt { font-size: 24px; }
  .modal-box { padding: 14px; }
  .choice-btn { font-size: 16px; padding: 12px 8px; }
  .upg-btn .upg-name { font-size: 15px; }
  .upg-btn .upg-desc { font-size: 12px; }
  #boss-panel { min-width: 0; width: 94vw; padding: 6px 8px; bottom: 8px; }
  #boss-spell { font-size: 18px; letter-spacing: 4px; }
  #boss-word-hint { font-size: 14px; }
  #combo { font-size: 15px; top: 56px; }
  #announce { font-size: 22px; width: 92vw; }
  .subtitle { font-size: 12px; letter-spacing: 1px; text-align: center; }
  .tip { font-size: 12px; }
  #tier-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tier-card { padding: 10px 6px; }
  .tier-card h2 { font-size: 17px; }
  .tier-card .t-badge { font-size: 20px; }
  .tier-card .t-desc { font-size: 10px; min-height: 24px; }
  .tier-card .t-best { font-size: 10px; }
  .pixel-btn.tool { font-size: 12px; padding: 8px 10px; }
  .screen { gap: 10px; padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); }
  .review-item b { min-width: 80px; font-size: 15px; }
  #over-stats .st b { font-size: 18px; }
  .toast { font-size: 12px; padding: 8px 10px; }
}
