* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  background: #0e1420; color: #fff; user-select: none;
}
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.rom { display: none; }
body.show-romaji .rom { display: block; }
button { font-family: inherit; cursor: pointer; }

/* loading */
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #0e1420; z-index: 100; font-size: 22px; letter-spacing: 2px; }

/* fade */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none;
  transition: opacity 0.45s; z-index: 40; }

/* HUD */
#hud { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; z-index: 20; }
.pill { background: rgba(14, 20, 32, 0.82); border: 2px solid rgba(255,255,255,0.25); border-radius: 999px;
  padding: 6px 14px; font-size: 16px; font-weight: 700; backdrop-filter: blur(4px); }
#scorePill { color: #ffd166; }
.hud-btns { margin-left: auto; display: flex; gap: 6px; }
.hbtn { width: 42px; height: 42px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.25);
  background: rgba(14,20,32,0.82); color: #fff; font-size: 17px; font-weight: 700; }
.hbtn:active { transform: scale(0.93); }

/* party bar */
#partyBar { position: fixed; top: 60px; left: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 20; }
.pslot { background: rgba(14,20,32,0.75); border-radius: 8px; padding: 3px 8px; font-size: 13px; display: flex;
  align-items: center; gap: 5px; border: 1px solid rgba(255,255,255,0.15); }
.pslot.ko { opacity: 0.45; }
.pdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.phb { width: 46px; height: 5px; background: #333; border-radius: 3px; overflow: hidden; }
.phb div { height: 100%; background: #5ecc62; }

/* hint */
#hint { position: fixed; bottom: 168px; left: 50%; transform: translateX(-50%);
  background: rgba(14,20,32,0.85); padding: 6px 16px; border-radius: 999px; font-size: 15px;
  border: 1px solid rgba(255,255,255,0.3); z-index: 20; }

/* dialogue / subtitles */
#dlg { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; width: min(720px, 94vw);
  background: rgba(10, 14, 26, 0.92); border: 2px solid rgba(255,255,255,0.35); border-radius: 16px;
  padding: 12px 18px 14px; z-index: 30; box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
#dlgSpeaker { font-size: 12px; color: #ffd166; font-weight: 700; min-height: 14px; }
#dlgJa { font-size: 21px; font-weight: 700; line-height: 1.45; }
#dlgRom { font-size: 13px; color: #9fd6f0; }
#dlgEn { font-size: 15px; color: #cfd8ea; margin-top: 2px; line-height: 1.35; }
#dlgNext { position: absolute; right: 14px; bottom: 8px; animation: bounce 0.8s infinite; color: #ffd166; }
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(4px);} }

/* battle */
#battlePanel { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
.moncard { position: absolute; background: rgba(10,14,26,0.9); border: 2px solid rgba(255,255,255,0.35);
  border-radius: 14px; padding: 10px 14px; min-width: 230px; pointer-events: auto; }
