:root {
  --ink: #f4efe4;
  --paper: #1a2233;
  --btn: #6b2e22;
  --hint: #d4a017;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: #12161f;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}
img { max-width: 100%; height: auto; object-fit: contain; }
#ehdApp [hidden] { display: none !important; }

.ehd-hero, .ehd-seo { padding: 20px 16px; text-align: center; color: #e8dcc8; }
.ehd-kicker { margin: 0; letter-spacing: .14em; font-size: 12px; color: #c4a574; }
.ehd-hero h1 { margin: 6px 0 4px; font-size: 28px; }
.ehd-hero p, .ehd-seo p { margin: 0 auto; max-width: 40rem; line-height: 1.7; }
.ehd-seo p { margin-bottom: .8em; }

.ehd-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.ehd-app {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 12px auto;
  width: min(100%, 1100px);
  min-height: 240px;
  height: min(860px, calc(100vh - 120px));
  height: min(860px, calc(100dvh - 120px));
  container: ehd-shell / size;
  background: #152030 url("img/bg_pharmacy.webp") center / cover no-repeat;
  color: var(--ink);
  border-radius: 12px;
  overflow: hidden;
}

.ehd-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 8px;
  padding: 16px;
  background: rgba(10, 12, 20, .88);
  overflow: auto;
}
.ehd-overlay-rules {
  z-index: 6;
  justify-content: flex-start;
  gap: 6px;
  padding: 12px 16px 16px;
}
.ehd-overlay.ehd-intro {
  justify-content: flex-start;
  padding-top: 8px;
}
.ehd-ov-kicker {
  margin: 0;
  letter-spacing: .16em;
  font-size: clamp(15px, 2.6cqh, 20px);
  color: #ffcc80;
  text-align: center;
}
.ehd-ov-game {
  margin: 0;
  font-size: clamp(22px, min(6.5cqh, 7.2cqi), 48px);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 12px #000;
  flex: 0 0 auto;
  line-height: 1.25;
}
.ehd-overlay-rules .ehd-ov-game { font-size: clamp(24px, 4.2cqh, 34px); }
.ehd-ov-lead {
  margin: 0 auto 8px;
  max-width: min(38rem, 92%);
  text-align: center;
  line-height: 1.65;
  font-size: clamp(18px, 3.4cqh, 26px);
}
.ehd-ov-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  flex: 0 0 auto;
  width: min(38rem, 100%);
  margin-inline: auto;
}
.ehd-btn {
  min-height: 48px;
  min-width: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: #3a4558;
  color: #fff8e8;
  font-size: clamp(17px, 2.8cqh, 22px);
  cursor: pointer;
}
.ehd-ov-actions .ehd-btn { flex: 1 1 9.5rem; }
.ehd-btn-main { background: var(--btn); font-weight: 700; }
.ehd-rules {
  margin: 0 auto;
  max-width: min(38rem, 92%);
  padding: 0 1.2rem;
  font-size: clamp(16px, 2.6cqh, 20px);
  line-height: 1.55;
}
.ehd-rules li { margin: 0 0 .45em; }
.ehd-rules-ex {
  margin: 0 auto 8px;
  max-width: min(38rem, 92%);
  padding: 10px 14px;
  background: rgba(212, 160, 23, .18);
  border-radius: 8px;
  font-size: clamp(16px, 2.4cqh, 20px);
  line-height: 1.5;
}

.ehd-intro-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(100%, 960px);
  margin: 0 auto;
}
.ehd-stills {
  width: 100%;
  height: auto;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #0b1020;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}
html.is-embed .ehd-stills {
  max-height: calc(100% - 96px);
}
html:not(.is-embed) .ehd-stills {
  max-height: 62vh;
}
.ehd-stills img {
  height: 100%;
  width: auto;
  max-width: 42%;
  object-fit: contain;
  object-position: bottom;
}
.ehd-stills.is-cast img:only-child {
  max-width: 38%;
}
.ehd-stills.is-scene {
  padding: 0;
  align-items: stretch;
}
.ehd-stills.is-scene img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center 40%;
}
@media (prefers-reduced-motion: no-preference) {
  .ehd-stills img {
    animation: ehd-still-in .35s ease;
  }
}
@keyframes ehd-still-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ehd-caption {
  min-height: 1.6em;
  margin: 0;
  text-align: center;
  font-size: clamp(17px, 3.2cqh, 24px);
  line-height: 1.5;
}
.ehd-intro-buttons { display: flex; gap: 8px; }

