:root {
  --ink: #07080c;
  --paper: #f4efe4;
  --gold: #e4c57a;
  --gold-2: #a6843d;
  --red: #d4453a;
  --blue: #7ea2ff;
  --line: rgba(228, 197, 122, 0.38);
  --glass: rgba(10, 12, 18, 0.62);
  --ok: #8fd18a;
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); }
body {
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button, input { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 480px at 50% 10%, rgba(212, 69, 58, 0.18), transparent 60%),
    radial-gradient(800px 500px at 80% 90%, rgba(36, 62, 139, 0.28), transparent 55%),
    #07080c center/cover no-repeat;
  filter: saturate(0.85) brightness(0.55);
  transform: scale(1.04);
}
#bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 8, 12, 0.25), rgba(7, 8, 12, 0.72));
}
#veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.04) 0.6px, transparent 0.6px);
  background-size: 3px 3px;
  opacity: 0.35;
  mix-blend-mode: overlay;
}

.topbar {
  position: fixed;
  z-index: 12;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.14em;
  font-size: 13px;
}
.seal {
  width: 36px; height: 36px;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-family: "Shippori Mincho", serif;
  font-size: 13px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 3px rgba(228, 197, 122, 0.25);
}
.brand b { font-weight: 500; font-size: 14px; }
.brand span { color: var(--gold); font-size: 10px; letter-spacing: 0.28em; }
.top-actions { display: flex; gap: 8px; }
.ghost {
  background: rgba(0,0,0,0.35);
  color: var(--paper);
  border: 1px solid rgba(244, 239, 228, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  letter-spacing: 0.12em;
  font-size: 12px;
}
.ghost.on { border-color: var(--gold); color: var(--gold); }

.view {
  position: relative;
  z-index: 1;
  height: 100dvh;
  height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: calc(78px + env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
}
.hero { max-width: 1080px; margin: 0 auto; }
.eyebrow {
  margin: 8px 0 0;
  color: var(--gold);
  letter-spacing: 0.42em;
  font-size: 12px;
}
h1 {
  font-family: "Shippori Mincho", serif;
  font-weight: 700;
  font-size: clamp(48px, 8vw, 92px);
  line-height: 1;
  margin: 8px 0 12px;
  background: linear-gradient(180deg, #fff 20%, #e4c57a 70%, #8a6230);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { max-width: 640px; margin: 0 0 28px; color: rgba(244,239,228,0.78); line-height: 1.7; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.28);
  min-height: 280px;
  display: flex;
  flex-direction: column;
}
.card .kana {
  font-family: "Shippori Mincho", serif;
  font-size: 32px;
  margin: 0;
}
.card .en { margin: 0 0 8px; color: var(--gold); letter-spacing: 0.18em; font-size: 11px; }
.card p { margin: 0 0 16px; color: rgba(244,239,228,0.76); line-height: 1.65; font-size: 14px; flex: 1; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card button, .primary, .line-btn {
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid transparent;
  letter-spacing: 0.06em;
}
.card button, .line-btn {
  background: rgba(255,255,255,0.04);
  color: var(--paper);
  border-color: rgba(244,239,228,0.16);
}
.primary {
  background: linear-gradient(180deg, #e4c57a, #b68a3e);
  color: #1a1208;
  font-weight: 700;
  border: none;
}
.card button:hover, .line-btn:hover { border-color: var(--gold); }

.portrait {
  height: 92px;
  margin: -6px -6px 10px;
  border-radius: 16px;
  background: center/cover no-repeat;
  position: relative;
  overflow: hidden;
}
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(10,12,18,0.15) 40%, rgba(10,12,18,0.9));
}
.portrait.kendo { background-image: linear-gradient(90deg, rgba(212,69,58,.35), rgba(36,62,139,.35)), url("../assets/dojo.png"); }
.portrait.tennis { background-image: linear-gradient(180deg, rgba(0,0,0,.1), rgba(0,0,0,.45)), url("../assets/arena.png"); }
.portrait.lift { background-image: radial-gradient(circle at 50% 80%, rgba(228,197,122,.45), transparent 55%), url("../assets/arena.png"); }

.panel {
  width: min(520px, 100%);
  margin: 6vh auto 0;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  backdrop-filter: blur(18px);
}
.panel h2 { font-family: "Shippori Mincho", serif; margin: 0 0 6px; font-size: 32px; }
.panel .sub { margin: 0 0 16px; color: rgba(244,239,228,0.72); line-height: 1.6; }
label { display: block; font-size: 12px; letter-spacing: 0.14em; color: var(--gold); margin: 12px 0 6px; }
input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(244,239,228,0.16);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}
.row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.row .primary { flex: 1; padding: 12px 16px; }
.status {
  min-height: 1.4em;
  margin-top: 12px;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.status.bad { color: #ff8d86; }
.pass-show {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0,0,0,0.28);
  border: 1px dashed rgba(228,197,122,0.4);
  font-family: "Shippori Mincho", serif;
  font-size: 22px;
}

#view-play {
  position: relative;
  z-index: 1;
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: calc(58px + env(safe-area-inset-top)) 12px 0;
}
.stage-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}
#game {
  width: min(100%, calc((100svh - 250px - env(safe-area-inset-bottom)) * 16 / 9));
  height: auto;
  max-height: calc(100svh - 250px - env(safe-area-inset-bottom));
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(228,197,122,0.25);
  touch-action: none;
}
#racket-pad {
  display: none;
  height: 128px;
  margin: 4px 12px calc(28px + env(safe-area-inset-bottom));
  border-radius: 18px;
  border: 1px dashed rgba(228, 197, 122, 0.55);
  background: rgba(8, 10, 16, 0.62);
  color: rgba(244, 239, 228, 0.72);
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  letter-spacing: 0.08em;
  font-size: 13px;
  touch-action: none;
}
body.racket-touch #racket-pad { display: flex; }
body.racket-touch #game {
  max-height: calc(100svh - 310px - env(safe-area-inset-bottom));
  width: min(100%, calc((100svh - 310px - env(safe-area-inset-bottom)) * 16 / 9));
}
#pads {
  display: none;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 4;
  padding: 12px 10px calc(52px + env(safe-area-inset-bottom));
}
body.show-pads #pads { display: flex; }
.cluster { display: flex; gap: 8px; align-items: center; }
.cluster button {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  border: 1px solid rgba(228,197,122,0.35);
  background: rgba(8,10,16,0.72);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}
