:root {
  color-scheme: light;
  --paper: var(--sakasen-paper, #f5f4ef);
  --ink: var(--sakasen-ink, #22231f);
  --soft-ink: var(--sakasen-muted, #676a60);
  --line: var(--sakasen-line, #d8d9cf);
  --lime: var(--sakasen-lime, #e7ed98);
  --paper-white: var(--sakasen-panel, #fffef9);
  --yellow: #f8dc65;
  font-family: var(--sakasen-font, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", Meiryo, system-ui, sans-serif);
  font-synthesis: none;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-weight: 400; }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #47674b; outline-offset: 4px; }

.masthead {
  min-height: 76px;
  max-width: 1200px;
  margin: auto;
  padding: 12px clamp(16px, 4vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sound-toggle {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--paper-white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .875rem;
  white-space: nowrap;
  font-weight: 600;
}
.sound-toggle:hover { border-color: #9a9e88; }
.sound-icon { width: 20px; height: 20px; }
.sound-toggle[aria-pressed="false"] .sound-waves,
.sound-toggle[aria-pressed="true"] .sound-mute { display: none; }

.page {
  width: min(100%, 1200px);
  margin-inline: auto;
  padding: 12px clamp(14px, 4vw, 42px) 28px;
}

.join-shell {
  min-height: 560px;
  background: var(--paper-white);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(330px, 1.08fr);
}
.join-form-panel { padding: clamp(28px, 5vw, 65px); align-self: center; }
.join-kicker {
  font-size: .9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.join-kicker span { background: var(--lime); border: 1px solid #b8be77; border-radius: 4px; width: 12px; height: 12px; }
.join-form-panel h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 13px 0;
}
.join-intro { font-size: 1rem; color: var(--soft-ink); line-height: 1.65; margin: 0 0 24px; }
#join-form { display: grid; gap: 12px; max-width: 355px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.field input {
  min-width: 0;
  min-height: 53px;
  width: 100%;
  padding: 9px 14px;
  background: #fff;
  border: 1px solid #a1a68f;
  border-radius: 9px;
  font-size: 1.05rem;
  font-weight: 400;
}
.field input::placeholder { color: var(--soft-ink); }
.join-button {
  position: relative;
  appearance: none;
  border: 1px solid #b7bd71;
  border-radius: 9px;
  min-height: 54px;
  background: var(--lime);
  padding: 9px 37px;
  font-size: 1.11rem;
  font-weight: 600;
}
.join-button:hover { background: #eff2b7; }
.join-button:active { transform: translateY(1px); }
.join-button:disabled { opacity: .62; cursor: progress; }
.join-button span { position: absolute; right: 17px; }
.form-message { color: #8b342a; font-size: .9rem; font-weight: 500; margin: 1px 0 0; }

.join-illustration {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  background-color: #eef0da;
}
.illustration-orbit {
  position: absolute;
  inset: auto;
  width: min(88%, 480px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #cdd3ad;
}
.illustration-orbit-inner { width: min(68%, 370px); border-style: dashed; }
.illustration-spark { position: absolute; color: #a3772d; font-size: clamp(1.3rem, 4vw, 2.5rem); line-height: 1; }
.illustration-first { left: 14%; top: 23%; }
.illustration-second { right: 16%; top: 27%; color: #777c50; font-size: clamp(1.3rem, 3.3vw, 2rem); }
.illustration-third { bottom: 21%; right: 19%; font-size: clamp(1.15rem, 3vw, 1.7rem); }
.illustration-buzzer { position: relative; width: min(62%, 296px); aspect-ratio: 1.35; transform: rotate(-9deg); }
.illustration-platform {
  position: absolute;
  inset: 50% 0 0;
  border: 2px solid #81876e;
  border-radius: 50%;
  background: #c9cfb2;
  box-shadow: 0 7px 0 #a3ab8a;
}
.illustration-dome {
  position: absolute;
  inset: 7% 10% 25%;
  display: grid;
  place-items: center;
  border: 2px solid #9b7434;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: inset 0 -7px 0 #edc348, 0 5px 0 #c59b46;
  color: #4c3516;
}
.illustration-dome svg { width: 26%; transform: rotate(9deg) translateY(-2px); }

.play-shell {
  background: var(--paper-white);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.game-strip {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px clamp(14px, 3vw, 24px);
}
.player-chip {
  display: flex;
  min-width: 0;
  gap: 7px;
  align-items: center;
  background: #eeefe7;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: .9rem;
  font-weight: 600;
}
.player-chip svg { width: 17px; flex: 0 0 auto; }
.player-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage {
  min-height: min(620px, max(540px, calc(100svh - 190px)));
  display: grid;
  place-items: center;
  isolation: isolate;
  position: relative;
  overflow: hidden;
  padding: clamp(23px, 5vw, 38px) 13px 27px;
  color: var(--ink);
  background-color: var(--stage, #f1f2eb);
  border-top: 1px solid var(--line);
  transition: background-color .2s;
}
.play-shell[data-mode="open"] { --stage: #f1f3db; }
.play-shell[data-mode="mine"] { --stage: #faf3d9; }
.play-shell[data-mode="correct"] {
  --stage: #eaf4e9;
  --mark-surface: #f7fff5;
  --mark-ink: #225c3b;
  --mark-line: #8fbb91;
}
.play-shell[data-mode="incorrect"] {
  --stage: #faeee7;
  --mark-surface: #fff8f3;
  --mark-ink: #903d32;
  --mark-line: #d7a596;
}
.play-shell[data-mode="ended"] {
  --stage: #edece6;
  --mark-surface: #faf9f3;
  --mark-ink: #555646;
  --mark-line: #c0c0b1;
}

.stage-orbit {
  position: absolute;
  z-index: -1;
  border: 1px solid #22231f17;
  border-radius: 50%;
  width: var(--diameter, 760px);
  aspect-ratio: 1;
  top: max(38%, 190px);
  left: 50%;
  translate: -50% 0;
  pointer-events: none;
}
.orbit-two { --diameter: 580px; border-style: dashed; }
.stage-content { width: min(100%, 640px); text-align: center; }
.stage-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 33px;
  padding: 3px 16px;
  margin: 0 0 10px;
  background: #ffffff91;
  border-radius: 999px;
  border: 1px solid #22231f26;
  font-size: .9rem;
  font-weight: 600;
}
.stage-title { font-size: clamp(1.55rem, 4.6vw, 3.25rem); line-height: 1.26; font-weight: 600; letter-spacing: -.015em; margin: 0; text-wrap: balance; }
.stage-description { min-height: 1.6em; margin: 9px 0 0; color: var(--soft-ink); font-size: clamp(.95rem, 2vw, 1.15rem); line-height: 1.6; text-wrap: balance; }
.play-shell[data-mode="open"] .stage-round, .play-shell[data-mode="mine"] .stage-round { background: var(--lime); border-color: #b8be77; }
.action-zone { display: grid; place-items: center; min-height: 266px; margin-top: clamp(21px, 4vw, 36px); }
.buzzer {
  position: relative;
  isolation: isolate;
  appearance: none;
  width: clamp(208px, 47vw, 305px);
  aspect-ratio: 1.24;
  border: 0;
  border-radius: 48%;
  padding: 0;
  background: transparent;
  color: var(--ink);
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.buzzer:focus-visible { outline-offset: 7px; }
.buzzer-base,
.buzzer-face { position: absolute; border-radius: 50%; border: 2px solid #828676; }
.buzzer-base {
  inset: 47% 0 2%;
  background: #cbd0bc;
  box-shadow: 0 5px 0 #a9af98;
}
.buzzer-face {
  inset: 1% 7% 24%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1px;
  padding: 4px 0 11px;
  background: #e5e7dd;
  box-shadow: inset 0 -7px 0 #d4d8c8, 0 4px 0 #aeb49f;
  transition: transform .1s, box-shadow .1s;
}
.buzzer:enabled .buzzer-face {
  border-color: #916730;
  color: #352813;
  background: var(--yellow);
  box-shadow: inset 0 -7px 0 #edc348, 0 5px 0 #ac7d38;
}
.buzzer:enabled:hover .buzzer-face { filter: brightness(1.055); }
.buzzer:active:enabled .buzzer-face,
.buzzer[data-pressed] .buzzer-face { transform: translateY(4px); box-shadow: inset 0 -5px 0 #edc348, 0 1px 0 #ac7d38; }
.buzzer[data-pressed] .buzzer-face { background: var(--yellow); border-color: #916730; }
.buzzer:disabled { cursor: default; }
.buzzer-icon { width: clamp(40px, 9vw, 63px); margin-bottom: 1px; }
#buzzer-caption { font-size: clamp(1.3rem, 4.5vw, 2rem); font-weight: 650; letter-spacing: -.015em; }

.result-mark { width: clamp(205px, 42vw, 266px); aspect-ratio: 1; position: relative; display: grid; place-items: center; }
.result-orbit { position: absolute; border: 1px solid #22231f27; border-radius: 50%; aspect-ratio: 1; }
.result-orbit-out { width: 100%; border-style: dashed; }
.result-orbit-in { width: 81%; }
.result-center {
  display: grid;
  place-items: center;
  text-align: center;
  width: 68%;
  height: 68%;
  background: var(--mark-surface, #fff8db);
  color: var(--mark-ink, #6e501b);
  border: 1px solid var(--mark-line, #d7b972);
  border-radius: 25%;
  font-size: clamp(4rem, 13vw, 6.1rem);
  font-family: system-ui, sans-serif;
  font-weight: 650;
  line-height: 1;
}
.result-spark { position: absolute; z-index: 1; color: var(--mark-ink, #6e501b); opacity: .65; font-size: 1.4rem; line-height: 1; }
.result-spark-one { top: 13%; left: 9%; }
.result-spark-two { top: 20%; right: 2%; font-size: 1rem; }
.result-spark-three { bottom: 12%; right: 9%; font-size: 1rem; }
.play-shell[data-mode="incorrect"] .result-spark { display: none; }
.game-message { max-width: 30em; margin: 9px auto 0; background: #fdf1d1; padding: 7px 10px; border-radius: 8px; color: #4d391e; font-weight: 500; font-size: .875rem; }
.back-button { display: inline-flex; min-height: 44px; align-items: center; margin: 9px 0 0; padding: 6px 14px; border: 1px solid #9da28c; border-radius: 999px; background: var(--paper-white); font-weight: 600; text-decoration: none; }
.back-button:hover { background: var(--lime); }

@media (max-width: 750px) {
  .masthead { min-height: 66px; }
  .page { padding-top: 4px; }
  .join-shell { grid-template-columns: minmax(0, 1fr); min-height: 0; border-radius: 16px; }
  .join-illustration { min-height: clamp(105px, 27vw, 170px); order: -1; }
  .illustration-orbit { width: min(64%, 330px); }
  .illustration-orbit-inner { width: min(46%, 240px); }
  .illustration-buzzer { width: clamp(80px, 27vw, 132px); margin-bottom: 9px; }
  .illustration-platform { box-shadow: 0 4px 0 #a3ab8a; }
  .illustration-dome { box-shadow: inset 0 -4px 0 #edc348, 0 3px 0 #c59b46; }
  .illustration-first { left: 22%; top: 23%; }
  .illustration-second { right: 19%; top: 24%; }
  .illustration-third { bottom: 16%; right: 28%; font-size: 1.2rem; }
  .join-form-panel { padding: 25px clamp(18px, 5vw, 36px) 31px; }
  .join-form-panel h1 { margin: 9px 0 11px; }
  .join-intro { margin-bottom: 18px; }
  .desktop-break { display: none; }
  .stage { min-height: min(550px, max(440px, calc(100svh - 168px))); }
  .game-strip { min-height: 49px; }
  .play-shell { border-radius: 16px; }
  .action-zone { min-height: 222px; }
}

@media (max-width: 370px) {
  .sound-toggle { padding-inline: 8px; gap: 4px; font-size: .8rem; }
  .sound-icon { width: 16px; height: 16px; }
}

.demo-frame .masthead { min-height: 52px; padding: 4px 12px; justify-content: flex-end; }
.demo-frame .page { padding: 6px 10px 10px; }
.demo-frame .join-shell { min-height: 0; grid-template-columns: minmax(0, 1fr); }
.demo-frame .join-illustration { min-height: 90px; order: -1; }
.demo-frame .illustration-buzzer { width: 100px; }
.demo-frame .join-form-panel { padding: 17px 20px 23px; }
.demo-frame .join-form-panel h1 { font-size: 1.95rem; }
.demo-frame .join-intro { margin-bottom: 14px; }
.demo-frame .desktop-break { display: none; }
.demo-frame .game-strip { min-height: 43px; padding: 5px 12px; }
.demo-frame .stage { min-height: clamp(340px, calc(100svh - 125px), 520px); padding: 17px 12px 20px; }
.demo-frame .stage-round { min-height: 29px; margin-bottom: 7px; }
.demo-frame .stage-title { font-size: clamp(1.36rem, 5vw, 1.75rem); }
.demo-frame .stage-description { margin-top: 6px; }
.demo-frame .action-zone { min-height: 182px; margin-top: 13px; }
.demo-frame .buzzer { width: clamp(173px, 43vw, 225px); }
.demo-frame .buzzer-icon { width: clamp(32px, 8vw, 45px); }
.demo-frame #buzzer-caption { font-size: 1.28rem; }
.demo-frame .result-mark { width: clamp(158px, 41vw, 202px); }
.demo-frame .result-center { font-size: clamp(3.3rem, 12vw, 4.2rem); }

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