/* ===========================================================
   數學冒險島 — ui.css
   按鈕、資訊列、面板、彈窗、開關
   =========================================================== */

/* ---------------- Kenney 白色圖示要染色才看得見 ---------------- */
/* assets/icons/* 全是白色剪影，放在淺色底上會隱形，這裡統一壓成深色 */
img[src^="assets/icons/"] {
  filter: brightness(0) saturate(100%) opacity(.62);
}
/* 深色底上的按鈕（例如大按鈕）另外覆寫成全白，見下方 .big-btn 規則 */
/* Kenney 的 UI 星星是藍色的，轉成金色才像「獎勵」 */
img[src$="ui/star.png"] { filter: hue-rotate(205deg) saturate(1.55) brightness(1.04); }

/* ---------------- 頂部資訊列 ---------------- */
.hud {
  position: relative; z-index: 20;
  height: var(--hud-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  overflow: hidden;                 /* 不要讓資訊列把整個版面撐寬 */
  background: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .72));
  border-bottom: 4px solid rgba(47, 63, 94, .12);
  box-shadow: 0 6px 18px rgba(20, 50, 90, .14);
  backdrop-filter: blur(6px);
}
.hud-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hud-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.hud-brand { display: flex; align-items: center; gap: 10px; }
.hud-brand-img { width: 46px; height: 46px; object-fit: contain; animation: floatY 3s ease-in-out infinite; }
.hud-brand-text {
  font-size: 26px; font-weight: 800; color: #fff;
  text-shadow: 0 3px 0 #3aa0d8, 0 6px 10px rgba(0, 60, 110, .3);
  letter-spacing: .04em;
}
.hud-world { min-width: 0; }
.hud-world-name {
  font-family: var(--font-cn); font-size: 20px; font-weight: 800; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw;
}
.hud-world-sub { font-size: 13px; color: var(--ink-soft); }

.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform .12s ease, box-shadow .12s ease;
}
.icon-btn img { width: 26px; height: 26px; object-fit: contain; opacity: .78; }
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.icon-btn:active, .icon-btn.is-press { transform: translateY(1px); box-shadow: var(--sh-1); }

/* 「回主頁」按鈕（地圖、自由練習、貼紙簿、家長區） */
.nav-back {
  display: inline-flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
  height: 52px; padding: 0 20px 0 14px; border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #eaf3ff);
  box-shadow: var(--sh-1);
  border: 3px solid rgba(255, 255, 255, .9);
  font-size: 19px; font-weight: 800; color: var(--ink);
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease;
}
.nav-back-ico { width: 26px; height: 26px; object-fit: contain; }
.nav-back:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.nav-back:active, .nav-back.is-press { transform: translateY(1px); box-shadow: var(--sh-1); }

