/* ===================================================================
   TYPEBLADE: SHADOW DOJO  -  styles
   Palette: sumi-ink black, crimson ink, bone paper, a touch of gold.
   Only system fonts are used; everything else is CSS / SVG.
   =================================================================== */
:root {
  --ink: #0a0708;
  --ink2: #150a0c;
  --crimson: #b3141f;
  --crimson2: #7d0f18;
  --crimson3: #4a0a10;
  --ember: #e0452b;
  --bone: #eadfcf;
  --bone2: #b9ab97;
  --gold: #d9a441;
  --disp: "Hiragino Mincho ProN", "Yu Mincho", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ui: "Trebuchet MS", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; height: 100dvh; min-height: 100%;
  overflow: hidden; background: #050203; color: var(--bone);
  font-family: var(--ui); -webkit-user-select: none; user-select: none;
  touch-action: manipulation; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, input:focus-visible { outline: 2px dashed var(--gold); outline-offset: 4px; }

#game-root {
  position: fixed; inset: 0; width: 100%; height: 100%; height: 100vh; height: 100dvh; min-height: 100%;
  display: flex; flex-direction: column; overflow: hidden; background: #050203; z-index: 1;
}
#game-root:fullscreen, #game-root:-webkit-full-screen {
  width: 100vw; height: 100vh; height: 100dvh; background: #050203;
}
.immersive-fullscreen #game-root,
html.immersive-fullscreen,
body.immersive-fullscreen {
  width: 100vw !important; height: 100vh !important; height: 100dvh !important;
}