.cluster button[data-k="attack"] {
  background: linear-gradient(180deg, #e25b4a, #8e241c);
  border-color: transparent;
  font-weight: 700;
}
.cluster button[data-k="guard"] { color: var(--gold); }
.cluster button.held { transform: translateY(2px) scale(0.97); filter: brightness(1.25); }
body.solo-pad .cluster[data-side="p2"] { display: none; }
.cluster[data-side="p1"] { margin-right: auto; }

.modal {
  position: fixed;
  z-index: 8;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal .sheet {
  width: min(520px, 100%);
  background: #12141b;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
}
.modal h3 { font-family: "Shippori Mincho", serif; margin: 0 0 8px; font-size: 28px; }
.modal p, .modal li { color: rgba(244,239,228,0.8); line-height: 1.65; }
.modal ul { padding-left: 1.1em; }
.keys { color: var(--gold); }

.result-card .scoreline {
  font-family: "Shippori Mincho", serif;
  font-size: 42px;
  margin: 8px 0;
}

.turn-hint {
  display: none;
  position: relative;
  z-index: 4;
  text-align: center;
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(244,239,228,0.7);
}
body.show-pads .turn-hint { display: block; }

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
  h1 { font-size: 56px; }
  .cluster button { width: 62px; height: 62px; }
}
@media (max-width: 720px) {
  body.duo-pad .cluster button { width: 54px; height: 54px; font-size: 11px; border-radius: 14px; }
}