.pill {
  display: flex; align-items: center; gap: 7px;
  height: 44px; padding: 0 16px 0 12px; border-radius: 999px;
  background: #fff; box-shadow: var(--sh-1);
  font-size: 20px; font-weight: 700;
}
.pill img { width: 26px; height: 26px; object-fit: contain; }
.pill-coins { color: #b1670a; background: linear-gradient(180deg, #fff8dd, #ffe9a8); }
.pill-stars { color: #8a5a00; background: linear-gradient(180deg, #fffbe8, #ffeeb8); }

/* ---------------- 心心（生命） ---------------- */
.hud-hearts { display: flex; align-items: center; gap: 3px; margin-left: 2px; flex: 0 0 auto; }
.heart {
  width: 30px; height: 30px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 30'%3E%3Cpath d='M16 28.5C16 28.5 1.5 19.4 1.5 10.8C1.5 5.6 5.7 1.5 10.7 1.5C13.4 1.5 15.2 2.7 16 3.9C16.8 2.7 18.6 1.5 21.3 1.5C26.3 1.5 30.5 5.6 30.5 10.8C30.5 19.4 16 28.5 16 28.5Z' fill='%23ff5f8a' stroke='%23ffffff' stroke-width='3'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform .22s cubic-bezier(.2, 1.5, .5, 1), filter .22s ease;
  filter: drop-shadow(0 2px 0 rgba(180, 40, 80, .35));
}
.heart.is-empty { filter: grayscale(1) opacity(.32); transform: scale(.86); }
.heart img { display: none; }
.heart.is-infinite {
  width: auto; padding: 0 12px; gap: 6px; background: #f2e8ff; border-radius: 999px; height: 32px;
  display: flex; align-items: center;
  background-image: none;
  filter: none;
}
.heart.is-infinite::before {
  content: ''; width: 20px; height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 30'%3E%3Cpath d='M16 28.5C16 28.5 1.5 19.4 1.5 10.8C1.5 5.6 5.7 1.5 10.7 1.5C13.4 1.5 15.2 2.7 16 3.9C16.8 2.7 18.6 1.5 21.3 1.5C26.3 1.5 30.5 5.6 30.5 10.8C30.5 19.4 16 28.5 16 28.5Z' fill='%23ff5f8a'/%3E%3C/svg%3E") center/contain no-repeat;
}
.heart.is-infinite img { display: none; }
.hud-hearts-text { font-size: 14px; color: #6b35b8; font-weight: 700; white-space: nowrap; }

/* ---------------- 進度點 ---------------- */
.hud-progress { display: flex; align-items: center; gap: 7px; margin: 0 auto; }
.pdot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(47, 63, 94, .18);
  transition: all .25s ease;
}
.pdot.is-ok { background: var(--green); box-shadow: 0 0 0 3px rgba(75, 200, 106, .25); }
.pdot.is-bad { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 107, .22); }
.pdot.is-now { width: 32px; border-radius: 8px; background: var(--gold); animation: pulse 1.1s ease-in-out infinite; }

/* ---------------- 大按鈕 ---------------- */
.big-btn {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #ffffff, #eaf3ff);
  box-shadow: var(--sh-2);
  font-size: 26px; font-weight: 800; color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
  border: 3px solid rgba(255, 255, 255, .9);
  text-align: left;
}
.big-btn:hover { transform: translateY(-3px) scale(1.015); }
.big-btn:active, .big-btn.is-press { transform: translateY(2px); box-shadow: var(--sh-1); }
.big-btn-ico {
  width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 14px;
  background: rgba(255, 255, 255, .75);
}
.big-btn-ico img { width: 26px; height: 26px; object-fit: contain; }
.big-btn-label { flex: 1; }

.big-btn.tone-primary { background: linear-gradient(180deg, #6fc6ff, #2f95e8); color: #fff; text-shadow: 0 2px 0 rgba(0, 70, 130, .35); }
.big-btn.tone-primary .big-btn-ico { background: rgba(255, 255, 255, .3); }
.big-btn.tone-primary .big-btn-ico img { filter: brightness(0) invert(1); }
.big-btn.tone-sun { background: linear-gradient(180deg, #ffe17a, #ffb933); color: #7a4800; text-shadow: 0 2px 0 rgba(255, 255, 255, .5); }
.big-btn.tone-grape { background: linear-gradient(180deg, #c9aaff, #9b6ef0); color: #fff; text-shadow: 0 2px 0 rgba(70, 20, 130, .3); }
.big-btn.tone-grape .big-btn-ico img { filter: brightness(0) invert(1); }
.big-btn.tone-mint { background: linear-gradient(180deg, #86ebd3, #35c6a8); color: #fff; text-shadow: 0 2px 0 rgba(0, 90, 70, .3); }
.big-btn.tone-mint .big-btn-ico img { filter: brightness(0) invert(1); }

/* ---------------- 一般按鈕 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 26px; border-radius: 999px;
  font-size: 20px; font-weight: 800;
  background: linear-gradient(180deg, #ffffff, #e8f1fb);
  box-shadow: var(--sh-1);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  border: 3px solid rgba(255, 255, 255, .85);
  color: var(--ink);
  text-decoration: none;
}
.btn.is-big { padding: 17px 40px; font-size: 24px; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.btn:active, .btn.is-press { transform: translateY(1px); box-shadow: var(--sh-1); }
.btn-primary { background: linear-gradient(180deg, #8fd4ff, #3098ea); color: #fff; text-shadow: 0 2px 0 rgba(0, 70, 130, .3); }
.btn-sun { background: linear-gradient(180deg, #ffe386, #ffb629); color: #7a4400; }
.btn-mint { background: linear-gradient(180deg, #8ceccf, #2fc4a4); color: #fff; text-shadow: 0 2px 0 rgba(0, 90, 70, .28); }
.btn-grape { background: linear-gradient(180deg, #cbb0ff, #9a6cf0); color: #fff; text-shadow: 0 2px 0 rgba(70, 20, 130, .28); }
.btn-ghost { background: rgba(255, 255, 255, .82); color: var(--ink-soft); }
.btn-danger { background: linear-gradient(180deg, #ff9c9c, #e84b47); color: #fff; }

.mini-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 16px; border-radius: 999px;
  font-size: 17px; font-weight: 800;
  background: #fff; box-shadow: var(--sh-1);
  transition: transform .12s ease;
  border: 2px solid rgba(255, 255, 255, .9);
  color: var(--ink);
}
.mini-btn:active { transform: translateY(1px); }
.mini-btn.tone-primary { background: linear-gradient(180deg, #8fd4ff, #3098ea); color: #fff; }
.mini-btn.tone-sun { background: linear-gradient(180deg, #ffe386, #ffb629); color: #7a4400; }
.mini-btn.tone-mint { background: linear-gradient(180deg, #8ceccf, #2fc4a4); color: #fff; }
.mini-btn img { width: 18px; height: 18px; object-fit: contain; }
.mini-ico { width: 18px !important; height: 18px !important; }

/* ---------------- 彈窗 ---------------- */
.overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.overlay .modal { pointer-events: auto; }
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(20, 40, 70, .45);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .22s ease;
  padding: 20px;
  z-index: 100;
}
.modal.is-in { opacity: 1; }
.modal-box {
  width: min(560px, 94vw);
  max-height: 90vh; overflow: auto;
  background: var(--paper);
  border-radius: var(--r-xl);
  padding: 26px 26px 22px;
  box-shadow: var(--sh-2), 0 0 0 6px rgba(255, 255, 255, .7);
  transform: scale(.88) translateY(16px);
  transition: transform .28s cubic-bezier(.2, 1.4, .5, 1);
  border: 4px solid rgba(255, 255, 255, .9);
}
.modal.is-wide .modal-box { width: min(760px, 95vw); }
.modal.is-in .modal-box { transform: scale(1) translateY(0); }
.modal-title {
  font-size: 27px; font-weight: 800; text-align: center; color: var(--ink);
  margin-bottom: 14px;
}
.modal-text { font-size: 19px; line-height: 1.75; text-align: center; color: var(--ink-soft); }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
  margin-top: 20px;
}

/* ---------------- 開關 ---------------- */
.switch {
  width: 66px; height: 36px; border-radius: 999px; flex: 0 0 auto;
  background: #d7e2ee; position: relative; transition: background .2s ease;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .12);
}
.switch-knob {
  position: absolute; top: 4px; left: 4px; width: 28px; height: 28px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
  transition: left .2s cubic-bezier(.2, 1.4, .5, 1);
}
.switch.is-on { background: linear-gradient(180deg, #7fe0a8, #35c069); }
.switch.is-on .switch-knob { left: 34px; }

/* ---------------- 卡片 ---------------- */
.pcard {
  background: rgba(255, 255, 255, .95);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-1);
  border: 3px solid rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; gap: 8px;
}
.pcard-title {
  font-size: 21px; font-weight: 800; color: var(--ink);
  padding-bottom: 8px; margin-bottom: 2px;
  border-bottom: 3px dashed rgba(47, 63, 94, .14);
}
.prow {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  font-size: 17px; color: var(--ink-soft); padding: 4px 0; line-height: 1.5;
}
.prow-k { flex: 0 1 auto; }
.prow-v { font-weight: 800; color: var(--ink); text-align: right; }
.prow-wrong { flex-direction: column; align-items: flex-start; gap: 4px; background: #fff2f2; border-radius: 12px; padding: 8px 12px; }
.prow-wrong-q { font-size: 16px; color: #9c3b3b; font-weight: 700; }
.prow-wrong-c { font-size: 14px; color: #c96a6a; }
.prow-note { color: var(--ink-soft); font-size: 15px; }
.prow-input {
  font-family: inherit; font-size: 17px; padding: 8px 14px; border-radius: 999px;
  border: 3px solid #d7e2ee; outline: none; width: 160px; text-align: center;
  color: var(--ink); background: #fff;
}
.prow-input:focus { border-color: var(--blue); }

.parent-gate { display: flex; justify-content: center; }
.settings { display: flex; flex-direction: column; gap: 6px; }

/* ---------------- 頁面標題 ---------------- */
.page-head { text-align: center; padding: 22px 0 12px; }
.page-title {
  font-size: 40px; font-weight: 800; color: #fff;
  text-shadow: 0 4px 0 #3aa0d8, 0 10px 20px rgba(0, 60, 110, .32);
  letter-spacing: .06em;
}
.page-sub { font-size: 17px; color: #17608c; margin-top: 6px; font-weight: 700; }

.empty { text-align: center; color: var(--ink-soft); font-size: 18px; padding: 30px; }

/* ===========================================================
   窄螢幕（小筆電 / 分割視窗）的資訊列微調
   =========================================================== */
@media (max-width: 980px) {
  .hud { gap: 9px; padding: 0 12px; }
  .hud-left { gap: 8px; }
  .hud-brand { gap: 6px; }
  .hud-brand-img { width: 36px; height: 36px; }
  .hud-brand-text { font-size: 21px; }
  .hud-world-name { font-size: 17px; max-width: 26vw; }
  .hud-world-sub { display: none; }
  .hud-hearts { gap: 1px; }
  .heart { width: 24px; height: 24px; }
  .hud-progress { gap: 4px; margin: 0 6px; }
  .pdot { width: 10px; height: 10px; }
  .pdot.is-now { width: 22px; border-radius: 6px; }
  .hud-right { gap: 6px; }
  .pill { height: 38px; padding: 0 12px 0 9px; font-size: 17px; gap: 5px; }
  .pill img { width: 22px; height: 22px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn img { width: 22px; height: 22px; }
  .nav-back { height: 44px; padding: 0 16px 0 11px; font-size: 17px; gap: 6px; }
  .nav-back-ico { width: 22px; height: 22px; }
  .hud-hearts-text { font-size: 13px; }
}

@media (max-width: 700px) {
  .hud-world-name { max-width: 30vw; }
  .hud-progress { gap: 3px; margin: 0 2px; }
  .pdot { width: 8px; height: 8px; }
  .pill { height: 34px; font-size: 15px; padding: 0 9px 0 7px; }
  .pill img { width: 18px; height: 18px; }
  .icon-btn { width: 38px; height: 38px; }
  .heart { width: 20px; height: 20px; }
  /* 空間不夠時「回主頁」只留箭頭 */
  .nav-back { padding: 0 10px; }
  .nav-back-label { display: none; }
}

/* 很窄的手機：留給「回主頁」與金幣星星，把品牌文字收起來 */
@media (max-width: 520px) {
  .hud-brand-text { display: none; }
  .hud { gap: 7px; padding: 0 10px; }
}
