:root {
  --blue: #2f6fd6; --blue2: #1f4fa8; --red: #e8483b; --yellow: #ffd23f; --green: #34b36a;
  --ink: #26314a; --soft: #f4f7ff; --card: #fff; --line: #dfe6f5;
  --r: 18px; --shadow: 0 6px 18px rgba(30, 50, 100, .14);
  --font: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: linear-gradient(180deg, #8fd0ff, #d8f1ff 60%, #eafbe0); background-attachment: fixed; font-size: clamp(16px, 1.9vw, 20px); overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; font-size: inherit; touch-action: manipulation; }
input { font-family: inherit; }
img { -webkit-user-drag: none; }
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.loading { margin: auto; font-size: 28px; color: #fff; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.btn { padding: 12px 22px; border-radius: 14px; background: #e9eef9; font-size: 1.05em; box-shadow: 0 3px 0 #c9d3ea; transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9d3ea; }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 3px 0 #b3322a; }
.btn.big { font-size: 1.25em; padding: 14px 30px; }
.btn.small { padding: 8px 14px; font-size: .9em; }
.btn.ghost { background: rgba(255, 255, 255, .18); color: #fff; box-shadow: none; }
.btn[disabled] { opacity: .45; }
.row { display: flex; gap: 12px; justify-content: space-between; margin-top: 18px; }
.sec { margin: 22px 4px 10px; font-size: 1.15em; font-weight: normal; }
.sec small { font-size: .7em; color: #5a6784; }
.type { display: inline-block; color: #fff; font-size: .72em; padding: 2px 9px; border-radius: 99px; margin: 2px; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.expbar { height: 8px; background: #e4e9f5; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.expbar i { display: block; height: 100%; background: linear-gradient(90deg, #4fc3ff, #2f6fd6); border-radius: 99px; }
.seg { display: inline-flex; background: #e8edf8; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { padding: 8px 16px; border-radius: 9px; }
.seg button.on { background: #fff; color: var(--blue); box-shadow: 0 2px 6px rgba(0, 0, 0, .1); }

/* ---- 상단/하단 바 ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .15); }
.top .me { display: flex; align-items: center; gap: 8px; }
.top .me svg { background: #fff; border-radius: 50%; height: 44px; width: 44px; }
.top .goal { flex: 1; position: relative; height: 26px; background: rgba(255, 255, 255, .25); border-radius: 99px; overflow: hidden; max-width: 420px; }
.top .goal i { position: absolute; inset: 0 auto 0 0; background: var(--yellow); border-radius: 99px; transition: width .4s; }
.top .goal span { position: relative; z-index: 1; display: block; text-align: center; line-height: 26px; font-size: .85em; color: var(--ink); }
.top .res { display: flex; gap: 12px; margin-left: auto; }
.top .res span { display: flex; align-items: center; gap: 3px; }
.top .res img { height: 22px; }
.nav { position: sticky; bottom: 0; z-index: 20; display: flex; background: #fff; box-shadow: 0 -3px 12px rgba(0, 0, 0, .1); padding-bottom: env(safe-area-inset-bottom); margin-top: auto; }
.nav button { flex: 1; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; font-size: .9em; color: #7b87a3; }
.nav button span { font-size: 1.6em; }
.nav button.on { color: var(--blue); }
main { padding: 12px 16px 20px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---- 타이틀 ---- */
.screen-title { background: radial-gradient(circle at 50% 30%, #6fb8ff, #2f6fd6 70%); }
.title-wrap { margin: auto; padding: 30px 16px; text-align: center; width: 100%; max-width: 760px; }
.logo .l1 { font-size: clamp(54px, 10vw, 96px); color: var(--yellow); -webkit-text-stroke: 3px #1f4fa8; text-shadow: 0 6px 0 #1f4fa8, 0 10px 18px rgba(0, 0, 0, .3); letter-spacing: 2px; animation: bob 2.4s ease-in-out infinite; }
.logo .l2 { color: #fff; font-size: 1.3em; margin-top: 6px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 40px; }
.profile { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); padding: 12px 18px; box-shadow: var(--shadow); text-align: left; font-size: 1.1em; }
.profile small { display: block; color: #6c7894; font-size: .8em; }
.profile.new { border: 3px dashed #bcd0f5; background: #f5f9ff; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---- 만들기 ---- */
.create { margin: 24px auto; width: min(94%, 860px); text-align: center; }
.create h2 { font-weight: normal; margin-top: 0; }
.create input { font-size: 1.6em; padding: 14px; width: min(100%, 380px); border-radius: 14px; border: 3px solid var(--line); text-align: center; margin: 20px 0; }
.av-edit { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.av-prev { background: radial-gradient(circle, #eaf4ff, #cfe3ff); border-radius: 50%; width: 230px; height: 230px; display: grid; place-items: center; }
.av-opts { flex: 1; min-width: 300px; text-align: left; }
.opt { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.opt > span { width: 80px; flex: none; color: #5a6784; }
.opt > div { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.sw.on { box-shadow: 0 0 0 3px var(--blue); }
.chip { padding: 7px 12px; border-radius: 10px; background: #eef2fa; }
.chip.on { background: var(--blue); color: #fff; }
.imgopt { width: 60px; height: 70px; border-radius: 10px; background: #eef2fa; padding: 3px; }
.imgopt img { width: 100%; height: 100%; object-fit: contain; }
.imgopt.on { outline: 3px solid var(--blue); }
.starters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.starter { background: #f4f7ff; border-radius: 16px; padding: 10px; border: 3px solid transparent; transition: transform .15s; }
.starter img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.starter b { display: block; font-size: 1.15em; font-weight: normal; }
.starter.on { border-color: var(--red); background: #fff1ef; transform: scale(1.04); }

/* ---- 모험 메인 ---- */
.hero { display: flex; gap: 18px; flex-wrap: wrap; align-items: stretch; }
.partner-box { display: flex; align-items: center; gap: 10px; background: linear-gradient(135deg, #fff7d6, #ffe7a3); border-radius: 16px; padding: 10px 16px; min-width: 250px; cursor: pointer; }
.partner-box img { width: 110px; height: 110px; object-fit: contain; animation: bob 2.6s ease-in-out infinite; }
.partner-box b { font-size: 1.3em; font-weight: normal; }
.partner-box > div { flex: 1; }
.today { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 6px; }
.today .t-h { color: #5a6784; }
.today b { font-weight: normal; color: var(--blue); }
.today .seg { margin-top: auto; align-self: flex-start; }
.routes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.route { position: relative; height: 150px; border-radius: var(--r); overflow: hidden; text-align: left; padding: 14px; color: #fff; background: var(--bg) center/cover, linear-gradient(160deg, var(--c1), var(--c2)); box-shadow: var(--shadow); text-shadow: 0 2px 4px rgba(0, 0, 0, .35); display: flex; flex-direction: column; transition: transform .1s; }
.route:active { transform: scale(.97); }
.route b { font-size: 1.5em; font-weight: normal; }
.route .rc { margin-top: auto; background: rgba(0, 0, 0, .28); align-self: flex-start; padding: 3px 10px; border-radius: 99px; font-size: .85em; }
.route.lock { filter: grayscale(.8) brightness(.8); }

/* ---- 풀숲 ---- */
.field { flex: 1; max-width: none; display: flex; flex-direction: column; background: var(--bg) center/cover, linear-gradient(180deg, var(--c1), var(--c2)); position: relative; overflow: hidden; }
.field-h { display: flex; align-items: center; gap: 14px; color: #fff; font-size: 1.4em; text-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.field-tip { text-align: center; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .35); font-size: 1.2em; }
.tufts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4vmin; width: min(92%, 720px); margin: 10px auto; flex: 1; align-content: center; }
.tuft { font-size: clamp(60px, 11vmin, 110px); animation: sway 2.2s ease-in-out infinite; animation-delay: var(--d); filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .15)); }
.tuft.rustle { animation: rustle .12s linear infinite; }
@keyframes sway { 50% { transform: rotate(-5deg) scale(1.03); } }
@keyframes rustle { 0% { transform: translateX(-6px) rotate(-8deg); } 50% { transform: translateX(6px) rotate(8deg); } 100% { transform: translateX(-6px) rotate(-8deg); } }
.field-me { position: absolute; left: 20px; bottom: 16px; display: flex; align-items: flex-end; }
.field-partner { width: 90px; margin-left: -10px; animation: bob 1.8s ease-in-out infinite; }
.field.flash { animation: flash .7s steps(2) 1; }
@keyframes flash { 0%, 100% { filter: none; } 50% { filter: invert(1) brightness(2); } }

/* ---- 배틀 ---- */
.screen-route .top, .screen-route .nav { display: none; }
.battle, .raid { flex: 1; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.battle { background: var(--bg) center/cover, linear-gradient(180deg, var(--c1), var(--c2) 55%, #f7f3e3 55%); }
.arena { position: relative; flex: 1; min-height: 0; }
.mon { position: absolute; height: min(64%, 300px); max-width: 34vw; aspect-ratio: 1; }
.mon img { position: relative; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .25)); }
.mon .plat { position: absolute; left: 5%; right: 5%; bottom: 2%; height: 22%; background: radial-gradient(ellipse, rgba(60, 120, 40, .55), rgba(60, 120, 40, 0) 70%); border-radius: 50%; }
.mon.foe { right: 6%; top: 4%; }
.mon.me { left: 5%; bottom: 0; }
.mon.me img { transform: scaleX(-1); }
.mon.foe img.appear { animation: appear .6s ease-out; }
@keyframes appear { from { transform: translateX(60vw); filter: brightness(0); } 70% { filter: brightness(0); } }
.hpbox { position: absolute; background: rgba(255, 255, 255, .94); border-radius: 14px; padding: 8px 14px; box-shadow: var(--shadow); min-width: 230px; }
.hpbox b { font-weight: normal; font-size: 1.2em; }
.hpbox.foe { left: 4%; top: 6%; }
.hpbox.me { right: 4%; bottom: 14%; }
.hpbox .got { height: 18px; vertical-align: middle; }
.newtag { font-style: normal; background: var(--red); color: #fff; font-size: .7em; padding: 1px 7px; border-radius: 6px; }
.hp { height: 12px; background: #dde3ef; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.hp i { display: block; height: 100%; background: #3ccf6e; transition: width .6s; }
.hp i.mid { background: #f4c01e; } .hp i.low { background: #ef4b3c; }
.hearts { font-size: 1.2em; letter-spacing: 1px; }
.msg { position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%); background: rgba(38, 49, 74, .85); color: #fff; padding: 8px 18px; border-radius: 12px; font-size: 1.1em; max-width: 90%; text-align: center; }
.msg b { color: var(--yellow); font-weight: normal; }
.lunge { animation: lunge .35s ease-out; }
@keyframes lunge { 50% { transform: translate(18%, -12%) scaleX(-1) scale(1.08); } }
.mon.foe img.lunge-foe { animation: lungefoe .3s; }
@keyframes lungefoe { 50% { transform: translate(-18%, 12%) scale(1.08); } }
.mon img.hurt { animation: hurt .45s steps(2) 1; }
.mon.me img.hurt { animation: hurtme .45s steps(2) 1; }
@keyframes hurt { 0%, 100% { opacity: 1; } 25%, 75% { opacity: .2; } 50% { transform: translateX(10px); } }
@keyframes hurtme { 0%, 100% { opacity: 1; transform: scaleX(-1); } 25%, 75% { opacity: .2; transform: scaleX(-1); } 50% { transform: scaleX(-1) translateX(10px); } }
.shake { animation: shake .35s; }
.bigshake { animation: shake .5s 2; }
@keyframes shake { 20% { transform: translate(-8px, 4px); } 40% { transform: translate(8px, -4px); } 60% { transform: translate(-6px, -2px); } 80% { transform: translate(6px, 3px); } }
.fx { position: absolute; font-size: 90px; transform: translate(-50%, -50%); animation: fx .9s ease-out forwards; pointer-events: none; z-index: 5; }
@keyframes fx { from { transform: translate(-50%, -50%) scale(.3); opacity: 1; } to { transform: translate(-50%, -50%) scale(2.2); opacity: 0; } }
.thrown { position: absolute; width: 44px; height: 44px; left: 12%; bottom: 30%; z-index: 6; animation: throw .65s cubic-bezier(.3, -.4, .6, 1) forwards; image-rendering: pixelated; }
@keyframes throw { to { left: var(--tx); top: var(--ty); bottom: auto; transform: rotate(720deg); } }
.thrown.wiggle { animation: none; left: var(--tx); top: var(--ty); animation: wiggle .5s; }
.thrown.locked { left: var(--tx); top: var(--ty); animation: none; filter: brightness(.7); }
@keyframes wiggle { 25% { transform: rotate(-25deg); } 75% { transform: rotate(25deg); } }
.mon.foe img.sucked { transform: scale(0); filter: brightness(3); transition: .45s; }

/* ---- 문제 패널 ---- */
.panel { background: #fffdf5; border-top: 5px solid #ffd23f; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); position: relative; min-height: 34vh; flex: none; overflow: auto; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 900px; margin: 10px auto; }
.act { padding: 18px; border-radius: 18px; font-size: 1.35em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff; box-shadow: 0 5px 0 rgba(0, 0, 0, .2); }
.act small { font-size: .6em; opacity: .9; }
.act img { height: 28px; vertical-align: middle; }
.act.atk { background: linear-gradient(135deg, #ff7a59, #e8483b); }
.act.ball { background: linear-gradient(135deg, #58a6ff, #2f6fd6); }
.act.run { grid-column: 1 / -1; background: #a3adc2; font-size: 1.05em; padding: 10px; }
.act[disabled] { opacity: .5; }
.q { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1fr minmax(280px, 380px); grid-template-areas: "timer timer" "tag tag" "body input"; gap: 6px 20px; align-items: start; }
.q.k-choice { grid-template-columns: 1fr; grid-template-areas: "timer" "tag" "body" "input"; }
.qtimer { grid-area: timer; height: 10px; background: #e6e9f2; border-radius: 99px; overflow: hidden; }
.qtimer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #3ccf6e, #9be15d); border-radius: 99px; transition: width .1s linear; }
.qtimer i.hurry { background: linear-gradient(90deg, #ef4b3c, #ff9a3c); animation: pulse .5s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.qtag { grid-area: tag; color: #7a86a3; font-size: .85em; }
.qtag .rev { color: var(--red); font-weight: normal; }
.qbody { grid-area: body; }
.qtext { font-size: clamp(22px, 3.1vw, 32px); line-height: 1.55; word-break: keep-all; }
.qbig { font-size: clamp(34px, 5vw, 54px); color: var(--blue); margin: 8px 0; text-align: center; letter-spacing: 1px; }
.spk { font-size: .6em; background: #eaf2ff; border-radius: 12px; padding: 4px 10px; vertical-align: middle; }
.spk.big { font-size: .5em; padding: 10px 20px; }
.dialog { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; font-size: 1.3em; }
.bub { padding: 10px 16px; border-radius: 16px; max-width: 90%; }
.bub.a { background: #e8f1ff; align-self: flex-start; }
.bub.b { background: #fff1d6; align-self: flex-end; }
.qpic { display: flex; justify-content: center; }
.pic { margin: 6px auto; max-width: 420px; width: 100%; }
.pic.groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 28px; }
.grp { border: 3px dashed #c7cfe2; border-radius: 12px; padding: 2px 6px; }
.grp.sel { border-color: var(--red); background: #fff0ee; }
.picto { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.picto .pt { text-align: center; margin-bottom: 6px; }
.picto table { width: 100%; border-collapse: collapse; }
.picto th { font-weight: normal; width: 72px; text-align: center; border-right: 2px solid var(--line); padding: 4px; white-space: nowrap; }
.picto td { padding: 4px 8px; border-bottom: 1px solid #eef1f7; }
.pb { font-size: 30px; } .ps { font-size: 16px; }
.picto .pl { text-align: right; font-size: .85em; margin-top: 6px; color: #5a6784; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 4px; line-height: 1.05; font-size: .9em; }
.frac > span:first-child { border-bottom: 3px solid currentColor; padding: 0 4px; }
.mixed { display: inline-flex; align-items: center; }
.qinput { grid-area: input; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.n5 { grid-template-columns: repeat(5, 1fr); }
.choices.n3 { grid-template-columns: repeat(3, 1fr); }
.choice { background: #fff; border: 3px solid #d7deef; border-radius: 16px; padding: 14px 10px; font-size: clamp(20px, 2.6vw, 28px); min-height: 70px; box-shadow: 0 4px 0 #d7deef; }
.choice:active { transform: translateY(2px); }
.q.right .choice.picked { background: #dcffe6; border-color: var(--green); }
.q.wrong .choice.picked { background: #ffe1de; border-color: var(--red); }
.q.wrong .choice.is-answer { border-color: var(--green); background: #effff3; }
.slots { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 1.3em; }
.slots label { display: flex; align-items: center; gap: 6px; }
.slots .lbl { color: #5a6784; font-size: .8em; }
.slot { min-width: 100px; height: 62px; border: 3px solid #cfd7ea; background: #fff; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4em; padding: 0 10px; }
.slot.on { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47, 111, 214, .18); }
.slot.shake { animation: shake .35s; border-color: var(--red); }
.fracin .frac .slot { min-width: 76px; height: 54px; margin: 3px 0; }
.fracin .frac > span:first-child { border-bottom: 0; padding: 0; }
.fracin .frac::after { content: ''; order: 1; width: 90px; border-top: 4px solid var(--ink); }
.fracin .frac .slot:last-child { order: 2; }
.fracin .hint { width: 100%; text-align: center; font-size: .6em; color: #8a95ad; }
.q.right .slot { border-color: var(--green); background: #e9fff0; }
.q.wrong .slot { border-color: var(--red); background: #fff0ee; }
.unit { color: #5a6784; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { background: #fff; border: 2px solid #d7deef; border-radius: 14px; font-size: 1.7em; height: 62px; box-shadow: 0 4px 0 #d7deef; }
.keypad button:active { transform: translateY(3px); box-shadow: 0 1px 0 #d7deef; }
.keypad .del { background: #f1f3f8; }
.keypad .ok { background: var(--green); color: #fff; border-color: #2a9a58; box-shadow: 0 4px 0 #22834a; }
.explain { position: absolute; inset: 0; background: rgba(255, 253, 245, .97); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; z-index: 5; animation: fadein .25s; }
.explain .ex-h { font-size: 1.4em; color: var(--red); }
.explain .ex-a { font-size: 1.7em; }
.explain .ex-a b { color: var(--green); font-weight: normal; }
.explain .ex-b { font-size: 1.2em; color: #46526e; max-width: 760px; line-height: 1.6; background: #fff; padding: 10px 16px; border-radius: 12px; border: 2px dashed #ffd23f; }
@keyframes fadein { from { opacity: 0; } }

/* ---- 모달/토스트 ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 60, .55); display: grid; place-items: center; z-index: 100; animation: fadein .2s; padding: 16px; }
.modal { background: #fff; border-radius: 24px; padding: 24px; width: min(94vw, 520px); max-height: 92vh; overflow: auto; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); animation: popin .3s cubic-bezier(.3, 1.6, .5, 1); }
.modal.wide { width: min(94vw, 680px); }
.modal h2 { font-weight: normal; margin: 8px 0; }
.modal h2 small { color: #7a86a3; font-size: .7em; }
.modal p { line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.modal-art { width: min(56vw, 240px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .2)); }
.modal-art.pop { animation: popin .6s cubic-bezier(.3, 1.8, .5, 1); }
.sil { filter: brightness(0) !important; opacity: .75; }
.gray { filter: grayscale(1) opacity(.6); }
.new { color: var(--red); font-size: 1.15em; }
.flavor { background: #f5f7fc; border-radius: 12px; padding: 10px 14px; color: #46526e; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }
.toast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); background: rgba(38, 49, 74, .92); color: #fff; padding: 12px 22px; border-radius: 14px; z-index: 200; animation: popin .3s; transition: opacity .4s, transform .4s; text-align: center; max-width: 90vw; }
.toast.gold { background: linear-gradient(135deg, #ffb72b, #ff7a2b); }
.toast.out { opacity: 0; transform: translate(-50%, -20px); }

/* ---- 도감 ---- */
.dex-h { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dex-count { font-size: 1.2em; min-width: 240px; }
.dex-count b { font-size: 1.6em; color: var(--red); font-weight: normal; }
.dex-count small { color: #6c7894; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.dexc { position: relative; background: #fff; border-radius: 16px; padding: 6px; box-shadow: 0 3px 8px rgba(0, 0, 0, .08); display: flex; flex-direction: column; align-items: center; }
.dexc small { color: #97a1b8; font-size: .75em; align-self: flex-start; }
.dexc img { width: 90%; aspect-ratio: 1; object-fit: contain; }
.dexc b { font-weight: normal; font-size: .95em; }
.dexc.s0 img { filter: brightness(0); opacity: .18; }
.dexc.s1 img { filter: grayscale(1); opacity: .55; }
.dexc.s0 { background: #eef1f7; }
.dexc .got { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; opacity: 1 !important; filter: none !important; }
.dexd .genus { color: #6c7894; margin-bottom: 8px; }
.dexd .hw { color: #6c7894; margin: 8px 0; }
.stat { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: .9em; }
.stat span { width: 72px; text-align: right; color: #5a6784; }
.stat i { flex: 1; height: 12px; background: #eef1f7; border-radius: 99px; overflow: hidden; }
.stat i b { display: block; height: 100%; background: linear-gradient(90deg, #ffcf3f, #ff8a3d); }
.stat em { width: 36px; font-style: normal; text-align: left; }
.chain { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 12px; background: #f5f7fc; border-radius: 14px; padding: 8px; }
.chain span { display: flex; flex-direction: column; align-items: center; font-size: .85em; }
.chain img { width: 70px; height: 70px; object-fit: contain; }
.chain .unk img { filter: brightness(0); opacity: .3; }
.chain i { color: #a3adc2; font-style: normal; }

/* ---- 내 포켓몬 ---- */
.team { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slot-mon { position: relative; background: #fff; border-radius: 16px; padding: 10px; text-align: center; box-shadow: var(--shadow); cursor: pointer; }
.slot-mon img { width: 70%; aspect-ratio: 1; object-fit: contain; }
.slot-mon b { display: block; font-weight: normal; font-size: 1.1em; }
.slot-mon.partner { background: linear-gradient(135deg, #fff7d6, #ffe7a3); }
.slot-mon em { position: absolute; top: 8px; left: 8px; font-style: normal; background: var(--red); color: #fff; padding: 2px 8px; border-radius: 8px; font-size: .8em; }
.slot-mon.empty { display: grid; place-items: center; min-height: 150px; color: #a3adc2; border: 3px dashed #d7deef; box-shadow: none; background: transparent; }
.mon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.monc { background: #fff; border-radius: 16px; padding: 8px; box-shadow: 0 3px 8px rgba(0, 0, 0, .08); }
.monc img { width: 80%; aspect-ratio: 1; object-fit: contain; }
.monc b { display: block; font-weight: normal; }
.monc small { color: #6c7894; }
.monc.in { outline: 3px solid var(--yellow); }

/* ---- 체육관 목록 ---- */
.gym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.gym { position: relative; background: linear-gradient(160deg, #fff, #fff 55%, color-mix(in srgb, var(--gc) 25%, #fff)); border: 4px solid var(--gc); border-radius: 20px; padding: 12px; display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow); }
.gym img { width: 60%; aspect-ratio: 1; object-fit: contain; }
.gym b { font-weight: normal; font-size: 1.2em; }
.gym small { color: #6c7894; }
.gym .gb { position: absolute; top: 8px; left: 10px; font-size: 1.8em; }
.gym .gs { margin-top: 6px; background: var(--gc); color: #fff; padding: 3px 12px; border-radius: 99px; font-size: .9em; }
.gym.lock { filter: grayscale(.9); opacity: .7; }
.gym.clear { box-shadow: 0 0 0 4px #ffd23f, var(--shadow); }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.legend { background: linear-gradient(160deg, #2c2150, #4b3a8a); border-radius: 16px; padding: 8px; color: #fff; }
.legend img { width: 90%; aspect-ratio: 1; object-fit: contain; }
.legend b { font-weight: normal; display: block; }
.legend.lock { opacity: .55; }
.legend.clear { box-shadow: 0 0 0 3px #ffd23f; }
.gym-intro .gb.big { font-size: 64px; }
.rules { text-align: left; display: inline-block; line-height: 1.9; margin: 6px 0 0; padding-left: 18px; }

/* ---- 레이드 ---- */
.screen-raid .top, .screen-gyms .raid ~ * { }
.raid { position: relative; overflow: hidden; color: #fff; background: var(--bg) center/cover, radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--gc) 70%, #fff), color-mix(in srgb, var(--gc) 50%, #000) 60%, #10131f); }
.raid.rage { background: var(--bg) center/cover, radial-gradient(circle at 50% 35%, #ff7a59, #7a1414 60%, #10131f); }
.r-top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); flex-wrap: wrap; }
.r-name { font-size: 1.5em; text-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.r-name small { font-size: .55em; opacity: .85; margin-left: 6px; }
.r-hp { position: relative; flex: 1 1 100%; height: 26px; background: rgba(0, 0, 0, .45); border-radius: 99px; border: 3px solid rgba(255, 255, 255, .8); overflow: hidden; }
.r-hp i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 99px; }
.r-hp .lag { background: #ffe38a; transition: width .8s ease .1s; }
.r-hp .now { background: linear-gradient(90deg, #3ccf6e, #b4f06a); transition: width .3s; }
.r-hp .now.rage { background: linear-gradient(90deg, #ef4b3c, #ff9a3c); }
.r-hp .mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: rgba(255, 255, 255, .7); }
.r-stage { position: relative; flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.aura { position: absolute; width: min(60vw, 460px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .45), transparent 65%); animation: aura 2s ease-in-out infinite; }
.rage .aura, .charging .aura { background: radial-gradient(circle, rgba(255, 60, 40, .7), transparent 65%); animation-duration: .6s; }
@keyframes aura { 50% { transform: scale(1.15); opacity: .7; } }
.boss { position: relative; height: 92%; max-height: 360px; width: auto; max-width: 50vw; object-fit: contain; filter: drop-shadow(0 16px 14px rgba(0, 0, 0, .45)); z-index: 1; }
.boss.enter { animation: bossin 1s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes bossin { from { transform: translateY(-80vh) scale(.5); } }
.boss.idle { animation: bossidle 2.4s ease-in-out infinite; }
@keyframes bossidle { 50% { transform: translateY(-10px) scale(1.03); } }
.charging .boss { filter: drop-shadow(0 0 30px #ff3b2f) brightness(1.2); animation: charge .15s infinite; }
@keyframes charge { 50% { transform: translateX(3px) scale(1.04); } }
.boss.hurt { animation: bosshurt .45s; }
@keyframes bosshurt { 0% { filter: brightness(4) drop-shadow(0 0 20px #fff); } 30% { transform: translateX(-14px) rotate(-4deg); } 60% { transform: translateX(10px) rotate(3deg); } }
.boss.slam { animation: slam .6s; }
@keyframes slam { 30% { transform: translateY(-30px) scale(1.1); } 60% { transform: translateY(40px) scale(1.2); } }
.boss.faint { animation: faint 1.6s forwards; }
@keyframes faint { 30% { transform: translateY(-20px); } to { transform: translateY(60vh) rotate(20deg); opacity: 0; } }
.combo { position: absolute; right: 5%; top: 8%; text-align: center; z-index: 3; font-size: 1.4em; color: #ffe14d; text-shadow: 0 3px 0 #b3322a, 0 0 18px rgba(255, 200, 0, .7); }
.combo b { display: block; font-size: 2.6em; font-weight: normal; line-height: 1; }
.combo small { display: block; font-size: .7em; color: #fff; }
.combo.pop { animation: combopop .4s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes combopop { from { transform: scale(2); opacity: 0; } }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.6); opacity: 0; z-index: 4; background: rgba(0, 0, 0, .55); padding: 14px 30px; border-radius: 18px; font-size: 1.6em; text-align: center; pointer-events: none; transition: .25s cubic-bezier(.3, 1.6, .5, 1); white-space: nowrap; }
.banner small { font-size: .6em; }
.banner.on { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.banner.big { font-size: 2.2em; background: rgba(0, 0, 0, .35); }
.banner.count { font-size: 5em; background: none; text-shadow: 0 4px 0 rgba(0, 0, 0, .4); }
.banner.go { color: #ffe14d; }
.banner.warn { background: rgba(200, 20, 20, .8); animation: pulse .4s infinite; }
.banner.good { background: rgba(255, 170, 0, .85); }
.banner.bad { background: rgba(80, 0, 0, .75); }
.r-team { display: flex; gap: 10px; padding: 6px 12px; justify-content: center; }
.tm { display: flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, .35); border-radius: 14px; padding: 4px 12px 4px 4px; border: 3px solid transparent; transition: .2s; }
.tm img { width: 58px; height: 58px; object-fit: contain; }
.tm b { font-weight: normal; display: block; font-size: .9em; }
.tm .hearts { font-size: .85em; }
.tm.active { border-color: #ffe14d; transform: translateY(-4px); background: rgba(0, 0, 0, .5); }
.tm.down { filter: grayscale(1); opacity: .5; }
.tm.hit { animation: shake .4s; background: rgba(200, 0, 0, .6); }
.tm.lunge { animation: tmlunge .4s; }
@keyframes tmlunge { 40% { transform: translateY(-26px) scale(1.12); } }
.r-panel { color: var(--ink); min-height: 0; flex: none; }
.shot { position: absolute; font-size: 44px; z-index: 5; transition: transform .45s cubic-bezier(.4, 0, .9, .6); pointer-events: none; }
.dmg { position: absolute; z-index: 6; font-size: 2.4em; color: #fff; text-shadow: 0 3px 0 #b3322a, 0 0 10px #000; animation: dmg 1.1s ease-out forwards; pointer-events: none; }
.dmg.big { font-size: 3.6em; color: #ffe14d; }
@keyframes dmg { from { transform: translate(-50%, 0) scale(1.6); } 30% { transform: translate(-50%, -30px) scale(1); } to { transform: translate(-50%, -110px); opacity: 0; } }
.impact { position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 6px solid #fff; transform: translate(-50%, -50%); animation: impact .5s ease-out forwards; z-index: 4; }
@keyframes impact { to { width: 260px; height: 260px; opacity: 0; border-width: 1px; } }
.raid.shake { animation: shake .35s; }
.raid.shake::after, .raid.bigshake::after { content: ''; position: absolute; inset: 0; background: rgba(255, 0, 0, .18); pointer-events: none; }
.conf { position: absolute; top: -20px; width: 10px; height: 16px; z-index: 7; animation: conf linear forwards; }
@keyframes conf { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
.badge-get { font-size: 90px; width: 150px; height: 150px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, #fff, color-mix(in srgb, var(--gc) 45%, #fff)); box-shadow: 0 0 0 6px #ffd23f, 0 0 40px #ffd23f; animation: badge 1.2s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes badge { from { transform: scale(0) rotate(-360deg); } }
.r-sum { margin-top: 12px; color: #5a6784; background: #f5f7fc; border-radius: 12px; padding: 8px; }

/* ---- 진화 ---- */
.evo-ov { position: fixed; inset: 0; z-index: 150; background: radial-gradient(circle, #fff, #9fd3ff); display: grid; place-items: center; }
.evo-ov img { grid-area: 1/1; width: min(60vw, 320px); }
.evo-ov .e1 { filter: brightness(0) invert(1) drop-shadow(0 0 20px #fff); animation: evoblink .5s infinite; }
.evo-ov .e2 { opacity: 0; }
.evo-ov.go .e1 { animation: none; opacity: 0; transition: .6s; }
.evo-ov.go .e2 { opacity: 1; transition: opacity 1s .4s; animation: popin 1s; }
@keyframes evoblink { 50% { transform: scale(1.15); } }
.evo-pick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.evo-pick span { display: flex; flex-direction: column; align-items: center; }
.evo-pick img { width: 90px; }

/* ---- 태블릿 세로/작은 화면 ---- */
@media (max-width: 820px) {
  .q { grid-template-columns: 1fr; grid-template-areas: "timer" "tag" "body" "input"; }
  .keypad button { height: 56px; }
  .mon { max-width: 40vw; }
  .hpbox { min-width: 180px; font-size: .9em; }
  .team { gap: 6px; }
}
@media (max-height: 700px) and (orientation: landscape) {
  .panel { min-height: 0; }
  .keypad button { height: 48px; font-size: 1.4em; }
  .slot { height: 50px; }
  .qtext { font-size: 22px; }
  .arena { min-height: 38vh; }
}

/* 소수 키패드, 텍스트 답, 선택 칸 */
.keypad .ok.wide { grid-column: 1 / -1; }
.keypad .dot { font-weight: bold; }
.slot.opt { border-style: dashed; }
.textin { display: flex; gap: 10px; align-items: center; }
.textin input { flex: 1; font-size: 1.6em; padding: 12px 16px; border-radius: 14px; border: 3px solid #cfd7ea; font-family: inherit; }
.q.right .textin input { border-color: var(--green); background: #e9fff0; }
.q.wrong .textin input { border-color: var(--red); background: #fff0ee; }
/* 단원 고르기 */
.focus-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.focus-row button { padding: 6px 12px; border-radius: 99px; background: #eef2fa; font-size: .85em; }
.focus-row button.on { background: var(--blue); color: #fff; }
.focus-row small { opacity: .7; }
.teacher-link { position: fixed; right: 14px; bottom: 12px; color: #fff; opacity: .75; font-size: .9em; background: rgba(0,0,0,.18); padding: 6px 12px; border-radius: 99px; text-decoration: none; }

/* ---------- 트레이너 랭크 ---------- */
.rank-chip { display: block; background: rgba(255,255,255,.2); color: #fff; border-radius: 99px; padding: 1px 9px; font-size: .78em; margin-top: 1px; white-space: nowrap; }
.rank-chip small { color: var(--yellow); }
.rank-bar { height: 14px; background: #e8eefb; border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), #ff9f1c); border-radius: 99px; }
.rank-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; text-align: left; }
.rank-list li { color: #9aa5bd; padding: 3px 6px; border-radius: 8px; }
.rank-list li.done { color: var(--ink); }
.rank-list li.now { background: #fff4c7; color: var(--ink); }
.rank-list small { color: #9aa5bd; }
.hint { font-size: .85em; color: #7b87a3; }
.rank-up { font-size: 72px; animation: popin .6s; }

/* ---------- 우편함 ---------- */
.nav button { position: relative; }
.mail-dot { position: absolute; top: 4px; left: calc(50% + 10px); background: var(--red); color: #fff; font-style: normal; font-size: .72em; min-width: 18px; height: 18px; line-height: 18px; border-radius: 99px; padding: 0 5px; }
.mail-dot[hidden] { display: none; }
.mail-banner { display: flex; align-items: center; gap: 8px; width: 100%; margin: 12px 0 0; padding: 12px 16px; border-radius: var(--r); background: linear-gradient(90deg, #fff4c7, #ffe08a); color: var(--ink); font-size: 1.05em; box-shadow: var(--shadow); animation: popin .5s; }
.mail-banner span { margin-left: auto; color: var(--blue); }
.mailbox { padding: 16px; max-width: 900px; margin: 0 auto; width: 100%; }
.letters { display: grid; gap: 10px; }
.letter { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 10px 16px; text-align: left; border-left: 6px solid var(--yellow); }
.letter img { height: 64px; width: 64px; object-fit: contain; }
.letter b { display: block; font-weight: normal; font-size: 1.1em; }
.letter small { color: #7b87a3; }
.letter .go { margin-left: auto; background: var(--red); color: #fff; padding: 8px 16px; border-radius: 99px; }
.empty-mail { text-align: center; line-height: 1.8; }
.mail-stats { display: flex; gap: 20px; justify-content: center; margin-top: 14px; padding: 12px; }
.gifts { display: grid; gap: 10px; }
.gift p { margin: 8px 0; font-size: 1.1em; }
.gift .g-from small { color: #7b87a3; margin-left: 6px; }
.g-items { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.g-items span { display: flex; align-items: center; gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px 10px; }
.g-items img { height: 40px; }

/* ---------- 트레이너 배틀 ---------- */
.tr-name { font-size: .85em; color: #7b87a3; }
.pips { margin-top: 4px; letter-spacing: 2px; }
@media (max-width: 700px) { .rank-chip { font-size: .7em; } .top .me > div b { font-size: .9em; } .nav button { font-size: .8em; } }
.letter .go { white-space: nowrap; flex: none; }
@media (max-width: 700px) { .letter { padding: 8px 10px; gap: 8px; } .letter img { height: 48px; width: 48px; } .letter b { font-size: 1em; } .sec small { display: block; } }

.me-av { position: relative; padding: 0; background: none; border: 0; line-height: 0; cursor: pointer; }
.me-av i { position: absolute; right: -4px; bottom: -2px; font-style: normal; font-size: 11px; line-height: 16px; width: 16px; height: 16px; border-radius: 50%; background: var(--yellow); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch-me svg { background: var(--soft); border-radius: 50%; width: 90px; height: 90px; }
/* 밝은 배경 위 버튼 글씨 가독성 */
.field-h .btn { color: var(--ink) !important; text-shadow: none !important; background: rgba(255,255,255,.95) !important; box-shadow: 0 3px 0 rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.2); }
.btn.ghost { background: rgba(20, 30, 60, .6); color: #fff; text-shadow: none; }
