:root {
  font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: #172033;
  background: #f3f6fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #eef5ff 0, #f7f8fc 35%, #f3f6fb 100%);
  word-break: keep-all;
}
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 4px solid rgba(49, 92, 232, .3); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .48; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  min-height: 78px; padding: 13px clamp(14px, 3vw, 34px); display: flex; align-items: center;
  justify-content: space-between; gap: 14px; background: rgba(255,255,255,.94);
  border-bottom: 1px solid #dfe6f2; box-shadow: 0 8px 26px rgba(43,65,103,.06); position: sticky; top: 0; z-index: 30;
}
.brand-button { border: 0; background: transparent; display: flex; align-items: center; gap: 10px; padding: 0; text-align: left; color: #172033; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg,#e5f5ff,#fff0c7); font-size: 25px; flex: none; }
.brand-button strong { display: block; font-size: clamp(18px, 2.5vw, 27px); line-height: 1.15; }
.brand-button small { display: block; color: #657088; font-size: 13px; margin-top: 3px; }
.brand-button strong .ko, .brand-button strong .ru, .brand-button small .ko, .brand-button small .ru { display: block; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.language-controls { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid #cfd8e8; border-radius: 999px; background: #f4f7fb; }
.language-button { min-height: 34px; border: 0; border-radius: 999px; padding: 6px 11px; background: transparent; color: #526079; font-weight: 800; font-size: 13px; }
.language-button.active { background: #315ce8; color: #fff; box-shadow: 0 5px 11px rgba(49,92,232,.22); }
.icon-button { min-width: 42px; min-height: 42px; border: 1px solid #cfd8e8; border-radius: 12px; background: #fff; color: #34425a; font-weight: 900; }

main { width: min(1260px, 100%); margin: 0 auto; padding: clamp(16px, 3vw, 34px); flex: 1; }
.view { min-height: calc(100vh - 150px); min-height: calc(100dvh - 150px); }
.home-view { display: flex; flex-direction: column; gap: 18px; }
.hero-card { padding: clamp(23px, 4vw, 40px); border: 1px solid #dfe6f1; border-radius: 28px; background: rgba(255,255,255,.95); box-shadow: 0 14px 36px rgba(43,65,103,.08); text-align: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px; background: #eaf4ff; border: 1px solid rgba(49,92,232,.15); color: #2453ad; font-size: 13px; font-weight: 900; }
.hero-card h1 { margin: 13px 0 8px; font-size: clamp(28px, 5vw, 50px); letter-spacing: -.055em; line-height: 1.12; }
.lead { margin: 0 auto; max-width: 700px; color: #526079; font-size: clamp(17px, 2.3vw, 22px); line-height: 1.5; font-weight: 700; }
.scope-note { margin: 17px 0 0; color: #7b879b; font-size: 14px; line-height: 1.45; }
.unit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.unit-card { border: 1px solid #dfe6f1; border-radius: 23px; background: rgba(255,255,255,.96); box-shadow: 0 11px 30px rgba(43,65,103,.08); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-height: 250px; }
.unit-card-head { display: flex; align-items: flex-start; gap: 11px; }
.unit-number { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: #edf4ff; color: #2453ad; font-size: 20px; font-weight: 950; flex: none; }
.unit-card h2 { margin: 0; font-size: clamp(20px, 2.6vw, 28px); line-height: 1.18; }
.unit-card h2 small { display: block; margin-top: 3px; color: #657088; font-size: .58em; font-weight: 750; }
.game-label { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 6px 10px; border-radius: 999px; background: #fff7df; color: #8a5b00; border: 1px solid rgba(238,157,24,.22); font-size: 14px; font-weight: 900; }
.concept-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; margin-right: 5px; padding: 5px 9px; border-radius: 999px; background: #eaf4ff; color: #2453ad; border: 1px solid rgba(49,92,232,.15); font-size: 13px; font-weight: 900; }
.unit-hint { margin: 0; color: #526079; line-height: 1.5; font-size: 15px; }
.unit-actions { display: flex; gap: 8px; margin-top: auto; }
.primary-button, .secondary-button { border-radius: 13px; min-height: 46px; padding: 9px 15px; font-weight: 900; border: 1px solid transparent; }
.primary-button { background: linear-gradient(145deg,#315ce8,#244aa9); color: #fff; box-shadow: 0 8px 15px rgba(49,92,232,.2); }
.secondary-button { background: #f4f7fb; color: #34425a; border-color: #cfd8e8; }
.unit-actions .primary-button { flex: 1; }
.settings-small { min-width: 46px; }

.game-view { display: flex; flex-direction: column; }
.game-mount { flex: 1; min-height: 0; }
.game-shell { min-height: calc(100vh - 150px); min-height: calc(100dvh - 150px); display: flex; flex-direction: column; gap: 12px; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border: 1px solid #dfe6f1; border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: 0 9px 24px rgba(43,65,103,.07); }
.game-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.game-title .game-emoji { font-size: 30px; }
.game-title strong { display: block; font-size: clamp(19px, 2.7vw, 28px); }
.game-title small { display: block; margin-top: 3px; color: #657088; font-size: 13px; }
.game-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.game-actions button { min-height: 40px; }
.game-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen-card { width: min(1040px, 100%); margin: 0 auto; border: 1px solid #dfe6f1; border-radius: 25px; background: rgba(255,255,255,.97); box-shadow: 0 13px 34px rgba(43,65,103,.08); padding: clamp(18px, 3vw, 30px); }
.screen-card.center { text-align: center; }
.screen-card h2 { margin: 0 0 8px; font-size: clamp(26px, 4.5vw, 45px); letter-spacing: -.045em; }
.screen-card h3 { margin: 0 0 7px; font-size: clamp(20px, 3vw, 28px); }
.screen-card p { color: #526079; line-height: 1.5; }
.bilingual .ko, .bilingual .ru { display: block; }
.bilingual .ru { margin-top: 3px; color: #657088; font-size: .86em; font-weight: 700; }
.together-text { line-height: 1.2; }
.theme-art { margin: 10px auto 4px; padding: 8px 18px; border-radius: 18px; width: fit-content; font-size: clamp(32px, 7vw, 54px); letter-spacing: 7px; line-height: 1.05; }
.sort-theme-art { background: linear-gradient(145deg, #e8f8df, #fff3c8); box-shadow: inset 0 -4px 0 rgba(74,132,73,.1); }
.card-theme-art { background: linear-gradient(145deg, #fff1d7, #ffe3e7); box-shadow: inset 0 -4px 0 rgba(227,125,78,.1); }
.speed-theme-art { background: linear-gradient(145deg, #172d67, #492c83); box-shadow: inset 0 -4px 0 rgba(124,179,255,.24); }
.theme-strip { display: flex; justify-content: center; align-items: center; min-height: 34px; margin: -4px 0 8px; padding: 5px 12px; border-radius: 13px; font-size: 22px; letter-spacing: 5px; }
.sort-theme-strip { background: #eef9e8; color: #3f7d41; }
.card-theme-strip { background: #fff1df; color: #b86642; }
.speed-theme-strip { background: #e9edff; color: #315ce8; }
.defense-theme-strip { background: #eaf4ff; color: #2453ad; }
.single-ru { color: #526079; }
.game-button { min-height: 50px; border-radius: 14px; border: 1px solid #cfd8e8; background: #f7faff; color: #244aa9; font-weight: 900; padding: 10px 15px; }
.game-button.primary { background: linear-gradient(145deg,#315ce8,#244aa9); color: #fff; border-color: transparent; }
.game-button.success { background: linear-gradient(145deg,#24b47e,#16885f); color: #fff; border-color: transparent; }
.game-button.warning { background: #fff6df; color: #8a5b00; border-color: rgba(238,157,24,.28); }
.game-button.danger { background: #fff0f0; color: #a03a3a; border-color: rgba(223,85,85,.25); }
.game-button:disabled { opacity: .48; }
.button-row { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 13px 0; }
.stat-pill { min-height: 34px; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; background: #edf4ff; color: #2453ad; font-weight: 850; font-size: 14px; }
.feedback { min-height: 54px; padding: 12px 14px; border-radius: 15px; background: #f3f6fb; color: #526079; line-height: 1.45; font-weight: 750; }
.feedback.good { background: #e5f8ec; color: #145f32; }
.feedback.bad { background: #fff0f0; color: #942323; }
.feedback.warn { background: #fff6df; color: #8a5b00; }

/* card game */
.card-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.memory-card { min-height: 115px; border: 2px solid #cddbf5; border-radius: 17px; background: linear-gradient(145deg,#f8fbff,#eaf3ff); color: #244aa9; padding: 10px; font-weight: 900; display: flex; align-items: center; justify-content: center; text-align: center; transition: transform .16s, background .16s, border-color .16s; }
.memory-card .card-front { display: none; }
.memory-card .card-back { font-size: 34px; filter: drop-shadow(0 4px 5px rgba(136,82,32,.14)); }
.memory-card.open, .memory-card.matched { background: #fff; color: #172033; border-color: #7594ff; transform: translateY(-2px); }
.memory-card.open .card-back, .memory-card.matched .card-back { display: none; }
.memory-card.open .card-front, .memory-card.matched .card-front { display: block; }
.memory-card.matched { background: #e5f8ec; border-color: #75c99a; }
.memory-card:disabled { opacity: 1; }
.memory-card .card-front .ru { font-size: .78em; }

/* speed game */
.speed-lane { position: relative; min-height: 440px; overflow: hidden; border-radius: 22px; border: 1px solid #cfe0f6; background: radial-gradient(circle at 18% 15%, rgba(255,255,255,.82) 0 2px, transparent 3px), radial-gradient(circle at 78% 30%, rgba(255,255,255,.75) 0 2px, transparent 3px), linear-gradient(180deg,#192d66 0%,#314b91 48%,#8cb8eb 100%); background-size: 160px 130px, 230px 180px, auto; }
.speed-space-decor { position: absolute; inset: 12px 18px auto; color: rgba(255,255,255,.86); font-size: 25px; letter-spacing: 7px; pointer-events: none; }
.speed-question { padding: 14px; border-radius: 17px; background: rgba(255,255,255,.9); border: 1px solid #dfe6f1; text-align: center; }
.speed-question strong { display: block; font-size: clamp(19px, 3vw, 28px); }
.falling-option { position: absolute; left: 0; top: 0; min-height: 50px; width: min(22%, 190px); transform: translateX(-50%); border-radius: 999px; border: 2px solid rgba(49,92,232,.25); background: #fff; color: #244aa9; font-weight: 900; padding: 9px 8px; box-shadow: 0 9px 17px rgba(43,65,103,.13); touch-action: manipulation; }
.falling-option .ru { font-size: .75em; color: #657088; }
.falling-option.removed { opacity: 0; pointer-events: none; }
.speed-columns { position: absolute; left: 12%; right: 12%; top: 0; bottom: 0; pointer-events: none; }
.speed-columns::before, .speed-columns::after { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; border-left: 1px dashed rgba(49,92,232,.12); }
.speed-columns::before { left: 25%; } .speed-columns::after { right: 25%; }

/* sort game */
.sort-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 13px; align-items: start; }
.basket-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.sort-basket { min-height: 150px; border: 2px dashed rgba(49,92,232,.3); border-radius: 18px; background: #f7faff; padding: 10px; text-align: center; color: #244aa9; font-weight: 900; cursor: pointer; }
.sort-basket.drag-over { background: #eaf4ff; border-color: #315ce8; }
.sort-basket .basket-name { font-size: clamp(18px, 2.5vw, 25px); }
.sort-basket .basket-icon { display: block; font-size: 30px; line-height: 1; margin-bottom: 5px; }
.placed-card { margin-top: 8px; padding: 5px; border-radius: 9px; background: #e5f8ec; color: #145f32; font-size: 12px; }
.sort-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sort-card { min-height: 69px; border: 2px solid #d7e1f0; border-radius: 14px; background: #fff; padding: 8px; text-align: center; font-weight: 850; touch-action: none; }
.sort-card-icon { display: block; font-size: 23px; line-height: 1; margin-bottom: 3px; }
.sort-card.selected { border-color: #315ce8; background: #eaf4ff; box-shadow: 0 0 0 3px rgba(49,92,232,.12); }
.sort-card.dragging { position: fixed; z-index: 100; pointer-events: none; box-shadow: 0 16px 30px rgba(43,65,103,.2); transform: translate(-50%, -50%) scale(1.05); }
.sort-card .ru, .sort-basket .ru { display: block; color: #657088; font-size: .76em; margin-top: 3px; }

/* defense game */
.defense-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, .85fr); gap: 13px; align-items: start; }
.question-panel { padding: 16px; border-radius: 19px; background: #f7faff; border: 1px solid #dbe7ff; }
.question-panel h3 { font-size: clamp(20px, 2.8vw, 29px); line-height: 1.35; }
.choice-grid { display: grid; gap: 9px; margin-top: 13px; }
.choice-button { min-height: 56px; border: 2px solid #cddbf5; border-radius: 15px; background: #fff; color: #172033; padding: 9px 12px; text-align: left; font-weight: 800; }
.choice-button:hover:not(:disabled) { background: #edf4ff; border-color: #7594ff; }
.choice-button.wrong { background: #fff0f0; border-color: #df5555; color: #942323; }
.choice-button.correct { background: #e5f8ec; border-color: #75c99a; color: #145f32; }
.robot-card { padding: 16px; border-radius: 19px; background: linear-gradient(145deg,#eef8ff,#fff7df); border: 1px solid #dbe7ff; }
.robot-card .robot-icon { font-size: 52px; text-align: center; }
.battle-lane { position: relative; min-height: 390px; overflow: hidden; border-radius: 21px; border: 1px solid #cfe0f6; background: linear-gradient(180deg,#dff3ff 0%,#eefaff 52%,#e6f6d9 53%,#cce8b9 100%); }
.battle-lane::before { content: "✦　·　🔧　·　✦　·　🔬　·　✦"; position: absolute; inset: 18px 0 auto; color: rgba(49,92,232,.28); text-align: center; letter-spacing: 7px; pointer-events: none; }
.tower-launch { position: absolute; right: 20px; bottom: 82px; z-index: 2; padding: 7px 10px; border-radius: 14px; background: rgba(255,255,255,.82); color: #315ce8; font-size: 24px; letter-spacing: 3px; box-shadow: 0 5px 12px rgba(43,65,103,.12); }
.battle-base { position: absolute; left: 14px; right: 14px; bottom: 10px; min-height: 58px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 18px; background: rgba(255,255,255,.95); border: 2px solid rgba(49,92,232,.2); color: #244aa9; font-weight: 950; z-index: 2; }
.monster { position: absolute; width: 70px; transform: translate(-50%, -50%); text-align: center; z-index: 3; transition: top .08s linear; }
.monster-icon { font-size: 31px; line-height: 1; }
.monster-name { font-size: 11px; font-weight: 900; color: #526079; white-space: nowrap; }
.monster-hp { height: 6px; margin-top: 2px; border-radius: 999px; background: #ffd2d2; overflow: hidden; }
.monster-hp span { display: block; height: 100%; background: #df5555; }
.tower-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.tower-card { min-height: 180px; display: flex; flex-direction: column; gap: 7px; padding: 12px; border: 1px solid #dfe6f1; border-radius: 17px; background: #fff; text-align: center; }
.tower-card .tower-icon { font-size: 35px; }
.tower-card strong { font-size: 17px; }
.tower-card small { color: #657088; line-height: 1.35; min-height: 37px; }
.tower-card button { margin-top: auto; min-height: 40px; }
.level-dots { color: #315ce8; letter-spacing: 2px; font-size: 13px; }
.battle-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px; margin: 10px 0; }
.battle-stat { padding: 8px; border-radius: 12px; background: #f7faff; border: 1px solid #dbe7ff; text-align: center; }
.battle-stat small { display: block; color: #657088; font-size: 11px; }
.battle-stat strong { display: block; color: #244aa9; font-size: 20px; }

/* modal and results */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: rgba(23,32,51,.55); backdrop-filter: blur(6px); }
.settings-modal { width: min(560px, 100%); max-height: min(90vh, 760px); overflow: auto; padding: 22px; border-radius: 24px; background: #fff; box-shadow: 0 24px 70px rgba(10,24,55,.25); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head h2 { margin: 8px 0 0; font-size: 28px; }
.modal-hint { color: #657088; line-height: 1.45; }
.settings-form { display: grid; gap: 14px; margin: 18px 0; }
.setting-field { display: grid; gap: 7px; }
.setting-field label { font-weight: 900; }
.setting-field select { min-height: 48px; border: 2px solid #d6deec; border-radius: 13px; background: #f8fbff; color: #172033; padding: 8px 11px; font: inherit; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions .primary-button { flex: 1; }
.result-list { display: grid; gap: 7px; margin: 13px 0; }
.result-item { padding: 10px 12px; border-radius: 13px; background: #f7faff; border: 1px solid #dbe7ff; line-height: 1.45; }
.muted { color: #657088; }
.empty-message { padding: 30px; text-align: center; color: #657088; }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: flex-end; }
  .unit-grid { grid-template-columns: 1fr; }
  .defense-grid, .sort-layout { grid-template-columns: 1fr; }
  .game-shell { min-height: calc(100vh - 190px); min-height: calc(100dvh - 190px); }
}
@media (max-width: 560px) {
  main { padding: 12px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .brand-block { flex: 1 1 100%; min-width: 0; }
  .top-actions { width: 100%; flex-direction: row; align-items: center; }
  .language-controls { flex: 1; min-width: 0; }
  .language-button { flex: 1; min-width: 0; padding-inline: 5px; white-space: nowrap; }
  .brand-button small { display: none; }
  .brand-button strong { font-size: 20px; }
  .hero-card { padding: 15px 13px; }
  .hero-card h1 { margin: 5px 0 5px; font-size: 30px; }
  .lead { font-size: 15px; }
  .scope-note { margin-top: 7px; font-size: 12px; }
  .game-header { align-items: flex-start; flex-direction: column; }
  .game-actions { width: 100%; justify-content: flex-start; }
  .game-actions button { flex: 1; }
  .card-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .memory-card { min-height: 105px; }
  .speed-lane { min-height: 390px; }
  .falling-option { width: 38%; font-size: 14px; }
  .basket-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sort-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tower-grid { grid-template-columns: 1fr; }
  .tower-card { min-height: 132px; display: grid; grid-template-columns: auto 1fr; text-align: left; align-items: center; }
  .tower-card .tower-icon { grid-row: span 3; }
  .tower-card button { margin-top: 0; }
  .battle-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .modal-actions { flex-direction: column-reverse; }
}