#enemyCard { top: 64px; right: 14px; }
#playerCard { top: 64px; left: 14px; }
.mc-name { font-size: 18px; font-weight: 700; }
.mc-name small { color: #9fd6f0; font-weight: 400; }
.mc-sub { font-size: 13px; color: #cfd8ea; margin: 3px 0 6px; }
.ebadge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; color: #10141f; font-weight: 700; }
.hpbar { height: 10px; background: #2a3245; border-radius: 6px; overflow: hidden; }
.hpfill { height: 100%; background: #5ecc62; transition: width 0.4s; }
.xpbar { height: 4px; background: #2a3245; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.xpfill { height: 100%; background: #9fd6f0; transition: width 0.4s; }
#battleMenu, #moveMenu { position: absolute; right: 14px; bottom: 130px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 8px; pointer-events: auto; width: min(400px, 92vw); }
#battleMenu button, #moveMenu button {
  background: linear-gradient(160deg, #223050, #16203a); color: #fff; border: 2px solid rgba(255,255,255,0.35);
  border-radius: 14px; padding: 12px 10px; font-size: 17px; font-weight: 700; text-align: left; }
#battleMenu button span, #moveMenu button span { display: block; font-size: 12px; color: #9fd6f0; font-weight: 400; }
#battleMenu button:disabled { opacity: 0.4; }
#battleMenu button:active, #moveMenu button:active { transform: scale(0.96); }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(4,6,12,0.65); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 12px; }
.mbox { background: #141c2e; border: 2px solid rgba(255,255,255,0.3); border-radius: 18px; padding: 18px;
  width: min(560px, 96vw); max-height: 88vh; overflow-y: auto; }
.mbox.wide { width: min(860px, 96vw); }
.mbox h2 { font-size: 20px; margin-bottom: 12px; }
.mbox h2 small { color: #9fd6f0; font-weight: 400; font-size: 14px; }
.closebtn { margin-top: 14px; width: 100%; padding: 10px; border-radius: 12px; border: none;
  background: #2a3a5c; color: #fff; font-size: 16px; font-weight: 700; }

/* quiz */
.q-ja { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.q-en { font-size: 14px; color: #9fd6f0; margin-bottom: 14px; }
#quizChoices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#quizChoices button { background: #1d2840; color: #fff; border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px; padding: 12px; font-size: 17px; font-weight: 700; }
#quizChoices button .rom { font-size: 12px; color: #9fd6f0; font-weight: 400; }
#quizChoices button.correct { background: #1d5c33; border-color: #5ecc62; }
#quizChoices button.wrong { background: #6b2330; border-color: #ff6b4a; }

/* dex */
#dexGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.dexcard { background: #1a2338; border: 2px solid #445; border-radius: 14px; padding: 12px; }
.dexcard.unknown { opacity: 0.55; text-align: center; }
.dx-kana { font-size: 20px; font-weight: 700; }
.dx-kanji { font-size: 14px; color: #ffd166; }
.dx-kanji .rom { display: inline; color: #9fd6f0; }
.dx-mean { font-size: 13px; color: #cfd8ea; margin: 2px 0 6px; }
.dx-flavor { font-size: 12px; color: #aab6cc; margin-top: 8px; line-height: 1.5; }
.dx-flavor i { color: #8fa0bd; }

/* missions */
.mission { display: flex; gap: 10px; padding: 10px; border-radius: 12px; background: #1a2338; margin-bottom: 8px; }
.mission.done { opacity: 0.6; }
.m-check { font-size: 20px; }
.m-ja { font-weight: 700; font-size: 16px; }
.m-en { font-size: 13px; color: #cfd8ea; }
.m-en b { color: #ffd166; }
.m-prog { font-size: 12px; color: #9fd6f0; margin-top: 2px; }

/* starter */
#starterCards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.starter { background: #1a2338; border: 3px solid #445; border-radius: 16px; padding: 14px 8px; color: #fff; }
.starter:active { transform: scale(0.95); }
@media (max-width: 560px) { #starterCards { grid-template-columns: 1fr; } }

/* title */
#title { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(10,14,30,0.5) 0%, rgba(10,14,30,0.85) 100%); text-align: center; }
.t-inner { padding: 20px; }
.t-petals { font-size: 22px; animation: bounce 2s infinite; }
#title h1 { font-size: clamp(46px, 12vw, 92px); letter-spacing: 4px; font-weight: 900;
  background: linear-gradient(180deg, #ffd166, #ff8fab); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; text-shadow: 0 4px 0 rgba(0,0,0,0.25); }
.t-sub { font-size: 18px; color: #9fd6f0; margin-top: 4px; font-weight: 700; }
.t-tag { font-size: 14px; color: #cfd8ea; margin: 14px 0 22px; line-height: 1.6; }
.t-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.bigbtn { background: linear-gradient(160deg, #ff8fab, #d2527f); border: none; color: #fff; font-size: 22px;
  font-weight: 900; padding: 14px 34px; border-radius: 999px; box-shadow: 0 6px 0 rgba(0,0,0,0.3); }
.bigbtn span { display: block; font-size: 12px; font-weight: 400; opacity: 0.9; }
.bigbtn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.3); }
#btnContinue { background: linear-gradient(160deg, #4aa8ff, #2a6fc0); }
.t-hint { margin-top: 26px; font-size: 12px; color: #8fa0bd; line-height: 1.7; }

/* touch */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 22; }
#joy { position: absolute; left: 22px; bottom: 120px; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.25); pointer-events: auto; touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; margin: -24px 0 0 -24px; width: 48px; height: 48px;
  border-radius: 50%; background: rgba(255,255,255,0.35); }
#btnA { position: absolute; right: 26px; bottom: 132px; width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255, 143, 171, 0.75); border: 3px solid rgba(255,255,255,0.5); color: #fff;
  font-size: 26px; font-weight: 900; pointer-events: auto; }

/* toasts */
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); display: flex;
  flex-direction: column; gap: 6px; z-index: 55; align-items: center; pointer-events: none; }
.toast { background: rgba(20, 28, 46, 0.95); border: 2px solid #ffd166; color: #ffd166; border-radius: 999px;
  padding: 8px 20px; font-size: 15px; font-weight: 700; opacity: 0; transform: translateY(-8px);
  transition: all 0.35s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.mission { border-color: #5ecc62; color: #5ecc62; }

@media (max-width: 700px) {
  #enemyCard, #playerCard { min-width: 160px; padding: 8px 10px; }
  .mc-name { font-size: 14px; }
  #playerCard { top: 60px; }
  #enemyCard { top: 60px; }
  #battleMenu, #moveMenu { bottom: 150px; }
  #dlgJa { font-size: 17px; }
  #dlgEn { font-size: 13px; }
}
