:root {
  --ink: #272119;
  --red: #cf3f2f;
  --red-dark: #91271f;
  --blue: #215d78;
  --paper: #f5ecd6;
  --paper-light: #fffaf0;
  --gold: #d4a243;
  --muted: #756a58;
  --shadow: 0 20px 50px rgba(66, 48, 26, .16);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #e9ddc0; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(255,255,255,.7), transparent 28%),
    linear-gradient(135deg, #f5ecd7, #e6d7b4);
  overflow-x: hidden;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: .15;
  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='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.app-shell { width: min(1180px, 100%); min-height: 100dvh; margin: auto; padding: 0 28px 32px; position: relative; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; }
.brand { border: 0; background: none; display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 22px; font-weight: 900; }
.brand b { color: var(--red); }
.brand-kamon {
  width: 48px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  color: var(--paper-light); font-family: "Kaisei Decol"; font-size: 21px;
  background: var(--red); border: 3px double var(--paper-light); outline: 2px solid var(--red);
}
.round-button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(39,33,25,.18); background: rgba(255,255,255,.38); cursor: pointer; font-weight: 900; }

.hero { min-height: calc(100dvh - 124px); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 30px 60px; align-items: center; padding: 24px 3% 30px; }
.hero-copy { align-self: end; position: relative; z-index: 2; }
.eyebrow { font-size: 12px; font-weight: 900; letter-spacing: .32em; color: var(--red); display: flex; align-items: center; gap: 10px; }
.eyebrow span { width: 28px; height: 1px; background: currentColor; }
h1 { font-family: "Kaisei Decol", serif; font-size: clamp(46px, 6vw, 77px); line-height: 1.14; margin: 14px 0 20px; letter-spacing: -.04em; }
h1 em { color: var(--red); font-style: normal; position: relative; }
h1 em::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 7px; background: var(--red); clip-path: polygon(0 40%, 100% 0, 95% 100%, 5% 70%); }
.lead { color: var(--muted); font-size: 16px; line-height: 1.9; font-weight: 700; }
.menu-arena { min-height: 430px; position: relative; display: grid; place-items: end center; }
.sun { position: absolute; top: 2%; right: 8%; width: 185px; aspect-ratio: 1; border-radius: 50%; background: rgba(197,57,45,.12); }
.cloud { position: absolute; width: 80px; height: 20px; border-top: 2px solid rgba(39,33,25,.14); }
.cloud::before, .cloud::after { content: ""; position: absolute; border: 2px solid rgba(39,33,25,.14); border-bottom: 0; border-radius: 50% 50% 0 0; }
.cloud::before { width: 35px; height: 18px; left: 7px; top: -20px; }
.cloud::after { width: 45px; height: 27px; right: 4px; top: -29px; }
.cloud-a { left: 4%; top: 25%; } .cloud-b { right: 0; top: 48%; transform: scale(.7); }
.mini-ring { width: min(430px, 90%); height: 130px; position: relative; border-radius: 50%; background: #c5954f; border: 16px solid #80592d; box-shadow: 0 30px 30px rgba(56,37,18,.2), inset 0 0 0 6px #e4c27f; transform: perspective(350px) rotateX(55deg); }
.menu-arena .paper-sumo { position: absolute; bottom: 70px; transform-origin: bottom; }
.preview-left { left: 28%; transform: rotate(-9deg) !important; }
.preview-right { right: 28%; transform: rotate(9deg) !important; }
.impact { position: absolute; font-family: "Kaisei Decol"; font-size: 25px; font-weight: 900; }
.impact-a { left: 7%; top: 45%; color: var(--red); transform: rotate(-12deg); }
.impact-b { right: 3%; top: 22%; color: var(--blue); transform: rotate(11deg); }

.menu-card { grid-column: 1 / -1; background: rgba(255,250,240,.64); border: 1px solid rgba(95,75,42,.15); border-radius: 24px; padding: 24px 28px 18px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.menu-card h2 { margin: 0 0 16px; font-family: "Kaisei Decol"; font-size: 20px; text-align: center; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-button { border: 1px solid rgba(39,33,25,.13); background: rgba(255,255,255,.6); border-radius: 16px; padding: 16px; display: flex; gap: 15px; align-items: center; text-align: left; cursor: pointer; transition: .2s ease; }
.mode-button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(39,33,25,.1); }
.mode-button.primary { background: var(--red); color: white; border-color: var(--red); }
.mode-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); font-size: 13px; font-weight: 900; flex: 0 0 auto; }
.mode-button:not(.primary) .mode-icon { color: var(--blue); background: rgba(33,93,120,.1); }
.mode-button > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.mode-button b { font-size: 17px; }
.mode-button small { opacity: .72; }
.mode-button i { font-size: 30px; font-style: normal; }
.mic-note { margin: 14px 0 0; text-align: center; font-size: 11px; color: var(--muted); }

