:root {
  --ink: #0b0614;
  --paper: #f3ead8;
  --red: #c8102e;
  --gold: #ffd76a;
  --glow: #8fd8ff;
  --ui: "Zen Kaku Gothic New", system-ui, sans-serif;
  --brush: "Yuji Syuku", "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #fff; font-family: var(--ui); }
canvas { display: block; position: fixed; inset: 0; touch-action: none; cursor: crosshair; }
button { font: inherit; color: inherit; }

#ui { position: fixed; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); pointer-events: auto; text-align: center;
  animation: fadeIn .35s ease both;
}
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- title ---------- */
#title { background: radial-gradient(ellipse at 50% 40%, rgba(6,3,14,0) 0%, rgba(6,3,14,.55) 70%); }
.logo { position: relative; display: flex; flex-direction: column; align-items: center; line-height: 1; user-select: none; }
.logo .kanji {
  font-family: var(--brush); font-size: clamp(92px, 24vw, 190px); color: #fff;
  text-shadow: 0 0 30px rgba(143,216,255,.45), 0 6px 0 rgba(0,0,0,.35);
  animation: logoIn 1.1s cubic-bezier(.2,.9,.2,1) both .15s;
}
.logo .latin {
  font-weight: 900; letter-spacing: .6em; margin-left: .6em; font-size: clamp(16px, 3.6vw, 24px); color: var(--gold);
  animation: fadeIn .8s ease both .9s;
}
.logo-slash {
  position: absolute; left: -12%; right: -12%; top: 42%; height: 4px;
  background: linear-gradient(90deg, transparent, #fff 30%, #fff 70%, transparent);
  box-shadow: 0 0 18px 4px var(--glow); transform: rotate(-14deg) scaleX(0); transform-origin: left;
  animation: slash 1.1s cubic-bezier(.7,0,.2,1) both .05s;
}
@keyframes logoIn {
  0% { clip-path: inset(-30% 100% -30% -30%); transform: translateX(-12px); opacity: .6; }
  45% { clip-path: inset(-30% -30% -30% -30%); transform: none; opacity: 1; }
  52% { transform: translate(6px, -2px); }
  60%, 100% { clip-path: inset(-30% -30% -30% -30%); transform: none; }
}
@keyframes slash {
  0% { transform: rotate(-14deg) scaleX(0); opacity: 1; }
  40% { transform: rotate(-14deg) scaleX(1); opacity: 1; }
  100% { transform: rotate(-14deg) scaleX(1); opacity: 0; }
}
.tag { margin: -6px 0 4px; color: rgba(255,255,255,.75); font-weight: 500; letter-spacing: .04em; animation: fadeIn .8s ease both 1s; }

.menu { display: flex; flex-direction: column; gap: 10px; width: min(300px, 86vw); animation: fadeIn .6s ease both 1.1s; }
.menu.row { flex-direction: row; width: auto; }
.btn {
  position: relative; border: 1px solid rgba(255,255,255,.25); background: rgba(12,6,24,.55); backdrop-filter: blur(4px);
  padding: 13px 20px; font-weight: 900; font-size: 17px; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); transition: background .15s, transform .15s, color .15s;
  overflow: hidden;
}
.btn small { font-weight: 500; letter-spacing: .04em; text-transform: none; opacity: .65; margin-left: 6px; font-size: 12px; }
.btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-20deg);
}
.btn:hover::after, .btn:focus-visible::after { left: 130%; transition: left .45s ease; }
.btn:hover, .btn:focus-visible { background: rgba(255,255,255,.12); transform: translateX(3px); outline: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); border-color: #ff4a5e; box-shadow: 0 0 24px rgba(200,16,46,.45); }
.btn.primary:hover { background: #e01836; }
.btn.ghost { background: transparent; }

.stats { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: rgba(255,255,255,.65); animation: fadeIn .6s ease both 1.2s; }
.stats b { color: #fff; margin-left: 4px; }
.howto {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; max-width: 520px; font-size: 12.5px; color: rgba(255,255,255,.6);
  animation: fadeIn .6s ease both 1.3s;
}
.howto b { color: var(--gold); font-weight: 700; }
.howto .keys { width: 100%; opacity: .7; }
@media (hover: none) { .howto .keys { display: none; } }

.icon-btn {
  position: absolute; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(10,5,20,.5); cursor: pointer; pointer-events: auto; font-size: 15px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }
#pauseBtn { top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-size: 11px; letter-spacing: -1px; opacity: .7; }

/* ---------- headings ---------- */
.screen h2 { margin: 0; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; font-size: 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.screen h2 span { font-family: var(--brush); font-size: 58px; letter-spacing: 0; text-transform: none; color: var(--gold); text-shadow: 0 0 20px rgba(255,215,106,.35); }
.hint { margin: 0; font-size: 13px; color: rgba(255,255,255,.6); }

/* ---------- relic draft ---------- */
#draft { background: rgba(6,3,14,.6); backdrop-filter: blur(2px); }
.cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 820px; }
.card {
  position: relative; width: min(220px, 28vw); min-width: 150px; min-height: 250px; padding: 22px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer;
  background: linear-gradient(180deg, #f6eedd, #e6d8bb); color: #1a0e0e; border: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.5), inset 0 0 0 2px rgba(120,20,30,.25), inset 0 0 0 6px #f6eedd, inset 0 0 0 7px rgba(120,20,30,.4);
  animation: cardIn .5s cubic-bezier(.2,1.2,.3,1) both;
  transition: transform .18s, box-shadow .18s;
}
.card:hover, .card:focus-visible { transform: translateY(-8px) rotate(-1deg); outline: none; box-shadow: 0 16px 50px rgba(0,0,0,.6), 0 0 0 3px var(--gold), inset 0 0 0 6px #f6eedd, inset 0 0 0 7px rgba(120,20,30,.4); }
.card .k { font-family: var(--brush); font-size: 74px; line-height: 1; color: var(--red); }
.card .n { font-weight: 900; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; }
.card .n em { font-style: normal; background: var(--red); color: #fff; padding: 0 6px; margin-left: 4px; font-size: 12px; }
.card .d { font-size: 13.5px; line-height: 1.45; color: #4a3434; }
.card .key { position: absolute; top: 8px; right: 12px; font-weight: 900; font-size: 12px; color: rgba(90,20,30,.45); }
.card.picked { animation: picked .3s ease forwards; }
.card.picked::after {
  content: ""; position: absolute; left: -10%; right: -10%; top: 50%; height: 4px; background: #fff;
  box-shadow: 0 0 20px 6px var(--gold); transform: rotate(-24deg);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(60px) rotate(4deg) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes picked { 0% { transform: scale(1.04); } 100% { transform: scale(1.12); opacity: 0; filter: brightness(2); } }

/* ---------- pause ---------- */
#pause { background: rgba(6,3,14,.65); backdrop-filter: blur(3px); }
.relics { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; }
.relics span { font-family: var(--brush); font-size: 26px; color: var(--gold); background: rgba(255,255,255,.06); padding: 6px 10px; display: flex; align-items: center; gap: 6px; }
.relics small { font-family: var(--ui); font-size: 12px; color: rgba(255,255,255,.75); }
.relics .none { font-family: var(--ui); font-size: 13px; color: rgba(255,255,255,.6); background: none; }

/* ---------- results ---------- */
#dead { background: radial-gradient(ellipse at 50% 50%, rgba(6,3,14,.55), rgba(6,3,14,.9)); }
.result {
  width: min(420px, 92vw); padding: 26px 22px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(20,10,34,.92), rgba(10,5,18,.95)); border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: cardIn .55s cubic-bezier(.2,1.1,.3,1) both;
  position: relative; overflow: hidden;
}
.result::before {
  content: ""; position: absolute; left: -20%; right: -20%; top: 70px; height: 2px; background: #fff; opacity: .0;
  box-shadow: 0 0 16px 4px var(--red); transform: rotate(-8deg); animation: resSlash .7s ease .1s both;
}
@keyframes resSlash { 0% { opacity: 1; transform: rotate(-8deg) scaleX(0); transform-origin: left; } 50% { opacity: 1; transform: rotate(-8deg) scaleX(1); } 100% { opacity: 0; transform: rotate(-8deg) scaleX(1); } }
.r-k { font-family: var(--brush); font-size: 84px; line-height: 1; color: var(--red); text-shadow: 0 0 24px rgba(200,16,46,.5); }
.r-cause { font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.badge { background: var(--gold); color: #1a0e0e; font-weight: 900; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; padding: 4px 10px; animation: pulse 1s ease infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); box-shadow: 0 0 20px rgba(255,215,106,.6); } }
.r-height { font-size: 22px; font-weight: 700; color: rgba(255,255,255,.75); }
.r-height b { font-size: 64px; font-weight: 900; color: #fff; }
.r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.r-grid span { background: rgba(255,255,255,.05); padding: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.55); display: flex; flex-direction: column; gap: 2px; }
.r-grid b { font-size: 22px; color: #fff; letter-spacing: 0; }
.r-relics { font-family: var(--brush); font-size: 28px; color: var(--gold); letter-spacing: .2em; }
.r-daily { font-size: 12px; color: rgba(255,255,255,.55); }
.unlock { font-size: 14px; padding: 8px 12px; background: rgba(255,255,255,.07); animation: pulse 1s ease infinite alternate; }
.result .menu { animation: none; margin-top: 6px; }

/* ---------- blades ---------- */
#blades { background: rgba(6,3,14,.7); backdrop-filter: blur(3px); }
.blade-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(480px, 92vw); }
.blade {
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.04); padding: 14px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.blade i { width: 70%; height: 6px; background: linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent); box-shadow: 0 0 14px 4px var(--g); transform: rotate(-20deg); margin: 10px 0; }
.blade span { font-weight: 900; letter-spacing: .1em; text-transform: uppercase; font-size: 14px; }
.blade small { font-size: 11px; color: rgba(255,255,255,.55); }
.blade.on { border-color: var(--g); box-shadow: 0 0 0 1px var(--g), 0 0 20px rgba(255,255,255,.1); }
.blade.locked { opacity: .4; cursor: default; }
.blade.locked i { box-shadow: none; background: rgba(255,255,255,.3); }

@media (max-width: 560px) {
  .cards { flex-direction: column; align-items: center; gap: 10px; }
  .card { width: min(340px, 88vw); min-height: 0; flex-direction: row; text-align: left; padding: 14px 16px; gap: 14px; }
  .card .k { font-size: 52px; }
  .card .n, .card .d { display: block; }
  .card > .n { position: absolute; left: 86px; top: 14px; }
  .card > .d { margin-top: 24px; }
  .screen h2 span { font-size: 46px; }
}
@media (max-height: 600px) {
  .howto { display: none; }
  .logo .kanji { font-size: 84px; }
}
.credit { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 10px; }

.btn-slash { position: fixed; width: 3px; pointer-events: none; z-index: 70; transform-origin: center top;
  background: linear-gradient(180deg, transparent, #fff 15%, #fff 85%, transparent);
  box-shadow: 0 0 12px 3px rgba(143,216,255,.9), 0 0 28px 8px rgba(143,216,255,.45);
  clip-path: inset(0 0 100% 0); animation: btnSlash .16s ease-out forwards; }
@keyframes btnSlash { 0% { clip-path: inset(0 0 100% 0); opacity: 1; } 60% { clip-path: inset(0 0 0 0); opacity: 1; } 100% { clip-path: inset(0 0 0 0); opacity: 0; } }

.vol { pointer-events: auto; position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 22px; background: rgba(10,5,20,.55); border: 1px solid rgba(255,255,255,.2); font-size: 11px; color: rgba(255,255,255,.75); }
.vol label { display: flex; align-items: center; gap: 6px; }
.vol input[type=range] { width: 70px; accent-color: #ff4a5e; }
.vbtn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; cursor: pointer; }
.vbtn.off { opacity: .45; }
@media (max-width: 420px) { .vol input[type=range] { width: 52px; } }