.ehd-story {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 28rem;
  margin: 0 auto;
}
.ehd-story img {
  height: min(52cqh, 420px);
  width: auto;
  object-fit: contain;
  object-position: bottom;
}
.ehd-story-text {
  margin: 0;
  text-align: center;
  font-size: clamp(17px, 3.2cqh, 24px);
  line-height: 1.6;
}
.ehd-stars { text-align: center; font-size: 22px; color: #ffd54a; margin: 0; }
.ehd-overlay-note {
  justify-content: flex-start;
  gap: 6px;
  padding: 10px 12px 12px;
  overflow: hidden;
  min-height: 0;
}
.ehd-note-sum {
  margin: 0 auto;
  text-align: center;
  font-size: clamp(15px, 2.2cqh, 18px);
  line-height: 1.45;
  flex: 0 0 auto;
}
.ehd-note-legend {
  margin: 0 auto;
  text-align: center;
  font-size: clamp(13px, 1.8cqh, 15px);
  color: #c4a574;
  flex: 0 0 auto;
}
.ehd-notes {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(8, 10, 18, .55);
  overflow: hidden;
}
.ehd-note-cell {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid rgba(196, 165, 116, .28);
  border-radius: 6px;
  background: rgba(30, 38, 52, .9);
  color: #8a8478;
  font-size: clamp(11px, 2.6cqi, 14px);
  font-weight: 700;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1.1;
}
.ehd-note-cell:disabled {
  opacity: 1;
  color: #8a8478;
}
.ehd-note-cell.is-open {
  color: #fff8e8;
  background: rgba(58, 69, 88, .95);
  cursor: pointer;
}
.ehd-note-cell.is-done {
  color: #1a2233;
  background: #e8c56b;
  border-color: #c4a574;
  cursor: pointer;
}
.ehd-note-cell.is-next {
  outline: 2px solid #ffd54a;
  outline-offset: -2px;
  color: #fff8e8;
  background: rgba(80, 70, 30, .95);
  cursor: pointer;
}
.ehd-note-stars {
  font-size: clamp(6px, 1.5cqi, 9px);
  letter-spacing: 0;
  color: #6b2e22;
  height: 0.9em;
}
.ehd-note-cell.is-open .ehd-note-stars,
.ehd-note-cell.is-next .ehd-note-stars { color: #ffd54a; }
@container ehd-shell (min-aspect-ratio: 1/1) {
  .ehd-notes {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
  }
}
@container ehd-shell (max-width: 420px) {
  .ehd-note-stars { display: none; }
}
@container ehd-shell (max-height: 420px) {
  .ehd-overlay-note { padding: 6px 8px; gap: 4px; }
  .ehd-overlay-note .ehd-btn { min-height: 36px; }
  .ehd-note-stars { display: none; }
  .ehd-notes { gap: 3px; padding: 4px; }
}

.ehd-play {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100%;
  min-height: 0;
  background: rgba(8, 12, 22, .28);
}
.ehd-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 10px;
  background: rgba(8, 10, 18, .72);
  font-size: clamp(14px, 2cqh, 16px);
}
.ehd-hud-moves { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ehd-hud-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: #3a4558;
  color: #fff8e8;
  font-size: clamp(14px, 2cqh, 16px);
  cursor: pointer;
}
.ehd-coach {
  margin: 0;
  padding: 8px 12px;
  background: rgba(8, 10, 18, .86);
  font-size: clamp(14px, 2.1cqh, 17px);
  line-height: 1.5;
  text-align: center;
  border-bottom: 2px solid var(--hint);
}
.ehd-field {
  display: grid;
  grid-template-columns: 1fr;
  position: relative;
  min-height: 0;
  height: 100%;
}
.ehd-char {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: min(34%, 150px);
  height: min(52%, 340px);
  min-width: 0;
  padding: 4px;
  z-index: 0;
  pointer-events: none;
}
.ehd-char img {
  flex: 0 0 auto;
  height: 100%;
  width: auto;
  max-width: 100%;
  min-height: 96px;
  object-fit: contain;
  object-position: bottom;
}
.ehd-speech { display: none; }
.ehd-board {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  padding: 8px 8px 12px;
  overflow: hidden;
}
.ehd-rack {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--ehd-cols, 3), var(--ehd-tube-w, 72px));
  justify-content: center;
  align-content: safe center;
  align-items: end;
  gap: var(--ehd-gap, 12px);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.ehd-tube {
  position: relative;
  width: var(--ehd-tube-w, 72px);
  height: var(--ehd-tube-h, 280px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.ehd-tube-glass {
  position: absolute;
  inset: 6% 10% 0;
  border: 2.5px solid rgba(255, 255, 255, .9);
  border-top-width: 3px;
  border-radius: 11px 11px 50% 50% / 9px 9px 32px 32px;
  background:
    linear-gradient(90deg,
      rgba(255,255,255,.38) 0%,
      rgba(255,255,255,.10) 16%,
      rgba(255,255,255,.02) 42%,
      transparent 58%,
      rgba(6,10,18,.22) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.18),
    inset 8px 0 14px rgba(255,255,255,.08),
    0 10px 18px rgba(0, 0, 0, .32);
  overflow: hidden;
}
.ehd-tube-glass::after {
  content: "";
  position: absolute;
  left: 16%;
  top: 8%;
  width: 18%;
  height: 58%;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,.04));
  pointer-events: none;
}
.ehd-tube-inner {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 8%;
  height: 78%;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  border-radius: 0 0 22px 22px;
  transform-origin: 50% 86%;
}
.ehd-layer {
  flex: 0 0 25%;
  min-height: 0;
  background: transparent;
  font-size: 0;
}
.ehd-layer.is-filled {
  background:
    linear-gradient(90deg,
      var(--liq-shade) 0%,
      var(--liq) 18%,
      var(--liq-hi) 46%,
      var(--liq) 72%,
      var(--liq-shade) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
  border-top: 1px solid rgba(8, 10, 18, .28);
}
.ehd-layer.is-top {
  border-radius: 50% 50% 0 0 / 14px 14px 0 0;
}
.ehd-tube.is-picked {
  z-index: 2;
  transform: translateY(-8%);
}
.ehd-tube.is-hint .ehd-tube-glass {
  outline: 3px solid var(--hint);
  outline-offset: 3px;
}
.ehd-tube.is-coach .ehd-tube-glass {
  outline: 3px solid #ffd54a;
  outline-offset: 3px;
}
.ehd-tube.is-pouring-right,
.ehd-tube.is-pouring-left { z-index: 3; }
.ehd-tube.is-pouring-right {
  transform: translate(18%, -10%) rotate(48deg);
  transform-origin: 50% 8%;
}
.ehd-tube.is-pouring-left {
  transform: translate(-18%, -10%) rotate(-48deg);
  transform-origin: 50% 8%;
}
.ehd-tube.is-pouring-right .ehd-tube-inner {
  transform: rotate(-48deg);
}
.ehd-tube.is-pouring-left .ehd-tube-inner {
  transform: rotate(48deg);
}
.ehd-stream {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  border-radius: 999px;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, var(--stream), color-mix(in srgb, var(--stream) 65%, #fff));
  box-shadow: 0 0 8px var(--stream);
  animation: ehdStream .42s linear both;
}
@keyframes ehdStream {
  from { opacity: .15; clip-path: inset(0 0 100% 0); }
  35% { opacity: 1; clip-path: inset(0 0 0 0); }
  to { opacity: .9; clip-path: inset(0 0 0 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .ehd-tube { transition: transform .28s ease; }
  .ehd-tube.is-coach { animation: ehdPulse 1.6s ease-in-out infinite; }
  .ehd-layer.is-filling { animation: ehdFill .42s ease-out both; }
  .ehd-layer.is-draining { animation: ehdDrain .38s ease-in forwards; }
}
@keyframes ehdPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.28) saturate(1.15); }
}
@keyframes ehdFill {
  from { flex-basis: 0%; opacity: .4; }
  to { flex-basis: 25%; opacity: 1; }
}
@keyframes ehdDrain {
  to { flex-basis: 0%; opacity: .12; }
}

@container ehd-shell (min-aspect-ratio: 1/1) {
  .ehd-play {
    grid-template-columns: minmax(120px, 20%) 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .ehd-hud { grid-column: 1 / -1; }
  .ehd-coach { grid-column: 1 / -1; }
  .ehd-field {
    grid-column: 1 / -1;
    grid-template-columns: minmax(100px, 22%) 1fr;
  }
  .ehd-char {
    position: relative;
    left: auto;
    bottom: auto;
    width: auto;
    height: auto;
    pointer-events: auto;
  }
  .ehd-char img {
    height: min(70cqh, 520px);
    min-height: 96px;
  }
  .ehd-speech {
    display: block;
    margin: 4px 2px 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(8, 10, 18, .78);
    font-size: clamp(13px, 2cqh, 16px);
    line-height: 1.4;
    text-align: center;
  }
  .ehd-board { overflow: visible; }
}

html.is-embed .ehd-hero,
html.is-embed .ehd-seo { display: none; }
html.is-embed,
html.is-embed body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #152030;
}
html.is-embed body { position: relative; }
html.is-embed .ehd-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  border-radius: 0;
}

@media (max-height: 40rem) {
  html:not(.is-embed) .ehd-hero { padding: 6px 12px 2px; }
  html:not(.is-embed) .ehd-hero h1 { font-size: 22px; }
  html:not(.is-embed) .ehd-hero p { display: none; }
  html:not(.is-embed) .ehd-seo { display: none; }
  html:not(.is-embed) .ehd-app { height: calc(100dvh - 64px); margin: 4px auto; }
  .ehd-hud { padding: 3px 8px; }
  .ehd-speech { display: none; }
  .ehd-coach { font-size: 13px; padding: 6px 8px; }
}

@container ehd-shell (max-width: 520px) {
  .ehd-hud {
    padding: 4px 8px;
    gap: 4px 6px;
  }
  .ehd-hud-btn { padding: 4px 8px; }
}