#app {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; overflow: hidden; z-index: 1;
}
#stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; display: none; padding: calc(8px + var(--sat)) calc(10px + var(--sar)) 8px calc(10px + var(--sal)); z-index: 10; }
body[data-state="playing"] #hud, body[data-state="paused"] #hud, body[data-state="dying"] #hud { display: block; }
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; width: 100%; }
.hearts-wrap { display: flex; flex-direction: column; gap: 3px; max-width: 38%; min-width: 96px; }
#hearts { display: flex; gap: 7px; padding-top: 6px; min-width: 0; flex-wrap: wrap; }
/* Life sigil: a crimson seal (rotated square) - no organic/drop shapes */
.sigil {
  width: 14px; height: 14px; margin: 3px; border-radius: 3px; transform: rotate(45deg);
  background: linear-gradient(135deg, #ff8a6a, var(--crimson) 55%, var(--crimson3));
  box-shadow: 0 0 8px rgba(224, 69, 43, .7); transition: transform .2s;
}
.sigil.empty { background: transparent; border: 2px solid var(--crimson3); box-shadow: none; }
.sigil.hurt { animation: sigilHurt .45s; }
@keyframes sigilHurt { 0% { transform: rotate(45deg) scale(1.8); } 100% { transform: rotate(45deg) scale(1); } }

#lifeGoal { pointer-events: none; text-shadow: 0 1px 0 #000; }
#lifeTxt { font-size: .6rem; letter-spacing: .14em; font-weight: 800; color: var(--bone2); white-space: nowrap; }
#lifeGoal .bar { width: min(92px, 22vw); height: 4px; margin-top: 3px; background: rgba(0, 0, 0, .6); border: 1px solid var(--crimson3); border-radius: 3px; overflow: hidden; }
#lifeFill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7a5212, var(--gold)); transition: width .15s; }
#lifeGoal.near #lifeTxt { color: var(--gold); }
#lifeGoal.near .bar { border-color: var(--gold); }

.hud-mid { text-align: center; text-shadow: 0 2px 0 #000; }
#waveLabel { font: italic 900 clamp(1rem, 3.6vw, 1.6rem)/1 var(--disp); letter-spacing: .12em; color: var(--bone); }
#modeLabel { font-size: clamp(.6rem, 1.8vw, .75rem); letter-spacing: .3em; color: var(--crimson); font-weight: 700; margin-top: 3px; }
.hud-right {
  display: flex; align-items: center; gap: 6px; pointer-events: auto;
  flex-wrap: nowrap; justify-content: flex-end;
}
.hud-chips { display: flex; align-items: center; gap: 6px; }
.hud-actions { display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; min-width: 52px; justify-content: center;
  background: linear-gradient(180deg, rgba(20, 8, 10, .85), rgba(8, 3, 4, .85)); border: 1px solid var(--crimson3);
  border-radius: 14px 4px 14px 4px; font-weight: 800; font-size: clamp(.8rem, 2.6vw, 1rem); text-shadow: 0 1px 0 #000;
}
.chip.big { font-size: 1.05rem; padding: 6px 14px 6px 10px; }
.chip.score b { color: var(--bone); letter-spacing: .05em; }
.chip.pulse { animation: chipPulse .25s; }
@keyframes chipPulse { 50% { transform: scale(1.18); border-color: var(--gold); } }
.coin {
  display: inline-block; position: relative; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe6a0, var(--gold) 60%, #8a5a16);
}
.coin::after { content: ""; position: absolute; inset: 4.5px; background: #2a1408; border-radius: 1px; }
.iconbtn {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; color: var(--bone);
  background: radial-gradient(circle at 35% 30%, #2a0e12, #0c0506); border: 2px solid var(--crimson2);
  border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%; transition: transform .1s, border-color .1s; pointer-events: auto;
  position: relative;
}
.iconbtn:hover { transform: scale(1.06) rotate(-3deg); border-color: var(--crimson); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 22px; height: 22px; pointer-events: none; }
.muted .waves { display: none; }
#btnMenuMute:not(.muted) .slash, .toggle-sound:not(.muted) .slash { display: none; }
.iconbtn .slash { display: none; }
.iconbtn.muted .slash { display: block; }

/* Combo */
#comboBox { position: absolute; left: 12px; top: 74px; opacity: 0; transform: translateX(-12px); transition: opacity .2s, transform .2s; text-shadow: 0 2px 0 #000; }
#comboBox.on { opacity: 1; transform: none; }
#comboMult { font: italic 900 clamp(1.6rem, 6vw, 2.6rem)/1 var(--disp); color: var(--ember); filter: drop-shadow(0 0 8px rgba(224, 69, 43, .6)); }
#comboMult.pop { animation: comboPop .28s; }
@keyframes comboPop { 0% { transform: scale(1.6) rotate(-6deg); color: #fff; } 100% { transform: none; } }
#comboCount { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--bone2); margin-top: 2px; font-weight: 700; }
#comboBar { width: 96px; height: 5px; margin-top: 5px; background: rgba(0, 0, 0, .6); border: 1px solid var(--crimson3); border-radius: 3px; overflow: hidden; }
#comboBar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--crimson2), var(--ember)); transition: width .15s; }

/* Boss bar */
#bossBar { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); width: min(70%, 420px); text-align: center; display: none; }
#bossBar.on { display: block; }
#bossBar span { font: italic 900 .9rem var(--disp); letter-spacing: .3em; color: var(--crimson); text-shadow: 0 2px 0 #000; }
#bossBar .bar { margin-top: 4px; height: 10px; background: rgba(0, 0, 0, .75); border: 2px solid var(--crimson2); border-radius: 6px 2px 6px 2px; overflow: hidden; }
#bossBar .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--crimson3), var(--crimson) 60%, var(--ember)); transition: width .35s; }

/* Banner + hint */
.banner { position: absolute; left: 0; right: 0; top: 20%; text-align: center; pointer-events: none; opacity: 0; overflow: visible; }
.banner b { display: block; padding: 0.12em 0; font: italic 900 clamp(2rem, 8vw, 4.4rem)/1.25 var(--disp); letter-spacing: .08em; color: var(--bone); text-shadow: 0 4px 0 var(--crimson2), 0 0 28px rgba(179, 20, 31, .8); filter: url(#rough-soft); overflow: visible; }
.banner span { display: block; margin-top: 10px; font-size: clamp(.7rem, 2.4vw, 1rem); letter-spacing: .4em; text-transform: uppercase; color: var(--bone2); text-shadow: 0 2px 0 #000; }
.banner.boss b { color: #ffd9cf; text-shadow: 0 4px 0 #4a0a10, 0 0 36px rgba(255, 40, 40, .95); }
.banner.warn b { color: #ffd27a; text-shadow: 0 4px 0 #6b4a0a, 0 0 30px rgba(255, 170, 40, .85); font-size: clamp(1.5rem, 6vw, 3.2rem); }
.banner.warn span { color: #ffdca0; }
.banner.go { animation: bannerGo 2.1s ease forwards; }
@keyframes bannerGo {
  0% { opacity: 0; transform: translateY(14px) scale(1.3); }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scale(.98); }
}
#hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: 88%; text-align: center; padding: 7px 16px; font-size: clamp(.75rem, 2.4vw, .95rem); letter-spacing: .06em;
  background: rgba(10, 4, 6, .8); border: 1px solid var(--crimson2); border-radius: 12px 3px 12px 3px; opacity: 0; transition: opacity .4s; pointer-events: none; }
#hint.on { opacity: 1; }
#hint kbd { color: var(--gold); font-weight: 800; }

/* --------------------------------------------------------- On-screen keys */
#osk {
  display: none; flex: 0 0 auto;
  padding: 6px 4px calc(6px + var(--sab));
  background: linear-gradient(#140709, #050203);
  border-top: 2px solid var(--crimson3);
  z-index: 15;
}
body.osk-on #osk { display: block; }
.osk-row { display: flex; justify-content: center; gap: clamp(3px, .9vw, 6px); margin-bottom: clamp(3px, .9vw, 6px); }
.osk-row:last-child { margin-bottom: 0; }
.key {
  flex: 1 1 0; max-width: 62px; height: clamp(36px, 7.6vh, 54px); display: grid; place-items: center;
  font: 800 clamp(.95rem, 4.2vw, 1.3rem) var(--ui); color: var(--bone);
  background: linear-gradient(180deg, #2b1215, #140709); border: 1px solid #5c1a20; border-bottom: 3px solid var(--crimson2);
  border-radius: 8px 3px 8px 3px; touch-action: none; transition: transform .05s;
}
.key.wide { flex: 1.5 1 0; max-width: 92px; color: var(--bone2); }
.key.down { transform: translateY(2px); background: linear-gradient(180deg, var(--crimson2), #3a0a10); border-bottom-width: 1px; }
.key.hint { color: #fff; border-color: var(--gold); box-shadow: 0 0 12px rgba(217, 164, 65, .8), inset 0 0 8px rgba(217, 164, 65, .35); }

/* --------------------------------------------------------------- Screens */
.screen {
  position: absolute; inset: 0; width: 100%; height: 100%; height: 100vh; height: 100dvh; min-height: 100%; display: none;
  padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal));
  z-index: 30; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.screen.show { display: flex; }
.screen.dim { background: radial-gradient(ellipse at center, rgba(14, 4, 6, .78), rgba(3, 1, 2, .92)); }

/* Paper-and-ink panel; the ::before is the ragged painted card */
.panel {
  position: relative; isolation: isolate; width: min(94vw, 520px); max-height: min(92vh, 92dvh);
  display: flex; flex-direction: column; overflow: hidden;
  padding: 22px 26px 20px; margin: auto; animation: panelIn .28s ease-out;
}
#screen-over .panel, #screen-pause .panel { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel.wide { width: min(96vw, 720px); }
.panel.narrow { width: min(90vw, 360px); }
.panel::before {
  content: ""; position: absolute; inset: 0; z-index: -1; filter: url(#rough);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(179, 20, 31, .22), transparent 60%),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #1a0a0d, #0b0506);
  border: 3px solid var(--crimson2); border-radius: 10px 22px 8px 26px / 22px 8px 24px 10px;
  box-shadow: 0 0 0 2px #000, 0 18px 50px rgba(0, 0, 0, .7), inset 0 0 40px rgba(0, 0, 0, .7);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel h2 { margin: 0; font: italic 900 clamp(1.5rem, 5vw, 2.1rem)/1.05 var(--disp); letter-spacing: .08em; color: var(--bone); text-shadow: 0 3px 0 var(--crimson2); }
.panel-foot { display: flex; justify-content: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.sub { margin: 0 0 12px; color: var(--bone2); letter-spacing: .05em; text-align: center; font-size: .95rem; }
.stack { display: flex; flex-direction: column; gap: 14px; align-items: stretch; margin-top: 10px; }

/* ----------------------------------------------------------- Brush buttons */
.btn {
  position: relative; isolation: isolate; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; overflow: visible;
  padding: .75em 1.7em; min-width: 120px; color: var(--bone); text-align: center;
  font: italic 900 1.05rem/1.1 var(--disp); letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 2px 0 rgba(0, 0, 0, .8);
  transition: transform .12s;
}
.btn small { font: 600 .68rem/1.2 var(--ui); font-style: normal; letter-spacing: .12em; text-transform: none; color: #f0c9bd; margin-top: 5px; opacity: .92; }
.btn small em { font-style: normal; background: #000; color: var(--gold); padding: 1px 5px; border-radius: 3px; margin-right: 5px; font-weight: 800; letter-spacing: .08em; }
.btn::before {
  content: ""; position: absolute; inset: -3px -8px; z-index: -1; filter: url(#rough);
  background: repeating-linear-gradient(97deg, rgba(0, 0, 0, .13) 0 2px, transparent 2px 6px), linear-gradient(100deg, var(--crimson2), var(--crimson) 45%, #8c1019);
  border-radius: 6px 20px 5px 24px / 22px 6px 20px 8px; box-shadow: 0 4px 0 #2a0508, 0 8px 18px rgba(0, 0, 0, .55);
  transition: transform .12s, filter .12s;
}
.btn:hover::before { transform: scale(1.04) rotate(-.7deg); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); }
.btn:active::before { transform: scale(.98); }
.btn.dark::before { background: repeating-linear-gradient(97deg, rgba(255, 255, 255, .03) 0 2px, transparent 2px 6px), linear-gradient(100deg, #1b0d10, #2a1316 50%, #150a0c); box-shadow: 0 4px 0 #000, inset 0 0 0 2px #5c1a20, 0 8px 18px rgba(0, 0, 0, .55); }
.btn.gold::before { background: linear-gradient(100deg, #7a5212, var(--gold) 50%, #8a5e16); }
.btn.gold { color: #1b0d04; text-shadow: 0 1px 0 rgba(255, 230, 160, .6); }
.btn.gold small { color: #3a1f06; }
.btn.big { min-width: 240px; padding: .85em 2em; font-size: 1.25rem; }
.btn[disabled], .btn.off { filter: grayscale(.9) brightness(.6); pointer-events: none; }
.btn-row { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.badge { position: absolute; right: -10px; top: -12px; min-width: 22px; height: 22px; padding: 0 6px; display: none; place-items: center; font: 900 .75rem var(--ui); font-style: normal; color: #1b0d04; background: var(--gold); border-radius: 50%; animation: badgeBob 1.2s ease-in-out infinite; }
.badge.on { display: grid; }
@keyframes badgeBob { 50% { transform: translateY(-3px) scale(1.1); } }

.toggle { min-width: 92px; padding: 7px 14px; font: 800 .85rem var(--ui); letter-spacing: .1em; color: var(--bone); background: #1b0d10; border: 2px solid var(--crimson3); border-radius: 12px 3px 12px 3px; }
.toggle.on { background: var(--crimson2); border-color: var(--crimson); }

/* ---------------------------------------------------------------- Logo */
.logo { text-align: left; margin-bottom: 20px; overflow: visible; }
.logo-main {
  /* line-height 1.3 (not .95) + padding give descenders ("yp") and the text-shadow/glow
     real room in the box itself, instead of relying only on the SVG filter region -
     this prevents clipping the bottom of "Typeblade" across different screen builds. */
  margin: -0.22em 0 -0.22em; padding: 0.1em 0.05em; font: italic 900 clamp(2.6rem, 11vw, 5.4rem)/1.3 var(--disp);
  letter-spacing: .02em; color: var(--bone); overflow: visible;
  text-shadow: 3px 4px 0 var(--crimson), 6px 8px 0 var(--crimson3), 0 0 40px rgba(179, 20, 31, .55); filter: url(#rough);
  transform: rotate(-2deg);
}
.logo-main.small { font-size: clamp(2.2rem, 9vw, 3.8rem); }
.logo-sub { display: flex; align-items: center; gap: 12px; margin-top: 10px; font: 700 clamp(.8rem, 2.8vw, 1.1rem) var(--ui); letter-spacing: .55em; text-transform: uppercase; color: var(--bone2); }
.hanko { width: 30px; height: 30px; flex: none; transform: rotate(6deg); }

/* Main menu layout: left column on landscape, bottom on portrait (scene shifts to match) */
.screen.menu { justify-content: flex-start; align-items: center; padding-left: clamp(16px, 5vw, 70px); background: linear-gradient(90deg, rgba(5, 2, 3, .9), rgba(5, 2, 3, .55) 40%, transparent 70%); }
.menu-wrap { width: min(440px, 92vw); margin: auto 0; }
.menu-btns { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; padding-left: 8px; }
.menu-btns .btn.big { align-items: flex-start; text-align: left; min-width: min(300px, 80vw); }
.menu-stats { margin-top: 22px; font-size: .75rem; letter-spacing: .14em; color: var(--bone2); line-height: 1.7; text-transform: uppercase; }
.menu-stats b { color: var(--bone); }
.top-bar {
  position: fixed; top: calc(10px + var(--sat)); left: calc(12px + var(--sal)); right: calc(12px + var(--sar));
  display: flex; justify-content: space-between; align-items: center; z-index: 25; pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.top-btns { display: flex; gap: 8px; align-items: center; }

/* ----------------------------------------------------------------- Loading */
#loading { z-index: 60; background: radial-gradient(ellipse at 50% 40%, #2a070c, #050203 70%); }
#loading.hide { opacity: 0; pointer-events: none; transition: opacity .5s; }
.load-card { text-align: center; width: min(86vw, 420px); }
.load-card .logo-sub { justify-content: center; }
.load-bar { margin: 30px auto 14px; height: 12px; border: 2px solid var(--crimson2); border-radius: 8px 2px 8px 2px; background: #0a0405; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--crimson3), var(--crimson), var(--ember)); transition: width .25s; filter: url(#rough-soft); }
#loadTip { color: var(--bone2); font-size: .85rem; letter-spacing: .18em; margin: 0; text-transform: uppercase; }

/* ------------------------------------------------------------ Shop / lists */
.tabs { display: flex; gap: 10px; margin-bottom: 12px; }
.tab { flex: 1; padding: 9px 0; font: italic 900 1rem var(--disp); letter-spacing: .14em; text-transform: uppercase; color: var(--bone2); background: #130809; border: 2px solid var(--crimson3); border-radius: 12px 3px 12px 3px; }
.tab.on { color: var(--bone); background: var(--crimson2); border-color: var(--crimson); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 50vh; overflow: auto; padding: 4px; }
.card { position: relative; padding: 8px 8px 10px; text-align: center; background: linear-gradient(180deg, #1c0c0f, #0d0607); border: 2px solid var(--crimson3); border-radius: 14px 4px 14px 4px; }
.card.equipped { border-color: var(--gold); box-shadow: 0 0 14px rgba(217, 164, 65, .3); }
.card canvas { width: 100%; height: 96px; display: block; }
.card h3 { margin: 4px 0 2px; font: italic 900 .95rem var(--disp); letter-spacing: .05em; }
.card p { margin: 0 0 8px; min-height: 2.4em; font-size: .72rem; color: var(--bone2); line-height: 1.25; }
.card .buy { width: 100%; padding: 7px 4px; font: 800 .8rem var(--ui); letter-spacing: .08em; text-transform: uppercase; background: var(--crimson2); border: 2px solid var(--crimson); border-radius: 10px 3px 10px 3px; color: var(--bone); display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.card .buy.own { background: #1d1012; border-color: #5c1a20; }
.card .buy.eq { background: var(--gold); border-color: #8a5e16; color: #1b0d04; }
.card .buy.poor { background: #1b0d10; border-color: var(--crimson3); color: var(--bone2); }

.set-list { display: flex; flex-direction: column; gap: 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .9rem; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 55%; height: 10px; background: #0a0405; border: 2px solid var(--crimson3); border-radius: 6px 2px 6px 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 26px; background: linear-gradient(180deg, var(--ember), var(--crimson2)); border: 2px solid #000; border-radius: 40% 60% 50% 50%; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 20px; height: 24px; background: var(--crimson); border: 2px solid #000; border-radius: 40% 60% 50% 50%; cursor: pointer; }

/* Game over */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { text-align: center; padding: 8px 4px; background: rgba(0, 0, 0, .35); border: 1px solid var(--crimson3); border-radius: 10px 3px 10px 3px; }
.stat b { display: block; font: italic 900 1.15rem var(--disp); color: var(--bone); }
.stat span { font-size: .56rem; letter-spacing: .1em; text-transform: uppercase; color: var(--bone2); }
.badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 6px; margin-bottom: 4px; }
.badges i { font-style: normal; font-weight: 900; font-size: .7rem; letter-spacing: .14em; padding: 3px 10px; color: #1b0d04; background: var(--gold); border-radius: 10px 2px 10px 2px; }

/* Tutorial */
.tut-body { min-height: 220px; text-align: center; font-size: .98rem; line-height: 1.55; }
.tut-body p { margin: 8px auto; max-width: 520px; color: var(--bone); }
.tut-body p.dim { color: var(--bone2); font-size: .85rem; }
kbd.k { display: inline-block; min-width: 26px; padding: 2px 7px; margin: 0 2px; font: 800 .9rem var(--ui); color: var(--bone); background: #2b1215; border: 1px solid #5c1a20; border-bottom: 3px solid var(--crimson2); border-radius: 6px 2px 6px 2px; }
.tut-foes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.foe { padding: 6px; background: rgba(0, 0, 0, .35); border: 1px solid var(--crimson3); border-radius: 12px 3px 12px 3px; }
.foe canvas { width: 100%; height: 90px; }
.foe b { display: block; font: italic 900 .95rem var(--disp); letter-spacing: .05em; }
.foe span { font-size: .72rem; color: var(--bone2); line-height: 1.3; display: block; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #2a1316; border: 1px solid var(--crimson3); }
.dots i.on { background: var(--crimson); }

/* Daily */
.daily-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { padding: 8px 2px; text-align: center; background: rgba(0, 0, 0, .35); border: 2px solid var(--crimson3); border-radius: 10px 3px 10px 3px; font-size: .7rem; letter-spacing: .06em; }
.day b { display: block; margin-bottom: 6px; color: var(--bone2); font-size: .62rem; text-transform: uppercase; }
.day i { display: block; font-style: normal; font-weight: 900; margin-top: 4px; font-size: .9rem; }
.day.today { border-color: var(--gold); background: rgba(217, 164, 65, .12); animation: badgeBob 1.4s ease-in-out infinite; }
.day.done { opacity: .45; }
.day.done::after { content: "✓"; display: block; color: var(--gold); font-weight: 900; }
@media (max-width: 520px) { .daily-grid { grid-template-columns: repeat(4, 1fr); } }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 80; padding: 10px 20px; max-width: 90vw; text-align: center; font-weight: 700; letter-spacing: .06em; color: var(--bone); background: rgba(10, 3, 5, .95); border: 2px solid var(--crimson); border-radius: 14px 3px 14px 3px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------- Responsive tuning */
@media (max-aspect-ratio: 1/1) {
  /* Portrait: menu sits low, the scene lifts up to make room */
  .screen.menu {
    flex-direction: column;
    justify-content: flex-start; align-items: stretch;
    padding: calc(52px + var(--sat)) max(14px, var(--sar)) calc(14px + var(--sab)) max(14px, var(--sal));
    background: linear-gradient(0deg, rgba(5, 2, 3, .96), rgba(5, 2, 3, .65) 55%, transparent 85%);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .menu-wrap { margin: auto auto 0; width: min(440px, 100%); padding-bottom: 6px; }
  .logo { text-align: center; margin-bottom: 12px; }
  .logo-main { font-size: clamp(2.2rem, 11vw, 3.8rem); }
  .logo-sub { justify-content: center; letter-spacing: .4em; }
  .menu-btns { align-items: stretch; padding: 0; gap: 12px; }
  .menu-btns .btn,
  .menu-btns .btn.big { align-items: center; text-align: center; width: 100%; min-width: 0; }
  .btn-row { width: 100%; gap: 10px; }
  .btn-row .btn { flex: 1 1 0; min-width: 0; }
  .menu-stats { text-align: center; margin-top: 14px; }
}
@media (max-height: 560px) {
  .panel { padding: 12px 16px 12px; max-height: min(94vh, 94dvh); }
  .panel-head { margin-bottom: 6px; }
  .stack { gap: 8px; }
  .btn { padding: .45em 1.2em; font-size: .9rem; min-height: 40px; }
  .btn.big { padding: .52em 1.4em; font-size: 1rem; }
  .menu-btns { gap: 8px; }
  .logo { margin-bottom: 8px; }
  .logo-main { font-size: clamp(1.8rem, 7vh, 3rem); }
  .menu-stats { margin-top: 8px; }
  .tut-body { min-height: 120px; font-size: .84rem; }
  .shop-grid { max-height: 40vh; }
  .card canvas { height: 60px; }
  .stats { gap: 4px; }
  .stat b { font-size: 1rem; }
  .hearts-wrap { max-width: 38%; }
  #hud { padding: max(4px, var(--sat)) max(6px, var(--sar)) 4px max(6px, var(--sal)); }
}
@media (max-height: 480px) and (orientation: landscape) {
  .menu-stats { display: none; }
  .logo-sub { display: none; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .stat { padding: 4px 2px; }
  .stat b { font-size: .95rem; }
  .stat span { font-size: .5rem; }
}
/* Narrow phones: clean compact HUD */
@media (max-width: 560px) {
  .iconbtn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  .iconbtn svg { width: 20px; height: 20px; }
  .chip { min-width: 40px; padding: 3px 6px; font-size: .82rem; gap: 4px; }
  .hearts-wrap { max-width: 32%; min-width: 70px; }
  #hud { padding: max(6px, var(--sat)) max(6px, var(--sar)) 6px max(6px, var(--sal)); }
  #comboBox { top: calc(64px + var(--sat)); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
/* Ultra-compact phones (320px - 360px) */
@media (max-width: 360px) {
  .menu-wrap { width: 100%; }
  .logo-main { font-size: clamp(1.9rem, 9.5vw, 2.6rem); }
  .btn-row { gap: 6px; }
  .btn { padding: .45em .7em; font-size: .86rem; letter-spacing: .06em; min-height: 40px; }
  .btn small { font-size: .6rem; }
  .shop-grid { grid-template-columns: 1fr; }
  .daily-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .day { padding: 6px 1px; font-size: .65rem; }
  .hearts-wrap { min-width: 68px; }
  .sigil { width: 11px; height: 11px; margin: 2px; }
  .chip { min-width: 36px; padding: 2px 5px; font-size: .76rem; }
  .iconbtn { width: 38px; height: 38px; min-width: 38px; min-height: 38px; }
  .iconbtn svg { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .badge, .day.today { animation: none; }
}

/* ------------------------------------------------ v2: lifeline, hints, themes */
#btnHint { display: none; }
body.osk-on #btnHint { display: inline-grid; }
#btnHint.off { --slash: 1; opacity: .75; }
#comboBox { top: 74px; }

.seg { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; width: 62%; }
.seg button { flex: 1 1 auto; padding: 6px 8px; font: 800 .72rem var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--bone2); background: #1b0d10; border: 2px solid var(--crimson3); border-radius: 10px 3px 10px 3px; }
.seg button.on { background: var(--crimson2); border-color: var(--crimson); color: var(--bone); }

/* Day theme: lighter sky, so HUD text gets a stronger outline */
body[data-theme="day"] #waveLabel, body[data-theme="day"] #modeLabel, body[data-theme="day"] #lifeTxt, body[data-theme="day"] #comboCount { text-shadow: 0 0 6px #000, 0 2px 0 #000; }
body[data-theme="day"] .banner b { color: #fff; text-shadow: 0 3px 0 #4a0d10, 0 0 20px rgba(0, 0, 0, .85); }
body[data-theme="day"] .banner span { color: #fff; text-shadow: 0 2px 4px #000; }