.setup-screen { min-height: calc(100dvh - 92px); display: grid; place-items: center; padding: 25px 0 60px; position: relative; }
.back-link { position: absolute; top: 10px; left: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-weight: 700; }
.setup-card { width: min(610px, 100%); background: rgba(255,250,240,.8); border-radius: 28px; padding: 38px; box-shadow: var(--shadow); border: 1px solid rgba(39,33,25,.1); text-align: center; }
.setup-card .eyebrow { justify-content: center; }
.setup-card h2 { font-family: "Kaisei Decol"; font-size: 36px; margin: 8px 0; }
.setup-card > p { color: var(--muted); margin-top: 5px; }
.difficulty { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 27px 0; }
.difficulty button { border: 1px solid rgba(39,33,25,.15); background: rgba(255,255,255,.5); border-radius: 14px; padding: 13px 5px; cursor: pointer; display: flex; flex-direction: column; }
.difficulty button.selected { background: var(--red); color: white; border-color: var(--red); box-shadow: 0 6px 14px rgba(207,63,47,.22); }
.difficulty small { opacity: .7; font-size: 11px; }
.online-panel { margin: 24px 0; padding: 20px; border-radius: 18px; background: rgba(255,255,255,.5); border: 1px solid rgba(39,33,25,.12); text-align: left; }
.online-name { display: block; color: var(--muted); font-size: 12px; font-weight: 900; }
.online-name input, .room-join input { width: 100%; border: 1px solid rgba(39,33,25,.16); border-radius: 11px; padding: 11px; background: rgba(255,255,255,.85); color: var(--ink); font-weight: 900; outline: none; text-transform: uppercase; }
.online-name input { margin-top: 7px; text-transform: none; }
.online-name input:focus, .room-join input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33,93,120,.1); }
.online-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 15px; }
.online-actions > span { color: var(--muted); font-size: 10px; }
.room-create, .room-join button, .room-ticket button { border: 0; border-radius: 11px; padding: 11px 13px; color: white; background: var(--blue); font-weight: 900; cursor: pointer; }
.room-join { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.room-join input { min-width: 0; letter-spacing: .15em; }
.room-ticket { margin-top: 16px; border: 2px dashed rgba(33,93,120,.3); border-radius: 14px; padding: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
.room-ticket small { color: var(--muted); }
.room-ticket strong { grid-row: 2; font-family: "Kaisei Decol"; color: var(--blue); font-size: 29px; letter-spacing: .18em; }
.room-ticket button { grid-row: 1 / 3; grid-column: 2; padding: 8px 12px; }
.online-status { margin: 13px 0 0; color: var(--blue) !important; text-align: center; font-size: 12px; font-weight: 900; }
.voice-check { border-top: 1px solid rgba(39,33,25,.12); border-bottom: 1px solid rgba(39,33,25,.12); padding: 20px 0; margin: 10px 0 24px; text-align: left; }
.voice-check-head, .live-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 900; }
.voice-check-head strong { color: var(--red); }
.voice-check p { font-size: 11px; color: var(--muted); }
.meter { height: 13px; margin: 9px 0; background: #d8cfbb; border-radius: 20px; overflow: hidden; position: relative; }
.meter i, .mini-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d4a243 0 45%, #e87832 65%, var(--red) 100%); border-radius: inherit; transition: width .08s linear; }
.sensitivity { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; font-size: 11px; font-weight: 900; }
.sensitivity input { accent-color: var(--red); width: 100%; }
.start-button { width: 100%; border: 0; border-radius: 15px; color: white; background: var(--red); box-shadow: 0 7px 0 var(--red-dark); padding: 12px; cursor: pointer; display: flex; flex-direction: column; font-size: 19px; font-weight: 900; }
.start-button:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--red-dark); }
.start-button span { font-size: 10px; opacity: .75; }
.practice-button { margin-top: 17px; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12px; font-weight: 700; }

