/* Blue Porcelain — style */
:root {
  --jiblue: #16283C;   /* 霁蓝 */
  --cobalt: #2B4A8B;   /* 钴蓝 */
  --tianqing: #88ABDA; /* 天青 */
  --yuebai: #D6E4F0;   /* 月白 */
  --tianbai: #F8F7F2;  /* 甜白 */
  --gold: #C9A063;     /* 描金 */
  --paper: #F2ECDF;
  --serif: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--jiblue);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.5), transparent 55%),
    radial-gradient(140% 110% at 50% 108%, rgba(43,74,139,.10), transparent 60%);
}
#app { height: 100dvh; display: flex; flex-direction: column; }

/* header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 4px;
}
#title { display: flex; align-items: baseline; gap: 10px; }
#title .zh { font-size: 30px; font-weight: 700; color: var(--cobalt); letter-spacing: 6px; }
#title .en { font-size: 15px; font-style: italic; color: var(--jiblue); opacity: .75; letter-spacing: 1px; }
#hud { display: flex; gap: 8px; }
.hbtn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--cobalt); background: var(--tianbai);
  font-size: 17px; color: var(--cobalt); cursor: pointer;
}
.hbtn:active { transform: scale(.92); }

/* level bar */
#levelbar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 2px 10px 8px; font-size: 14px; opacity: .9;
}
#lvlLabel { font-weight: 700; letter-spacing: .5px; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 15px; }
#pairLabel { opacity: .65; font-style: italic; }

/* board */
#boardWrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
#board { position: relative; }
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.tile {
  position: absolute; border-radius: 50%;
  cursor: pointer; z-index: 1;
  transition: transform .16s cubic-bezier(.34,1.45,.64,1), opacity .3s ease;
  will-change: transform;
  filter: drop-shadow(0 2px 3px rgba(22,40,60,.28));
}
.tile svg { display: block; width: 100%; height: 100%; }
.tile.sel {
  transform: scale(1.12) !important;
  filter: drop-shadow(0 0 8px rgba(43,74,139,.65)) drop-shadow(0 2px 3px rgba(22,40,60,.3));
  z-index: 3;
}
.tile.hinted { animation: hintPulse 0.9s ease-in-out 2; }
@keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.tile.gone { transform: scale(.15) rotate(40deg) !important; opacity: 0; pointer-events: none; z-index: 0; }
.tile.shake { animation: shakeX .3s ease; }
@keyframes shakeX { 0%,100% { margin-left: 0; } 25% { margin-left: -5px; } 75% { margin-left: 5px; } }

/* footer */
footer { display: flex; justify-content: center; gap: 14px; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.fbtn {
  font-family: var(--serif); font-size: 15px; color: var(--cobalt);
  background: var(--tianbai); border: 1.5px solid var(--cobalt);
  border-radius: 22px; padding: 9px 18px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(43,74,139,.25);
}
.fbtn:active { transform: translateY(2px); box-shadow: none; }
.fbtn em { font-style: normal; font-weight: 700; }
.fbtn:disabled { opacity: .4; pointer-events: none; }

/* overlay */
#overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(16,28,54,.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
#overlay.hidden, #toast.hidden { display: none; }
#ovCard {
  background: var(--tianbai); border-radius: 14px; max-width: 420px; width: 100%;
  max-height: 86dvh; overflow: auto; padding: 22px 20px;
  border: 1px solid var(--yuebai);
  box-shadow: 0 18px 50px rgba(10,20,40,.45);
  animation: cardIn .32s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cardIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#ovCard h2 { text-align: center; color: var(--cobalt); font-size: 22px; margin-bottom: 4px; }
#ovCard .sub { text-align: center; font-style: italic; opacity: .7; font-size: 13px; margin-bottom: 14px; }
#lvGrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.lvbtn {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--cobalt);
  background: #fff; color: var(--cobalt); font-family: var(--serif);
  font-size: 16px; font-weight: 700; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.lvbtn .lvstars { font-size: 8.5px; color: var(--gold); letter-spacing: 0; line-height: 1; margin-top: 2px; }
.lvbtn.locked { border-color: #A8B4C6; color: #A8B4C6; background: #EEF1F5; pointer-events: none; }
.lvbtn:not(.locked):active { transform: scale(.93); }
.lvbtn.next { box-shadow: 0 0 0 2.5px var(--gold); }

/* win card */
.bigstars { text-align: center; font-size: 42px; color: var(--gold); letter-spacing: 8px; margin: 6px 0 2px; }
.bigstars .dim { color: #C9CFD8; }
.fact {
  margin: 12px 0; padding: 12px 14px; border-radius: 10px;
  background: linear-gradient(160deg, #fff, var(--yuebai));
  border: 1px solid var(--yuebai);
  font-size: 14px; line-height: 1.5; color: var(--jiblue);
}
.fact b { color: var(--cobalt); }
.ovbtns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(22,40,60,.88); color: #fff; font-size: 14px;
  padding: 8px 18px; border-radius: 20px; z-index: 30;
  animation: toastIn 2.4s ease forwards; pointer-events: none;
}
@keyframes toastIn { 0% { opacity: 0; transform: translate(-50%, 8px); } 12%,80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -6px); } }

@media (max-width: 380px) {
  #title .zh { font-size: 24px; letter-spacing: 4px; }
  #title .en { font-size: 12px; }
  .fbtn { font-size: 13px; padding: 8px 14px; }
}
