@font-face {
  font-family: "Germania One";
  src: url("/assets/fonts/GermaniaOne-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #090808;
  --ink-soft: #12100f;
  --panel: rgba(21, 18, 15, 0.92);
  --paper: #cbb88f;
  --paper-dark: #776849;
  --gold: #c7a75a;
  --gold-bright: #f1d889;
  --gold-dim: #735c2d;
  --green: #8bf391;
  --violet: #a166ff;
  --danger: #d25757;
  --text: #eee6d7;
  --muted: #a49a87;
  --border: rgba(208, 174, 92, 0.34);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(100, 58, 24, 0.16), transparent 32rem),
    radial-gradient(circle at 100% 30%, rgba(69, 31, 111, 0.12), transparent 38rem),
    #090808;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.ambient-grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 0 5vw;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 8, 8, 0.86);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
  color: var(--gold-bright);
  font-family: "Germania One", serif;
  font-size: 15px;
  box-shadow: inset 0 0 18px rgba(199, 167, 90, 0.15);
}
.brand-mark::first-line { transform: rotate(-45deg); }
.brand b { display: block; color: var(--gold-bright); font-family: "Germania One", serif; font-size: 20px; letter-spacing: 0.08em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.connection-pill { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; letter-spacing: 0.1em; }
.connection-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #171411;
  color: var(--gold-bright);
  cursor: pointer;
  font-size: 24px;
}

main { width: min(1380px, 100%); margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; animation: view-enter 0.45s ease both; }
@keyframes view-enter { from { opacity: 0; transform: translateY(8px); } }