.game-screen { min-height: calc(100dvh - 92px); display: grid; grid-template-rows: auto minmax(360px, 1fr) auto; padding-bottom: 10px; }
.scoreboard { display: grid; grid-template-columns: 1fr 110px 1fr; align-items: center; gap: 20px; max-width: 830px; width: 100%; margin: 0 auto 10px; }
.fighter-label { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 10px; }
.fighter-label > span { width: 40px; height: 40px; display: grid; place-items: center; color: white; background: var(--red); border-radius: 50%; font-family: "Kaisei Decol"; }
.fighter-label > b { font-size: 17px; }
.fighter-label.west { direction: rtl; }
.fighter-label.west > span { background: var(--blue); }
.mini-meter { grid-column: 2; height: 5px; background: rgba(39,33,25,.12); border-radius: 8px; overflow: hidden; width: 100%; }
.fighter-label.west .mini-meter { grid-column: 1 / 2; }
.round-state { text-align: center; display: grid; grid-template-columns: 1fr auto; justify-content: center; align-items: baseline; }
.round-state small { grid-column: 1 / -1; color: var(--muted); font-weight: 900; }
.round-state strong { font-family: "Kaisei Decol"; font-size: 40px; color: var(--red); }
.round-state span { font-size: 11px; }
.game-stage { position: relative; min-height: 360px; overflow: hidden; border-radius: 28px; background: linear-gradient(#efe1bd 0 63%, #dfc58e 63%); border: 1px solid rgba(70,50,25,.14); box-shadow: inset 0 -20px 60px rgba(114,77,30,.1); }
.audience-pattern { position: absolute; inset: 9% 4% auto; height: 80px; opacity: .14; background: radial-gradient(circle, var(--ink) 0 5px, transparent 6px) 0 0 / 38px 38px; mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); }
.ring-wrap { position: absolute; left: 50%; top: 55%; width: min(650px, 84%); height: 250px; transform: translate(-50%, -50%); transform-origin: 50% 65%; will-change: transform; }
.ring-wrap::before, .ring-wrap::after { content: ""; position: absolute; z-index: -1; bottom: -48px; width: 28px; height: 86px; background: linear-gradient(90deg, #5b391d, #906331 48%, #4b2d17); border-radius: 5px 5px 13px 13px; box-shadow: 0 10px 10px rgba(56,34,14,.2); }
.ring-wrap::before { left: 19%; transform: rotate(7deg); }
.ring-wrap::after { right: 19%; transform: rotate(-7deg); }
.ring-shadow { position: absolute; left: 5%; right: 5%; bottom: -6%; height: 70px; background: rgba(80,49,17,.22); border-radius: 50%; filter: blur(12px); transform-origin: center; will-change: transform; }
.impact-point { position: absolute; z-index: 5; bottom: -27px; width: 68px; height: 68px; border-radius: 50%; pointer-events: none; opacity: 0; }
.impact-left { left: 3%; color: var(--red); }
.impact-right { right: 3%; color: var(--blue); }
.impact-point::before { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 8px color-mix(in srgb, currentColor 22%, transparent); }
.impact-point i { position: absolute; inset: 8px; border: 3px solid currentColor; border-radius: 50%; }
.impact-point i:last-child { inset: -8px; opacity: .5; }
.impact-point.hit { animation: impactFlash .3s ease-out; }
.impact-point.hit i { animation: impactRing .3s ease-out; }
.dohyo { position: absolute; inset: 0; border-radius: 50%; background: #c99c55; border: 20px solid #7f572a; box-shadow: inset 0 0 0 8px #e5bf74, 0 20px 0 #5d3d1e; }
.straw { position: absolute; inset: 9%; border-radius: 50%; border: 5px dashed rgba(88,54,20,.45); }
.circle { position: absolute; inset: 16%; border-radius: 50%; border: 5px solid rgba(245,236,214,.72); }
.shikiri { position: absolute; top: 35%; bottom: 35%; width: 5px; background: rgba(245,236,214,.85); }
.line-left { left: 43%; } .line-right { right: 43%; }
.fighter-space { position: absolute; left: 8%; right: 8%; top: 10%; bottom: 17%; }
.paper-sumo {
  width: 104px; height: 168px; position: absolute; bottom: 0; z-index: 2;
  background: center bottom / contain no-repeat url("assets/fighter-red.webp");
  filter: drop-shadow(0 12px 6px rgba(47,28,13,.25));
  transform-origin: 50% 95%;
  will-change: transform, left, bottom;
}
.paper-sumo.blue { background-image: url("assets/fighter-blue.webp"); }
.paper-sumo::before, .paper-sumo::after, .paper-sumo i, .paper-sumo b, .paper-sumo span, .paper-sumo em { display: none; }
#leftFighter { left: 23%; transform: rotate(-3deg); }
#rightFighter { left: calc(77% - 104px); transform: rotate(3deg) scaleX(-1); }
.turn-banner { position: absolute; z-index: 8; left: 50%; top: 15px; transform: translateX(-50%); background: rgba(255,250,240,.92); padding: 7px 25px; border-radius: 30px; box-shadow: 0 5px 18px rgba(39,33,25,.15); text-align: center; }
.turn-banner small { color: var(--muted); margin-right: 5px; }
.turn-banner b { color: var(--red); }
.countdown { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; font-family: "Kaisei Decol"; font-size: 130px; color: var(--red); text-shadow: 0 7px 0 white; animation: pop .65s ease both; }
.shout-text { position: absolute; z-index: 7; left: 50%; top: 20%; font-family: "Kaisei Decol"; font-size: 45px; color: var(--red); text-shadow: 2px 2px white; transform: translateX(-50%) rotate(-8deg); animation: shout .35s ease both; }
.control-panel { width: min(670px, 100%); margin: 14px auto 0; display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: center; }
.live-meter { min-width: 0; }
.meter.large { height: 21px; border: 3px solid rgba(39,33,25,.08); }
.meter.large > span { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.65); }
.meter.large > span:nth-of-type(1) { left: 25%; }.meter.large > span:nth-of-type(2) { left: 50%; }.meter.large > span:nth-of-type(3) { left: 75%; }
.push-button { border: 0; border-radius: 16px; background: var(--red); color: white; padding: 11px 16px; box-shadow: 0 6px 0 var(--red-dark); cursor: pointer; display: grid; grid-template-columns: 35px 1fr; text-align: left; user-select: none; touch-action: none; }
.push-button:active, .push-button.pressing { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); filter: brightness(1.08); }
.push-button .mic-glyph { grid-row: 1 / 3; width: 28px; height: 28px; border-radius: 50%; border: 3px solid white; display: grid; place-items: center; color: white; font-size: 8px; margin-top: 3px; }
.push-button b { font-size: 14px; }.push-button small { font-size: 9px; opacity: .72; }

.result-overlay { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; background: rgba(39,33,25,.66); backdrop-filter: blur(7px); padding: 22px; }
.result-card { width: min(410px, 100%); background: var(--paper-light); border-radius: 25px; padding: 34px; text-align: center; position: relative; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: resultIn .45s cubic-bezier(.2,.9,.3,1.25); }
.result-card > * { position: relative; z-index: 2; }
.result-card > p:first-of-type { color: var(--red); font-weight: 900; letter-spacing: .2em; margin: 0; }
.result-card h2 { font-family: "Kaisei Decol"; font-size: 35px; margin: 8px 0 15px; }
.winner-stamp { width: 105px; height: 105px; margin: 0 auto 15px; border: 7px double var(--red); border-radius: 50%; display: grid; place-items: center; color: var(--red); font-family: "Kaisei Decol"; font-size: 57px; transform: rotate(-7deg); }
.result-reason { color: var(--muted); font-weight: 900; }
.result-burst { position: absolute; z-index: 0; width: 360px; aspect-ratio: 1; left: 50%; top: 45%; transform: translate(-50%,-50%); background: repeating-conic-gradient(rgba(212,162,67,.13) 0 7deg, transparent 7deg 15deg); border-radius: 50%; }

@keyframes pop { 0% { transform: scale(.35); opacity: 0; } 55% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shout { from { transform: translateX(-50%) scale(.4) rotate(-18deg); opacity: 0; } to { transform: translateX(-50%) scale(1) rotate(-8deg); opacity: 1; } }
@keyframes resultIn { from { transform: translateY(30px) scale(.85); opacity: 0; } }
@keyframes impactFlash { 0% { opacity: 1; transform: scale(.55); } 100% { opacity: 0; transform: scale(1.2); } }
@keyframes impactRing { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

@media (max-width: 760px) {
  .app-shell { padding: 0 15px 20px; }
  .topbar { height: 72px; }
  .brand { font-size: 18px; }.brand-kamon { width: 39px; font-size: 16px; }
  .hero { min-height: calc(100dvh - 80px); grid-template-columns: 1fr; grid-template-rows: auto 230px auto; gap: 12px; padding: 10px 0 22px; }
  .hero-copy { text-align: center; }
  .hero-copy .eyebrow { justify-content: center; }
  h1 { font-size: clamp(39px, 12vw, 54px); margin: 8px 0 14px; }
  .lead { font-size: 13px; line-height: 1.7; }
  .menu-arena { grid-row: 2; min-height: 230px; }
  .sun { width: 125px; }
  .mini-ring { width: 320px; height: 95px; border-width: 12px; }
  .menu-arena .paper-sumo { bottom: 48px; transform: scale(.72) rotate(-8deg) !important; }
  .preview-right { transform: scale(-.72,.72) rotate(-8deg) !important; }
  .impact-a { top: 33%; }.impact-b { top: 12%; }
  .menu-card { padding: 19px 14px 14px; border-radius: 19px; }
  .mode-grid { grid-template-columns: 1fr; gap: 9px; }
  .mode-button { padding: 11px 13px; }.mode-icon { width: 44px; height: 44px; }
  .mic-note { font-size: 9px; }
  .setup-screen { min-height: calc(100dvh - 72px); padding: 30px 0; }
  .setup-card { padding: 28px 18px; border-radius: 20px; }
  .setup-card h2 { font-size: 29px; }
  .online-panel { padding: 14px; margin: 18px 0; }
  .online-actions { grid-template-columns: 1fr; }
  .online-actions > span { text-align: center; }
  .game-screen { min-height: calc(100dvh - 72px); grid-template-rows: auto minmax(310px, 1fr) auto; }
  .scoreboard { grid-template-columns: 1fr 68px 1fr; gap: 6px; }
  .fighter-label { grid-template-columns: 29px 1fr; gap: 5px; }
  .fighter-label > span { width: 29px; height: 29px; font-size: 11px; }
  .fighter-label > b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .round-state strong { font-size: 29px; }
  .game-stage { min-height: 310px; border-radius: 19px; }
  .ring-wrap { width: 570px; max-width: 115%; height: 210px; top: 58%; }
  .paper-sumo { width: 78px; height: 126px; }
  #leftFighter { left: 27%; }
  #rightFighter { left: calc(73% - 78px); }
  .control-panel { margin-top: 10px; grid-template-columns: 1fr; gap: 7px; }
  .push-button { max-width: 360px; width: 100%; margin: auto; }
  .live-label { font-size: 10px; }
  .turn-banner { top: 10px; padding: 5px 16px; font-size: 12px; }
}

@media (max-height: 720px) and (max-width: 760px) {
  .hero { grid-template-rows: auto 165px auto; }
  .menu-arena { min-height: 165px; transform: scale(.82); margin: -20px; }
  .lead { display: none; }
  .game-screen { grid-template-rows: auto minmax(270px,1fr) auto; }
  .game-stage { min-height: 270px; }
  .ring-wrap { transform: translate(-50%,-50%) scale(.86); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
