.wave {
  --ink: #282421;
  --muted: #63574e;
  --line: #e6ddd4;
  --paper: #fff5ec;
  --accent: #a52d20;
  box-sizing: border-box;
  width: min(100%, 57rem);
  margin: 0 auto;
  padding: 18px 16px 48px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.wave *, .wave *::before, .wave *::after { box-sizing: border-box; }
.wave [hidden] { display: none !important; }
.wave h1 { font-size: clamp(23px, 5.6vw, 34px); margin: 0 0 5px; line-height: 1.3; }
.wave h2 { margin: 0 0 12px; font-size: 19px; }
.wave h3 { margin: 0 0 8px; font-size: 16px; }
.wave p { margin: 0 0 12px; }
.wave .muted { color: var(--muted); font-size: 14px; }
.wave .eyebrow { font-size: 13px; font-weight: 800; letter-spacing: .04em; color: var(--accent); }
.wave button, .wave .button {
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #baa99d;
  border-radius: 9px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.wave button:disabled { opacity: .52; cursor: default; }
.wave button.primary { background: var(--accent); color: white; border-color: var(--accent); }
.wave button.pill, .wave .chip { border-radius: 24px; }
.wave input:not([type=checkbox]), .wave select, .wave textarea {
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #baa99d;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.wave input[type=checkbox] { accent-color: var(--accent); width: 20px; height: 20px; margin: 0; }
.wave label { display: block; font-size: 14px; font-weight: 700; min-width: 0; }
.wave label > input:not([type=checkbox]), .wave label > textarea, .wave label > select { display: block; margin-top: 4px; }
.wave .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; min-height: 44px; border: 1px solid var(--line); cursor: pointer;
}
.wave .chip:has(:checked) { border-color: var(--accent); background: var(--paper); }
.wave :focus-visible { outline: 3px solid #1b6477; outline-offset: 2px; }
.wave a { color: var(--accent); text-underline-offset: 3px; }
.wave .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.wave .actions > * { min-width: 0; }
.wave .actions > p { margin: 0; }
.wave .tabs { display: flex; gap: 5px; margin: 14px 0; border-bottom: 1px solid var(--line); }
.wave .tabs button {
  flex: 1; border: 0; border-bottom: 3px solid transparent; border-radius: 5px 5px 0 0;
}
.wave .tabs [aria-selected=true] { border-bottom-color: var(--accent); background: var(--paper); color: var(--accent); }
.wave .columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.wave .stack { display: grid; gap: 12px; min-width: 0; }
.wave .fields { display: grid; gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wave .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 65px auto; gap: 6px; align-items: end; margin-bottom: 6px; }
.wave .result {
  padding: 15px; background: var(--paper); border: 1px solid #ecd7ca; border-radius: 13px; min-width: 0;
}
.wave .result p, .wave .result pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0 0 12px; }
.wave .result .winner { font-weight: 900; font-size: clamp(26px, 6vw, 45px); line-height: 1.15; }
.wave .result .eyebrow { font-size: 13px; }
.wave .result .muted { font-size: 14px; }
.wave .wheel-frame { position: relative; width: min(100%, 230px); margin: 10px auto 12px; }
.wave .wheel-frame::before {
  content: ''; position: absolute; left: 50%; top: 0;
  transform: translateX(-50%); border: 11px solid transparent; border-top: 15px solid var(--ink);
}
.wave .wheel-frame canvas { display: block; width: 100%; height: auto; }
.wave .solo { max-width: 41rem; margin: 0 auto; }
.wave .rule { border: 0; border-top: 1px solid var(--line); margin: 9px 0; }
.wave .warning { font-weight: 700; color: var(--accent); }
.wave fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.wave legend { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.wave summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.wave dialog { max-width: min(660px, 94vw); max-height: 90dvh; border: 1px solid var(--line); border-radius: 12px; padding: 16px; color: var(--ink); }
.wave dialog::backdrop { background: #28242199; }
.wave dialog canvas { display: block; width: auto; max-width: 100%; max-height: 62dvh; object-fit: contain; margin: 12px auto; }
.wave-dialog-body { overflow: auto; }
.wave .help { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 14px; }
.wave .weight-config { max-height: 19rem; overflow: auto; }
.wave .weight-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(80px, 8rem); align-items: center; gap: 8px; margin-bottom: 5px; }
.wave .spin-button { width: 100%; }
@media(max-width: 660px) {
  .wave .columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .wave .exchange-output { grid-row: 1; }
  .wave .wheel-frame { width: min(100%, 168px); }
  .wave [aria-label="ルーレットの結果と操作"] { grid-row: 1; }
}
.wave #history-list li { white-space: pre-wrap; margin: 0 0 9px; }
.wave .wheel-frame::before { z-index: 1; }
.wave #chance-result { margin: 12px 0; min-height: 125px; }
.wave [data-side] {
  display: grid; place-items: center;
  width: 100px; height: 100px;
  border-radius: 50%; border: 5px double #955d19; background: #ffdfa2; color: #5d360b;
}
.wave [data-side=tails] { border-color: #657077; background: #e6ecee; color: #293942; }
.wave [aria-invalid=true] { border-color: var(--accent) !important; }
.wave input[type=date] { min-inline-size: 0; }

.wave #png-pages { margin-bottom: 8px; }
.wave #png-scroll.is-paged { max-height: 55dvh; overflow: auto; margin-bottom: 8px; }
.wave #png-scroll.is-paged canvas { width: 100%; height: auto; max-height: none; margin: 0; }

/* Wave 1 work surfaces, controls and draw stages */
.wave { --paper: #f7f4f3; --line: #e4dedb; }
.wave .result { padding: 12px; background: #fff; border-color: var(--line); }
.wave .result p, .wave .result pre { margin-bottom: 8px; }
.wave .output-toolbar { position: sticky; top: 64px; z-index: 2; padding: 8px 0; background: #fff; border-bottom: 1px solid var(--line); }
.wave .output-title { justify-content: space-between; }
.wave .output-title h2, .wave #copy-hint { margin: 0; }
.wave .exchange-output { align-self: stretch; align-content: start; scroll-margin-top: 64px; }
.wave .jump-links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }
.wave .jump-links button { font-size: .875rem; }
.wave #exchange-output:focus { outline: 0; }
.wave #exchange-output:focus-visible .output-toolbar { outline: 2px solid var(--accent); outline-offset: 2px; }
.wave .result h3[tabindex] { scroll-margin-top: 70px; }
.wave #dm-list { gap: 8px; }
.wave #wheel-labels ol { max-height: 12rem; overflow: auto; margin: 0 0 8px; padding-left: 2rem; }
.wave #wheel-labels [aria-current] { color: var(--accent); font-weight: 800; }
.wave .wheel-frame { width: min(100%, 420px); }
.wave #motion-pause { margin: 4px 0; }
.wave button[aria-disabled=true] { opacity: .65; cursor: default; }
.wave .wave-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wave .chance-visual { display: flex; flex-wrap: wrap; justify-content: center; align-items: end; gap: 8px; min-height: 110px; margin-bottom: 8px; padding: 8px; background: #f6f5fb; border-radius: 9px; }
.wave .chance-visual img { display: block; max-width: 100%; object-fit: contain; }
.wave .chance-visual > img { width: 88px; }
.wave .die { position: relative; width: clamp(60px, 21vw, 99px); aspect-ratio: 1; }
.wave .die b { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(.9rem, 5vw, 1.5rem); color: #2f264c; overflow-wrap: anywhere; text-align: center; }
.wave .coin-stage { perspective: 650px; width: 112px; height: 112px; }
.wave .coin-flip { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.wave .coin-flip img { position: absolute; inset: 0; backface-visibility: hidden; }
.wave .coin-flip img + img { transform: rotateX(180deg); }
body[data-tool="coin-toss"] .chance-visual { padding-top: 78px; }
.wave .fortune-prop { position: relative; height: 210px; width: 140px; }
.wave .fortune-tube { position: absolute; width: 132px; height: 145px; bottom: 0; left: 4px; }
.wave .fortune-slip, .wave .fortune-card-slip { position: relative; width: 59px; margin-inline: auto; }
.wave .fortune-slip img, .wave .fortune-card-slip img { width: 100%; height: 134px; object-fit: fill; }
.wave .fortune-slip strong, .wave .fortune-card-slip strong { position: absolute; inset: 18px 0 0; display: flex; justify-content: center; margin: 0; color: #8e2919; writing-mode: vertical-rl; align-items: center; padding-bottom: 20px; }
.wave .fortune-slip strong { inset: 8px 0 auto; height: 51px; padding: 0; font-size: 17px; }
.wave .fortune-slip { position: absolute; top: 1px; left: calc(50% - 29.5px); clip-path: inset(0 0 25px); }
.wave .fortune-group-toggle { margin-block: 8px; border-block: 1px solid var(--line); }
.wave .fortune-group-toggle summary { min-height: 44px; }
.wave #fortune-group { padding-bottom: 8px; }
.wave .fortune-person { display: grid; grid-template-columns: 64px 1fr; gap: 4px 10px; align-content: start; border-top: 1px solid var(--line); padding: 8px 0; }
.wave .fortune-person h3 { align-self: end; margin: 0; }
.wave .fortune-person p { align-self: start; }
.wave .fortune-card-slip { grid-row: span 2; align-self: center; }
@media(max-width: 660px) {
  .wave .exchange-output { grid-row: auto; }
  .wave .output-toolbar { position: static; }
  .wave .wheel-frame { width: min(100%, 300px); }
}

.wave #wheel-hit {
  position: absolute; z-index: 2; top: 8%; left: 50%; transform: translateX(-50%);
  padding: 3px 9px; border: 2px solid #282421; border-radius: 7px;
  background: #fff; color: #282421; font-size: 15px; font-weight: 800;
  line-height: 1.25; white-space: nowrap; pointer-events: none;
}

.wave .wheel-frame { overflow: hidden; }