.hero-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.6fr);
  gap: clamp(28px, 5vw, 76px);
  min-height: 500px;
  padding: clamp(70px, 9vw, 130px) 6vw 70px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.hero-overview::before {
  content: "";
  position: absolute;
  inset: 0 0 0 47%;
  background: linear-gradient(90deg, #090808 0%, transparent 38%), url("/assets/boss-concept.png") 50% 8% / cover no-repeat;
  opacity: 0.22;
  filter: grayscale(0.4) sepia(0.3);
  mask-image: linear-gradient(90deg, transparent, #000 35%);
}
.hero-copy, .profile-panel { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; }
.hero-copy h1 { margin: 0; max-width: 820px; font-family: "Germania One", Georgia, serif; font-size: clamp(46px, 6.8vw, 92px); font-weight: 400; line-height: 0.98; letter-spacing: -0.025em; }
.hero-copy h1 em { color: var(--gold-bright); font-style: normal; text-shadow: 0 0 32px rgba(220, 173, 75, 0.16); }
.hero-description { max-width: 620px; margin: 28px 0; color: #b8ad9c; font-size: clamp(15px, 1.4vw, 19px); line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }

.primary-button, .secondary-button, .text-button, .finish-button, .listen-button, .back-button {
  border: 0;
  cursor: pointer;
  transition: 0.2s ease;
}
.primary-button {
  min-height: 50px;
  padding: 0 24px;
  border: 1px solid #e3c371;
  background: #b59143;
  color: #120e08;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 7px 0 #58431d, 0 12px 32px rgba(173, 127, 46, 0.18);
}
.primary-button:hover { transform: translateY(-2px); background: var(--gold-bright); box-shadow: 0 9px 0 #58431d, 0 18px 40px rgba(173, 127, 46, 0.28); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #58431d; }
.primary-button.full { width: 100%; }
.secondary-button { min-height: 44px; padding: 0 18px; border: 1px solid var(--border); background: #171411; color: var(--text); }
.text-button { padding: 10px 2px; background: none; color: var(--gold-bright); border-bottom: 1px solid var(--gold-dim); }

.profile-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border: 1px solid var(--border);
  background: var(--border);
  box-shadow: var(--shadow);
}
.profile-panel > div { min-height: 120px; padding: 22px; background: rgba(12, 11, 10, 0.92); }
.profile-panel strong { display: block; margin-top: 12px; color: var(--gold-bright); font-family: "Germania One", serif; font-size: 34px; font-weight: 400; }
.profile-panel .profile-level { grid-row: span 2; display: flex; flex-direction: column; justify-content: space-between; min-height: 241px; }
.profile-level span, .stat-label { color: var(--muted); font-size: 10px; letter-spacing: 0.18em; }
.profile-panel .profile-level strong { font-size: 100px; line-height: 0.8; }

.content-section { padding: 64px 6vw; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 30px; }
.section-heading.compact { margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-family: "Germania One", serif; font-size: clamp(34px, 4vw, 52px); font-weight: 400; }
.filter-bar { display: flex; gap: 6px; padding: 5px; border: 1px solid var(--border); background: #0f0d0c; }
.filter-chip { min-width: 62px; padding: 10px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.filter-chip.is-active { background: #302719; color: var(--gold-bright); box-shadow: inset 0 0 0 1px var(--gold-dim); }

.article-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.article-card {
  position: relative;
  display: flex;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #12100f;
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.article-card:hover { transform: translateY(-7px); border-color: var(--gold); }
.article-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url("/assets/boss-concept.png") 50% 8% / 180% auto no-repeat;
  filter: hue-rotate(var(--monster-hue)) saturate(0.75);
  opacity: 0.38;
  transform: scale(1.02);
  transition: transform 0.6s ease;
}
.article-card:hover::before { transform: scale(1.08); }
.article-card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(5, 4, 5, 0.06), rgba(8, 7, 7, 0.9) 62%, #0b0909 100%); }
.card-content { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; padding: 24px; }
.card-top { position: absolute; inset: 18px 18px auto; display: flex; justify-content: space-between; align-items: center; }
.difficulty-tag { padding: 7px 10px; border: 1px solid currentColor; color: var(--gold-bright); background: rgba(8, 7, 7, 0.7); font-size: 10px; letter-spacing: 0.14em; }
.best-badge { display: grid; place-items: center; width: 48px; aspect-ratio: 1; border: 1px solid var(--gold); background: rgba(10, 8, 7, 0.85); color: var(--gold-bright); font-family: "Germania One", serif; font-size: 25px; transform: rotate(45deg); }
.best-badge span { transform: rotate(-45deg); }
.monster-label { margin: 0 0 8px; color: #bcb19f; font-size: 10px; letter-spacing: 0.18em; }
.article-card h3 { margin: 0; font-family: "Germania One", serif; font-size: 30px; font-weight: 400; line-height: 1.05; }
.card-subtitle { min-height: 42px; margin: 10px 0 18px; color: #aaa090; font-size: 13px; line-height: 1.6; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; border-top: 1px solid var(--border); padding-top: 14px; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; }
.card-stats b { display: block; margin-top: 4px; color: var(--text); font-size: 15px; letter-spacing: normal; }

.achievements-section { padding-top: 20px; }
.achievement-list { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; }
.achievement-item, .achievement-empty { min-width: 240px; padding: 18px; border: 1px solid var(--border); background: rgba(19, 16, 14, 0.86); }
.achievement-item b { color: var(--gold-bright); font-family: "Germania One", serif; font-size: 20px; font-weight: 400; }
.achievement-item p, .achievement-empty { color: var(--muted); font-size: 13px; line-height: 1.5; }

.practice-view { padding: 22px 4vw 50px; }
.practice-topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.back-button { padding: 10px 0; background: none; color: var(--muted); }
.back-button:hover { color: var(--gold-bright); }
.mode-switch { display: flex; padding: 4px; border: 1px solid var(--border); background: #100e0d; }
.mode-switch button { padding: 9px 13px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.mode-switch button.is-active { background: #34291a; color: var(--gold-bright); }
.battle-layout { display: grid; grid-template-columns: minmax(380px, 0.9fr) minmax(420px, 1.1fr); min-height: calc(100vh - 138px); border: 1px solid var(--border); box-shadow: var(--shadow); }

.boss-stage { position: relative; min-height: 680px; overflow: hidden; background: #09080a; isolation: isolate; }
.boss-art { position: absolute; inset: 0; z-index: -3; width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; filter: hue-rotate(var(--boss-hue, 0deg)) saturate(0.9) contrast(1.05); transform: scale(1.55); transform-origin: 50% 20%; }
.boss-vignette { position: absolute; inset: 0; z-index: -2; background: linear-gradient(180deg, rgba(4, 4, 5, 0.18), transparent 30%, rgba(7, 5, 7, 0.3) 55%, #090708 100%), linear-gradient(90deg, rgba(8, 7, 8, 0.3), transparent, rgba(8, 7, 8, 0.35)); }
.boss-header { display: flex; justify-content: space-between; align-items: start; padding: 30px; background: linear-gradient(180deg, rgba(4, 3, 4, 0.82), transparent); }
.boss-header p { margin: 0 0 4px; color: #c9b793; font-size: 10px; letter-spacing: 0.22em; }
.boss-header h2 { margin: 0; font-family: "Germania One", serif; font-size: clamp(30px, 3vw, 48px); font-weight: 400; text-shadow: 0 3px 16px #000; }
.boss-rank { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 9px; letter-spacing: 0.18em; }
.boss-rank b { color: var(--gold-bright); font-family: "Germania One", serif; font-size: 38px; }
.boss-health-wrap { position: absolute; right: 30px; bottom: 32px; left: 30px; }
.boss-health-copy { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--gold-bright); font-size: 11px; letter-spacing: 0.12em; }
.boss-health { height: 17px; padding: 3px; border: 1px solid var(--gold); background: #0a0808; box-shadow: 0 0 24px rgba(148, 65, 211, 0.18); }
.boss-health i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #4d176f, #b74dff 65%, #f1c9ff); transition: width 0.5s ease; box-shadow: 0 0 14px #9b46e4; }
.attack-flash { position: absolute; inset: 35% 0 auto; z-index: 4; text-align: center; color: #fff4b7; font-family: "Germania One", serif; font-size: clamp(54px, 8vw, 112px); opacity: 0; text-shadow: 0 0 15px #fff, 0 0 50px #b95cff; pointer-events: none; }
.attack-flash.is-active { animation: final-strike 1.5s ease both; }
@keyframes final-strike { 0% { opacity: 0; transform: scale(2.5); } 18% { opacity: 1; transform: scale(0.85); } 40% { transform: scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }

.scroll-console { position: relative; display: flex; flex-direction: column; padding: clamp(24px, 4vw, 52px); background: linear-gradient(135deg, rgba(31, 25, 18, 0.92), rgba(10, 9, 8, 0.98)), #111; }
.scroll-console::before { content: ""; position: absolute; inset: 12px; pointer-events: none; border: 1px solid var(--gold-dim); box-shadow: inset 0 0 0 4px #110e0b, inset 0 0 0 5px rgba(200, 164, 77, 0.18); }
.practice-meta, .scroll-window, .recognition-panel, .practice-controls, .fallback-panel { position: relative; z-index: 1; }
.practice-meta { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.practice-meta h1 { margin: 0; font-family: "Germania One", serif; font-size: clamp(30px, 3.6vw, 52px); font-weight: 400; }
.live-metrics { display: flex; border: 1px solid var(--border); }
.live-metrics span { min-width: 85px; padding: 10px; text-align: center; }
.live-metrics span + span { border-left: 1px solid var(--border); }
.live-metrics small { display: block; color: var(--muted); font-size: 9px; }
.live-metrics b { display: block; margin-top: 4px; color: var(--green); font-size: 20px; }

.scroll-window { flex: 1; min-height: 340px; max-height: 52vh; overflow-y: auto; padding: 55px clamp(22px, 5vw, 70px); border: 1px solid #8e7542; background: linear-gradient(90deg, rgba(58, 42, 22, 0.3), transparent 15% 85%, rgba(58, 42, 22, 0.3)), #b9a47b; color: #332a1e; box-shadow: inset 0 0 45px rgba(41, 28, 12, 0.64), 0 8px 30px #000; scrollbar-width: thin; scrollbar-color: #735c2d #a08b66; }
.sentence-track { display: grid; gap: 22px; }
.sentence-line { margin: 0; padding: 12px 8px; border-block: 1px solid transparent; text-align: center; font-size: clamp(20px, 2.25vw, 31px); line-height: 1.55; opacity: 0.47; transition: 0.3s ease; }
.sentence-line.is-current { border-color: rgba(113, 76, 18, 0.4); background: rgba(255, 242, 187, 0.14); opacity: 1; box-shadow: 0 8px 24px rgba(70, 48, 15, 0.11); }
.sentence-line.is-complete { opacity: 0.75; }
.word { transition: color 0.18s ease, text-shadow 0.18s ease; }
.word.is-matched { color: #17612b; text-shadow: 0 0 10px rgba(89, 255, 115, 0.22); }
.word.is-current { color: #7c4b00; text-decoration: underline; text-decoration-color: #c58f1c; text-underline-offset: 5px; }
.word.is-interim { color: #69a97a; text-shadow: 0 0 9px rgba(105, 169, 122, 0.25); animation: interim-word 0.9s ease-in-out infinite alternate; }
.word.is-final { color: #17612b; text-shadow: 0 0 10px rgba(89, 255, 115, 0.22); }
@keyframes interim-word { to { color: #3f8554; text-shadow: 0 0 13px rgba(63, 133, 84, 0.4); } }

[hidden] { display: none !important; }
.scroll-edge { position: sticky; z-index: 3; height: 20px; margin-inline: -30px; pointer-events: none; }
.scroll-edge.top { top: -55px; background: linear-gradient(#6c5839, transparent); }
.scroll-edge.bottom { bottom: -55px; background: linear-gradient(transparent, #6c5839); }

.recognition-panel { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 22px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.status-copy { display: flex; align-items: center; gap: 12px; }
.status-copy b, .status-copy small { display: block; }
.status-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.recording-dot { width: 10px; height: 10px; border-radius: 50%; background: #6a635b; }
.recording-dot.is-recording { background: #ff6565; box-shadow: 0 0 0 7px rgba(255, 73, 73, 0.12), 0 0 16px #ff3d3d; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { transform: scale(0.7); opacity: 0.7; } }
.listen-button { padding: 8px 0; background: none; color: var(--gold-bright); }

.practice-controls { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 12px; margin-top: 18px; }
.mic-button { display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 9px 18px; border: 1px solid #7dc37e; background: #122016; color: #d7f9d9; cursor: pointer; text-align: left; transition: 0.2s ease; }
.mic-button:hover { border-color: var(--green); background: #18301d; }
.mic-button.is-recording { border-color: #e96b6b; background: #321717; color: #ffe1dc; }
.mic-glyph { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid currentColor; border-radius: 50%; color: var(--green); font-size: 13px; box-shadow: inset 0 0 14px currentColor; }
.is-recording .mic-glyph { color: #ff7777; }
.mic-button b, .mic-button small { display: block; }
.mic-button small { margin-top: 3px; opacity: 0.6; font-size: 9px; letter-spacing: 0.12em; }
.finish-button { padding: 10px 16px; border: 1px solid var(--gold); background: #3a2c15; color: var(--gold-bright); font-weight: 700; }
.finish-button:disabled { opacity: 0.35; cursor: not-allowed; }
.finish-button:not(:disabled):hover { background: #58421e; }

.fallback-panel { margin-top: 16px; color: var(--muted); font-size: 12px; }
.fallback-panel summary { cursor: pointer; color: #aa9d87; }
.fallback-panel label { display: block; margin: 12px 0 6px; }
.fallback-panel textarea { width: 100%; resize: vertical; padding: 12px; border: 1px solid var(--border); background: #0c0b0a; color: var(--text); }
.fallback-panel .secondary-button { margin-top: 8px; }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(7px); }
.ornate-dialog { width: min(620px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--gold-dim); background: #15120f; box-shadow: var(--shadow); }
.ornate-dialog form { position: relative; padding: clamp(28px, 5vw, 50px); }
.ornate-dialog form::before, .result-shell::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(227, 191, 103, 0.18); pointer-events: none; }
.ornate-dialog h2, .result-dialog h2 { margin: 0; font-family: "Germania One", serif; font-size: 40px; font-weight: 400; }
.dialog-description { color: var(--muted); line-height: 1.6; }
.dialog-close { position: absolute; top: 16px; right: 16px; z-index: 2; width: 38px; height: 38px; border: 1px solid var(--border); background: #0e0c0b; color: var(--muted); cursor: pointer; font-size: 25px; }
.ornate-dialog label { display: block; margin: 18px 0; color: #c8bda9; font-size: 12px; letter-spacing: 0.07em; }
.ornate-dialog input, .ornate-dialog textarea, .ornate-dialog select { display: block; width: 100%; margin-top: 7px; padding: 12px; border: 1px solid var(--border); background: #0c0b0a; color: var(--text); resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { min-height: 20px; color: #f5a8a0; font-size: 12px; }

.result-dialog { width: min(570px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--gold); background: #100d0c; box-shadow: 0 0 0 8px #090707, 0 0 0 9px var(--gold-dim), var(--shadow); overflow: visible; }
.result-shell { position: relative; padding: 38px; text-align: center; }
.result-grade { width: 112px; height: 112px; margin: 6px auto 18px; display: grid; place-items: center; border: 2px solid var(--gold-bright); transform: rotate(45deg); background: #261c10; color: var(--gold-bright); font-family: "Germania One", serif; font-size: 78px; box-shadow: inset 0 0 30px rgba(219, 170, 60, 0.2), 0 0 40px rgba(207, 156, 46, 0.15); }
.result-grade::first-line { transform: rotate(-45deg); }
.attack-score { margin: 24px 0 16px; padding: 16px; border-block: 1px solid var(--border); }
.attack-score span { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.2em; }
.attack-score strong { display: block; color: var(--gold-bright); font-family: "Germania One", serif; font-size: 46px; }
.score-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); }
.score-breakdown span { padding: 13px 8px; background: #171310; }
.score-breakdown small { display: block; color: var(--muted); font-size: 10px; }
.score-breakdown b { display: block; margin-top: 5px; color: var(--green); font-size: 24px; }
.best-copy { color: var(--gold-bright); }
.review-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0; }
.review-words span { padding: 7px 10px; border: 1px solid var(--border); color: #d4c6af; font-size: 12px; }
.new-achievements { color: var(--green); font-size: 12px; }
.result-actions { display: grid; gap: 10px; margin-top: 24px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 360px; padding: 14px 18px; border: 1px solid var(--gold); background: #17120d; color: var(--text); box-shadow: var(--shadow); opacity: 0; transform: translateY(16px); pointer-events: none; transition: 0.25s ease; }
.toast.is-visible { opacity: 1; transform: none; }

@media (max-width: 960px) {
  .hero-overview { grid-template-columns: 1fr; min-height: auto; }
  .profile-panel { max-width: 620px; }
  .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-layout { grid-template-columns: 1fr; }
  .boss-stage { min-height: 480px; }
  .scroll-window { max-height: none; }
}

@media (max-width: 640px) {
  .app-header { height: 66px; padding: 0 16px; }
  .brand b { font-size: 16px; }
  .brand small, .connection-pill { display: none; }
  .brand-mark { width: 34px; }
  .hero-overview { padding: 64px 20px 50px; }
  .hero-overview::before { inset-left: 20%; }
  .hero-copy h1 { font-size: 48px; }
  .profile-panel .profile-level { min-height: 180px; }
  .profile-panel .profile-level strong { font-size: 72px; }
  .profile-panel > div { min-height: 90px; padding: 16px; }
  .content-section { padding: 48px 18px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .filter-bar { width: 100%; overflow-x: auto; }
  .filter-chip { flex: 1; }
  .article-grid { grid-template-columns: 1fr; }
  .article-card { min-height: 330px; }
  .practice-view { padding: 12px 10px 30px; }
  .practice-topbar { align-items: stretch; flex-direction: column; }
  .mode-switch button { flex: 1; padding-inline: 8px; }
  .battle-layout { border: 0; box-shadow: none; }
  .boss-stage { min-height: 390px; border: 1px solid var(--border); }
  .boss-header { padding: 20px; }
  .boss-health-wrap { right: 18px; bottom: 20px; left: 18px; }
  .scroll-console { padding: 34px 20px; }
  .practice-meta { flex-direction: column; }
  .live-metrics { align-self: flex-start; }
  .scroll-window { min-height: 360px; padding: 48px 18px; }
  .recognition-panel { align-items: flex-start; flex-direction: column; }
  .practice-controls { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .result-shell { padding: 30px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Mobile app shell: the product is designed as a portrait phone experience. */
body {
  background:
    radial-gradient(circle at 50% -10%, rgba(115, 67, 28, 0.17), transparent 28rem),
    #050505;
}

.app-header {
  width: min(100%, 480px);
  height: 64px;
  margin-inline: auto;
  padding: 0 16px;
}

main {
  width: min(100%, 480px);
  min-height: calc(100vh - 64px);
  border-inline: 1px solid rgba(199, 167, 90, 0.16);
  background: #090808;
}

.hero-overview {
  display: block;
  min-height: 0;
  padding: 48px 18px 28px;
}

.hero-overview::before {
  inset: 0;
  opacity: 0.24;
  background: linear-gradient(180deg, rgba(9, 8, 8, 0.04), #090808 72%), url("/assets/boss-concept.png") 50% 5% / 145% auto no-repeat;
  filter: grayscale(0.25) sepia(0.12);
  mask-image: none;
}

.hero-copy h1 { font-size: clamp(42px, 13vw, 61px); }
.hero-description { margin: 20px 0; font-size: 14px; line-height: 1.75; }
.hero-actions { align-items: stretch; flex-direction: column; gap: 12px; }
.hero-actions .primary-button { width: 100%; }
.hero-actions .text-button { align-self: center; }

.profile-panel {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 32px;
}

.profile-panel > div,
.profile-panel .profile-level {
  min-height: 82px;
  padding: 11px 8px;
}

.profile-panel .profile-level {
  grid-row: auto;
}

.profile-panel strong,
.profile-panel .profile-level strong {
  margin-top: 9px;
  font-size: 26px;
  line-height: 1;
}

.profile-level span,
.stat-label { font-size: 8px; letter-spacing: 0.08em; }

.content-section { padding: 38px 16px; }
.section-heading { align-items: stretch; flex-direction: column; gap: 18px; margin-bottom: 22px; }
.section-heading h2 { font-size: 38px; }
.filter-bar { width: 100%; }
.filter-chip { flex: 1; min-width: 0; padding-inline: 8px; }
.article-grid { grid-template-columns: 1fr; gap: 14px; }
.article-card { min-height: 292px; }
.article-card::before { background-size: 160% auto; }
.card-content { padding: 20px; }
.article-card h3 { font-size: 28px; }
.achievements-section { padding-top: 18px; }
.achievement-item, .achievement-empty { min-width: 220px; }

.practice-view { padding: 12px 10px 28px; }
.practice-topbar { align-items: stretch; flex-direction: column; margin-bottom: 12px; }
.back-button { align-self: flex-start; }
.mode-switch { width: 100%; }
.mode-switch button { flex: 1; padding: 10px 6px; }
.battle-layout { display: block; min-height: auto; border: 0; box-shadow: none; }
.boss-stage { min-height: 330px; border: 1px solid var(--border); }
.boss-art { transform: scale(1.46); transform-origin: 50% 16%; }
.boss-header { padding: 18px; }
.boss-header h2 { font-size: 32px; }
.boss-rank b { font-size: 30px; }
.boss-health-wrap { right: 16px; bottom: 17px; left: 16px; }
.boss-health-copy { font-size: 9px; }

.scroll-console {
  padding: 34px 18px 28px;
  border: 1px solid var(--border);
  border-top: 0;
}

.scroll-console::before { inset: 7px; }
.practice-meta { flex-direction: column; margin-bottom: 16px; }
.practice-meta h1 { font-size: 36px; }
.live-metrics { align-self: stretch; }
.live-metrics span { flex: 1; }
.scroll-window { min-height: 370px; max-height: 440px; padding: 48px 18px; }
.sentence-line { font-size: 23px; }
.recognition-panel { align-items: flex-start; flex-direction: column; }
.listen-button { min-height: 38px; }
.practice-controls { grid-template-columns: 1fr; }
.mic-button, .finish-button { min-height: 62px; }
.finish-button { width: 100%; }
.fallback-panel textarea { font-size: 16px; }

.ornate-dialog,
.result-dialog {
  width: min(456px, calc(100vw - 16px));
  max-height: calc(100vh - 20px);
  overflow-y: auto;
}

.ornate-dialog form { padding: 34px 22px; }
.result-shell { padding: 32px 20px; }
.result-grade { width: 92px; height: 92px; font-size: 62px; }
.attack-score strong { font-size: 42px; }
.score-breakdown b { font-size: 21px; }
.toast { right: 12px; bottom: 12px; left: 12px; max-width: none; }

@media (min-width: 700px) {
  body { padding-block: 18px; }
  .app-header { top: 18px; border-top: 1px solid var(--border); }
  main { box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72); }
}
