:root {
  --navy: #12365e;
  --blue: #1976c9;
  --sky: #dff5ff;
  --cream: #fffaf0;
  --gold: #ffbf28;
  --orange: #f77c2e;
  --green: #27a95b;
  --red: #e64a3c;
  --purple: #8d55c7;
  --ink: #183047;
  --muted: #63798d;
  --line: #d5e1e9;
  --shadow: 0 14px 36px rgba(21, 58, 89, .18);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  min-height: 100%;
  background: #dff5ff;
  color: var(--ink);
}
html:root:not([data-app-block-surface]) > body { padding: 0; }

body {
  min-height: 100dvh;
  overflow: hidden;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid rgba(255, 173, 0, .55);
  outline-offset: 2px;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; }

.button {
  min-height: 42px;
  border: 0;
  border-radius: 13px;
  padding: 10px 18px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: #e9f1f7;
  box-shadow: 0 4px 0 rgba(17, 55, 86, .16);
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
  white-space: nowrap;
}

.button:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(17, 55, 86, .16); }
.button:disabled { opacity: .46; cursor: not-allowed; box-shadow: none; }
.button.primary { background: linear-gradient(#ffcc39, #f69a1d); color: #382400; }
.button.accent { background: linear-gradient(#44ca85, #1ca25e); color: #fff; }
.button.secondary { background: #fff; border: 2px solid #c8d9e4; }
.button.bronze { background: linear-gradient(#e9a64c, #b96320); color: #fff; }
.button.danger-fill { background: linear-gradient(#f06b60, #cf3c35); color: #fff; }
.button.danger { border-color: #c5322c; background: linear-gradient(#f06b60, #cf3c35); color: #fff; }
.button.jumbo { min-height: 50px; padding-inline: 26px; font-size: 1.05rem; }

/* Title */
.title-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
  background:
    radial-gradient(circle at 14% 18%, rgba(255,255,255,.92) 0 3px, transparent 4px),
    radial-gradient(circle at 76% 12%, rgba(255,255,255,.8) 0 2px, transparent 3px),
    linear-gradient(#65c9ff 0 45%, #8ade8d 45% 52%, #307a52 52% 100%);
}

.title-screen::after {
  content: "";
  position: fixed;
  inset: auto 0 0;
  height: 22vh;
  background:
    linear-gradient(150deg, transparent 0 12%, #274b6b 12% 13%, transparent 13% 22%, #274b6b 22% 23%, transparent 23%) 0 100%/320px 100% repeat-x,
    linear-gradient(25deg, rgba(255,255,255,.08), transparent);
  pointer-events: none;
}

.title-card {
  position: relative;
  z-index: 2;
  width: min(920px, 96vw);
  border: 5px solid #fff;
  border-radius: 28px;
  padding: 20px 28px 24px;
  background: rgba(255, 250, 240, .96);
  box-shadow: 0 18px 0 rgba(20, 61, 93, .2), var(--shadow);
  text-align: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: #dc691c;
  font-weight: 900;
  letter-spacing: .08em;
}

.title-card h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  color: #ef7d22;
  line-height: 1;
  text-shadow: 0 3px 0 #fff, 0 7px 0 rgba(154, 80, 16, .14);
}
.title-card h1 span { color: #126fb0; font-size: .72em; }
.title-copy { margin: 10px 0 16px; font-weight: 800; }

.title-festival {
  position: relative;
  min-height: 118px;
  display: grid;
  grid-template-columns: 125px minmax(260px, 1fr) 150px;
  align-items: center;
  gap: 12px;
  margin: -2px auto 13px;
  padding-inline: 24px;
}
.title-card-fan {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.title-card-fan img {
  width: 82px;
  max-height: 112px;
  border: 4px solid #fff;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 9px 18px rgba(20,61,93,.23);
}
.title-card-fan img:first-child { transform: translateX(14px) rotate(-9deg); }
.title-card-fan img:nth-child(2) { position: relative; z-index: 2; transform: translateY(-5px); }
.title-card-fan img:last-child { transform: translateX(-14px) rotate(9deg); }
.title-coin-stack {
  position: relative;
  width: 104px;
  height: 82px;
  margin: auto;
}
.title-coin-stack span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 6px double #fff1a3;
  border-radius: 50%;
  color: #8d5800;
  background: radial-gradient(circle at 35% 30%, #fff3a1, #ffc62f 48%, #dc8413);
  font-size: 1.35rem;
  text-shadow: 0 1px #fff;
  box-shadow: 0 7px 12px rgba(133,81,0,.2);
}
.title-coin-stack span:nth-child(1) { left: 2px; top: 18px; transform: rotate(-12deg); }
.title-coin-stack span:nth-child(2) { left: 42px; top: 25px; transform: rotate(10deg); }
.title-coin-stack span:nth-child(3) { left: 23px; top: 0; }
.title-attraction-icons {
  position: relative;
  min-height: 104px;
  font-size: 3.9rem;
  filter: drop-shadow(0 7px 5px rgba(20,61,93,.18));
}
.title-wheel { position: absolute; right: 35px; top: 0; }
.title-tent { position: absolute; right: 0; bottom: 0; font-size: 2.45rem; }
.title-coins { position: absolute; left: 0; bottom: 5px; font-size: 1.55rem; transform: rotate(-8deg); }

.mode-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.mode-picker.single-mode { grid-template-columns: minmax(0, 1fr); }
.single-mode .mode-option { cursor: default; border-color: #f4a21d; background: #fff6d8; }

.mode-option {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 3px solid #d7e3ea;
  border-radius: 17px;
  background: #fff;
  cursor: pointer;
}
.mode-option:has(input:checked) {
  border-color: #f4a21d;
  background: #fff6d8;
  box-shadow: inset 0 0 0 2px #fff;
}
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option strong { font-size: 1.08rem; color: var(--navy); }
.mode-option span { font-size: .84rem; color: var(--muted); }

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.setup-grid label, .player-config {
  display: grid;
  gap: 5px;
  text-align: left;
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
}
select, .player-config input {
  width: 100%;
  min-height: 40px;
  border: 2px solid #cbdbe5;
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.player-setup {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 12px;
}
.setup-summary {
  margin: 10px 0 0;
  color: var(--navy);
  font-size: .92rem;
  font-weight: 900;
}
.player-config {
  border-radius: 13px;
  padding: 9px;
  background: #edf7fc;
  border-top: 5px solid var(--player-color, #1689d8);
}
.player-config .seat-label { color: var(--ink); font-size: .9rem; }
.cpu-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--navy);
  background: #dfeef8;
  font-size: .9rem;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}
.version { position: fixed; z-index: 3; right: 12px; bottom: 4px; color: #fff; font-weight: 800; }
.title-sky { position: fixed; inset: 0; pointer-events: none; }
.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 -42px #fff, 29px -29px #ffdf4b, 42px 0 #fff, 29px 29px #ff8b40,
    0 42px #fff, -29px 29px #ffdf4b, -42px 0 #fff, -29px -29px #ff8b40;
  animation: sparkle 2.4s ease-in-out infinite;
}
.firework.f1 { left: 10%; top: 18%; }
.firework.f2 { right: 10%; top: 22%; animation-delay: 1.1s; }
.star { position: absolute; color: #fff08b; font-size: 24px; animation: float 2.2s ease-in-out infinite; }
.star.s1 { left: 17%; top: 44%; }
.star.s2 { right: 18%; top: 42%; animation-delay: .8s; }

/* Game */
.game-screen {
  height: 100dvh;
  flex-direction: column;
  background: linear-gradient(#def5ff, #f5fbff 35%, #eef8eb);
  overflow: hidden;
}

.game-header {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: linear-gradient(90deg, #103a68, #1767a2);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 47, 75, .2);
  z-index: 4;
}
.header-title { font-size: 1.28rem; font-weight: 900; }
.icon-button {
  min-width: 50px;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.icon-button span { font-size: .72rem; }
.title-return-button {
  min-width: 82px;
  white-space: nowrap;
}
.icon-button.danger { background: rgba(231, 72, 60, .78); }
.special-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  justify-content: center;
  border-radius: 12px;
  padding: 5px 11px;
  color: #173350;
  background: #fff3a9;
}
.special-counter span { font-size: .75rem; font-weight: 900; }
.special-counter .special-six {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 8px;
  color: #fff;
  background: #173b63;
  font-size: 1.25rem;
}
.special-counter strong {
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--gold);
  font-size: 1rem;
  white-space: nowrap;
}
.special-counter.final { background: linear-gradient(90deg, #3b1b69, #8f46a8); color: #fff; }
.special-counter.final .special-six { color: #4b2770; background: #ffcf42; }
.special-counter.final strong { background: #ffcf42; color: #4b2770; padding-inline: 9px; font-size: .9rem; }

.game-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(175px, 19vw, 235px) minmax(520px, 1fr) clamp(200px, 22vw, 275px);
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.players-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.player-panel {
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 5px;
  padding: 9px;
  border: 3px solid var(--player-color);
  border-radius: 15px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 5px 12px rgba(28, 66, 95, .1);
  overflow: hidden;
}
.player-panel.current { box-shadow: 0 0 0 4px #ffd23d, 0 8px 18px rgba(28,66,95,.2); }
.player-panel.effect-active { animation: effectPulse .75s ease-in-out infinite alternate; }
.player-panel.skipped::after {
  content: "次の手番スキップ";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(109, 36, 44, .82);
  font-weight: 900;
  transform: rotate(-3deg);
}
.player-summary { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.player-name-button {
  max-width: 145px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 7px;
  padding: 2px 4px;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.player-name-button:hover,
.player-name-button:focus-visible { background: #e2f2fa; }
.player-name { font-size: .95rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-type { color: var(--muted); font-size: .66rem; }
.coin-count {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff0a9;
  color: #593d00;
  font-weight: 900;
}
.coin-symbol { width: 17px; height: 17px; border-radius: 50%; background: linear-gradient(#ffd84d,#f3a400); border: 2px solid #fff5a1; box-shadow: 0 0 0 1px #b47b00; }
.owned-list {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: auto;
}
.owned-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 25px;
  border-radius: 7px;
  padding: 2px 6px 2px 3px;
  background: #edf4f8;
  border-left: 4px solid var(--chip-color, #789);
  font-size: .67rem;
  font-weight: 900;
}
.owned-chip img { width: 20px; height: 25px; object-fit: cover; object-position: top; border-radius: 3px; }
.coin-float {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 38px;
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 5px 10px;
  color: #5b3a00;
  background: #ffd443;
  font-size: 1.05rem;
  font-weight: 900;
  pointer-events: none;
  animation: coinFloat 1.15s ease-out forwards;
}

.market-section {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 3px solid #d9bf83;
  border-radius: 18px;
  padding: 8px;
  background: rgba(255, 251, 238, .94);
  box-shadow: inset 0 0 0 3px #fff, 0 7px 16px rgba(60, 79, 55, .13);
  overflow: hidden;
}
.market-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 2px; }
.market-heading-row > div { min-width: 0; }
.market-heading-row h2 { margin: 0 0 4px; font-size: 1rem; color: #744814; }
.market-heading-row p { margin: 0; font-size: .73rem; font-weight: 800; color: var(--muted); }
.market-scale-control {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 92px 40px;
  align-items: center;
  gap: 6px;
  color: #5a4630;
  font-size: .68rem;
  font-weight: 900;
  white-space: nowrap;
}
.market-scale-control input { width: 92px; accent-color: #1976c9; cursor: pointer; }
.market-scale-control output { color: #176ba1; text-align: right; font-variant-numeric: tabular-nums; }
.special-day-board-card {
  flex: 0 0 auto;
  width: calc(100% - 6px);
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(210px, 250px) auto;
  align-items: center;
  gap: 12px;
  margin: 0 3px 4px;
  border: 2px solid #e5b94e;
  border-radius: 13px;
  padding: 5px 10px;
  color: #fff;
  background: linear-gradient(120deg, #3a236b, #764098 55%, #b84f84);
  box-shadow: 0 4px 9px rgba(73, 38, 99, .2);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}
.special-day-board-card:hover {
  border-color: #ffe47c;
  box-shadow: 0 0 0 3px rgba(255,212,67,.25), 0 5px 12px rgba(73,38,99,.25);
}
.special-day-board-visual {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1980 / 890;
  min-width: 0;
}
.special-day-board-visual img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: fill;
}
.special-day-current-marker {
  --special-count: 9;
  position: absolute;
  left: calc(4.7% + var(--special-count) * 9.02%);
  bottom: 1.5%;
  width: 8.4%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border: 3px solid #fff34d;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #7a326c, 0 0 13px 5px rgba(255,238,57,.9);
  pointer-events: none;
  animation: currentCountPulse .8s ease-in-out infinite alternate;
}
.special-day-board-copy { display: grid; gap: 1px; min-width: 0; }
.special-day-board-copy span { font-size: .66rem; font-weight: 800; opacity: .82; }
.special-day-board-copy strong { font-size: 1rem; white-space: nowrap; }
.special-day-board-card.final {
  border-color: #ffe16c;
  background: linear-gradient(120deg, #d34e79, #713d9f 55%, #273d83);
  animation: specialCardGlow 1.1s ease-in-out infinite alternate;
}
.special-day-board-card.final .special-day-current-marker {
  border-color: #fff;
  box-shadow: 0 0 0 3px #ffcc3a, 0 0 18px 7px rgba(255,226,83,.95);
}
.unlock-progress {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 0 3px 5px;
}
.unlock-step {
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid #ccd9e1;
  border-radius: 10px;
  padding: 4px 8px;
  color: #536777;
  background: #edf2f5;
  font-size: .72rem;
  font-weight: 900;
  text-align: center;
}
.unlock-step.unlocked { border-color: #4eb479; color: #155c35; background: #e4f8ec; }
.unlock-step.purple.unlocked { border-color: #9867bd; color: #5f3280; background: #f3e9fb; }
.unlock-step.ticket.unlocked { border-color: #d59b1a; color: #744c00; background: #fff3c2; }
.six-face {
  --die-size: 42px;
  --dot-size: 7px;
  width: var(--die-size);
  height: var(--die-size);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  flex: 0 0 auto;
  border: 3px solid #173b63;
  border-radius: calc(var(--die-size) * .2);
  padding: calc(var(--die-size) * .1);
  background: #fff;
  box-shadow: 0 4px 8px rgba(0,0,0,.2);
}
.six-face i { width: var(--dot-size); height: var(--dot-size); border-radius: 50%; background: #173b63; }
.six-face i:nth-child(1) { grid-area: 1 / 1; }
.six-face i:nth-child(2) { grid-area: 1 / 3; }
.six-face i:nth-child(3) { grid-area: 2 / 1; }
.six-face i:nth-child(4) { grid-area: 2 / 3; }
.six-face i:nth-child(5) { grid-area: 3 / 1; }
.six-face i:nth-child(6) { grid-area: 3 / 3; }
.six-face.large { --die-size: 104px; --dot-size: 17px; border-width: 5px; }
.market-board {
  --market-scale: .75;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  transform: scale(var(--market-scale));
  transform-origin: top center;
  transition: transform .18s ease;
}
.market-grid {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.ticket-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0 3px;
  color: #9c5b13;
  font-size: .75rem;
  font-weight: 900;
}
.ticket-heading::before, .ticket-heading::after { content: ""; height: 2px; flex: 1; background: #e1c493; }
.ticket-grid {
  height: clamp(105px, 17vh, 160px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.market-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  justify-content: center;
  border: 2px solid #d6e0e6;
  border-radius: 11px;
  padding: 3px;
  background: #fff;
  overflow: hidden;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.market-card img { width: 100%; height: 100%; object-fit: contain; }
.market-card.color-red { border-top: 6px solid #d93d35; }
.market-card.color-blue { border-top: 6px solid #087ebc; }
.market-card.color-green { border-top: 6px solid #218b45; }
.market-card.color-purple { border-top: 6px solid #7b43ad; }
.market-card.color-ticket { border-top: 6px solid #e8ac18; }
.market-card.purchasable { cursor: pointer; border-color: #f0a51f; box-shadow: 0 0 0 3px rgba(255,190,36,.3); }
.market-card.color-red.purchasable { border-top-color: #d93d35; }
.market-card.color-blue.purchasable { border-top-color: #087ebc; }
.market-card.color-green.purchasable { border-top-color: #218b45; }
.market-card.color-purple.purchasable { border-top-color: #7b43ad; }
.market-card.color-ticket.purchasable { border-top-color: #e8ac18; }
.market-card.purchasable:hover { transform: translateY(-3px) scale(1.015); box-shadow: 0 7px 16px rgba(92,68,16,.24); }
.market-card.sold-out { filter: grayscale(.9); opacity: .52; }
.market-card.locked img { filter: grayscale(.75); opacity: .48; }
.lock-badge {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 12px);
  border: 2px solid #fff;
  border-radius: 9px;
  padding: 5px 4px;
  color: #fff;
  background: rgba(45, 52, 65, .9);
  font-size: .66rem;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.2);
}
.stock-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 36px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(18, 54, 94, .92);
  color: #fff;
  font-size: .68rem;
  font-weight: 900;
  text-align: center;
}
.price-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  border-radius: 8px;
  padding: 4px 7px;
  background: #ffdf45;
  color: #3e2b00;
  font-size: .72rem;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(0,0,0,.16);
}
.price-badge.free { background: #4ad27e; color: #fff; }

.current-hand-panel {
  flex: 0 0 clamp(150px, 21dvh, 205px);
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(155px, 16vw, 210px) 1fr;
  gap: 10px;
  margin: 0 10px 10px;
  border: 3px solid #73a9ce;
  border-radius: 17px;
  padding: 9px;
  background: rgba(240, 249, 255, .98);
  box-shadow: 0 7px 17px rgba(22, 74, 112, .17);
  overflow: hidden;
}
.current-hand-heading {
  display: grid;
  align-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px;
  color: #fff;
  background: linear-gradient(145deg, #155f96, #193f70);
}
.current-hand-heading > div { display: grid; gap: 2px; }
.current-hand-heading span { font-size: .7rem; font-weight: 800; opacity: .8; }
.current-hand-heading strong { font-size: 1.03rem; line-height: 1.3; }
.current-hand-heading p { margin: 0; font-size: .68rem; font-weight: 800; opacity: .82; }
.current-hand {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 3px 5px;
  scrollbar-color: #79a8c8 transparent;
}
.hand-card {
  position: relative;
  flex: 0 0 auto;
  height: 100%;
  width: clamp(88px, 8.5vw, 116px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) 25px;
  border: 2px solid #c3d8e5;
  border-radius: 10px;
  padding: 2px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(24, 68, 101, .15);
  cursor: pointer;
  overflow: hidden;
  transition: transform .14s, box-shadow .14s;
}
.hand-card:hover { transform: translateY(-3px); box-shadow: 0 7px 14px rgba(24,68,101,.23); }
.hand-card.color-red { border-color: #d93d35; }
.hand-card.color-blue { border-color: #087ebc; }
.hand-card.color-green { border-color: #218b45; }
.hand-card.color-purple { border-color: #7b43ad; }
.hand-card.color-ticket { border-color: #e8ac18; }
.hand-card img { display: block; width: 100%; height: 100%; min-height: 0; border-radius: 7px 7px 3px 3px; object-fit: contain; }
.hand-count-badge {
  display: grid;
  place-items: center;
  width: 100%;
  height: 23px;
  border-radius: 5px;
  color: #fff;
  background: #176ba1;
  font-size: .78rem;
  font-weight: 900;
}
.hand-card.color-red .hand-count-badge { background: #d93d35; }
.hand-card.color-blue .hand-count-badge { background: #087ebc; }
.hand-card.color-green .hand-count-badge { background: #218b45; }
.hand-card.color-purple .hand-count-badge { background: #7b43ad; }
.hand-card.color-ticket .hand-count-badge { color: #553700; background: #f2bd31; }

.turn-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
}
.turn-exit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.turn-exit-actions .button {
  min-height: 36px;
  padding: 6px 7px;
  font-size: .75rem;
  white-space: nowrap;
}
.turn-player {
  display: grid;
  place-items: center;
  border-radius: 13px;
  padding: 8px;
  background: #e8f5ff;
}
.turn-player span { font-size: .72rem; color: var(--muted); font-weight: 800; }
.turn-player strong { font-size: 1.18rem; }
.skip-effects-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid #bed6e5;
  border-radius: 11px;
  padding: 7px 9px;
  color: #244a66;
  background: #eef8fd;
  cursor: pointer;
}
.skip-effects-toggle input { width: 20px; height: 20px; margin: 0; accent-color: #176fb2; }
.skip-effects-toggle span { min-width: 0; display: grid; gap: 1px; }
.skip-effects-toggle strong { font-size: .76rem; }
.skip-effects-toggle small { color: var(--muted); font-size: .61rem; font-weight: 800; line-height: 1.2; }
.dice-stage { display: grid; place-items: center; gap: 3px; padding: 5px; }
.dice {
  display: grid;
  place-items: center;
  width: clamp(74px, 9vw, 112px);
  aspect-ratio: 1;
  border-radius: 20px;
  background: #fff;
  color: #183047;
  font-family: Georgia, serif;
  font-size: clamp(4.5rem, 9vw, 7rem);
  line-height: 1;
  box-shadow: inset 0 0 0 4px #d7e3ea, 0 10px 15px rgba(25, 58, 82, .15);
}
.dice.rolling { animation: diceRoll .16s linear infinite; }
.dice-stage p { min-height: 34px; margin: 3px 0 0; text-align: center; font-size: .77rem; font-weight: 800; color: var(--muted); }
.roll-button { font-size: 1.08rem; }
.reroll-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.reroll-actions p { grid-column: 1 / -1; margin: 0; text-align: center; font-size: .75rem; font-weight: 800; }
.purchase-summary {
  border-radius: 11px;
  padding: 8px;
  background: #fff4c7;
  font-size: .78rem;
  font-weight: 800;
  text-align: center;
}
.turn-log {
  flex: 1;
  min-height: 55px;
  overflow: auto;
  border-radius: 10px;
  padding: 7px;
  background: #f1f6f9;
  font-size: .7rem;
  line-height: 1.45;
}
.log-line { margin-bottom: 3px; }

/* Information */
.info-screen {
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: linear-gradient(140deg, #58bff0, #3676b7 55%, #24517d);
  overflow: auto;
}
.info-card {
  width: min(1050px, 96vw);
  max-height: 92dvh;
  overflow: auto;
  border: 5px solid rgba(255,255,255,.72);
  border-radius: 24px;
  padding: 18px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}
.info-header {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin: -2px -2px 12px;
  padding: 5px 2px 10px;
  background: #fffdf7;
}
.info-header h2 { margin: 0; text-align: center; color: var(--navy); }
.rules-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.rules-columns article { border-radius: 15px; padding: 14px 17px; background: #edf7fc; }
.rules-columns h3 { margin: 0 0 7px; color: #116da8; }
.rules-columns p, .rules-columns li { line-height: 1.7; }
.color-help { list-style: none; padding: 0; }
.dot { display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 50%; vertical-align: -1px; }
.dot.purple { background: var(--purple); }
.dot.blue { background: #19aee5; }
.dot.green { background: #75c945; }
.dot.red { background: var(--red); }
.rules-visual {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.rules-panel {
  border: 2px solid #c9dce8;
  border-radius: 16px;
  padding: 14px;
  background: #edf7fc;
}
.rules-panel h3 { margin: 0 0 10px; color: #116da8; }
.rules-panel p { margin: 9px 0 0; line-height: 1.65; }
.rules-start-kit { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.rules-start-cards { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.rules-start-cards img { width: min(31%, 105px); border-radius: 8px; box-shadow: 0 4px 9px rgba(28,71,98,.18); }
.rules-start-cards > span { font-size: 1.5rem; font-weight: 900; }
.rules-start-coins { min-width: 100px; display: grid; grid-template-columns: auto auto; place-items: center; border-radius: 14px; padding: 12px; color: #5e4200; background: #fff0a8; }
.rules-start-coins > span { grid-row: 1 / 3; font-size: 2rem; }
.rules-start-coins strong { font-size: 2rem; line-height: 1; }
.rules-start-coins small { font-weight: 900; }
.rules-flow { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.rules-flow > div { position: relative; min-width: 76px; display: grid; place-items: center; gap: 3px; border-radius: 12px; padding: 9px 6px; background: #fff; }
.rules-flow > div > b { position: absolute; left: 5px; top: 4px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #176ba1; font-size: .7rem; }
.rules-flow > div > span { font-size: 1.8rem; }
.rules-flow > div > strong { font-size: .72rem; }
.flow-arrow { color: #1c6b9f; font-size: 1.3rem; font-weight: 900; }
.rules-card-reading { grid-row: span 2; }
.card-reading-layout {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(145px, 210px) minmax(100px, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 10px;
}
.card-reading-layout > img { grid-column: 2; grid-row: 1 / 3; width: 100%; border-radius: 11px; box-shadow: 0 8px 17px rgba(25,67,94,.22); }
.card-callout { display: grid; gap: 3px; border-radius: 12px; padding: 10px; background: #fff; font-size: .75rem; line-height: 1.45; }
.card-callout strong { color: #105f94; font-size: .86rem; }
.card-callout.activation { grid-column: 1; grid-row: 1; }
.card-callout.price { grid-column: 3; grid-row: 1; }
.card-callout.effect { grid-column: 3; grid-row: 2; }
.rules-color-list { display: grid; gap: 7px; }
.rules-color-row { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 10px; border-left: 8px solid; border-radius: 10px; padding: 6px 8px; background: #fff; }
.rules-color-row img { width: 58px; max-height: 58px; object-fit: contain; }
.rules-color-row span { display: grid; gap: 2px; font-size: .73rem; line-height: 1.4; }
.rules-color-row strong { font-size: .83rem; }
.rules-color-row.red { border-color: #d93d35; }
.rules-color-row.blue { border-color: #087ebc; }
.rules-color-row.green { border-color: #218b45; }
.rules-color-row.purple { border-color: #7b43ad; }
.rules-color-row.ticket { border-color: #e8ac18; }
.rules-math-example { display: grid; grid-template-columns: 82px 1fr auto 1fr auto 1fr; align-items: center; gap: 7px; }
.rules-math-example > img { width: 82px; border-radius: 7px; }
.rules-math-example > b { font-size: 1.4rem; }
.rules-factor { display: grid; place-items: center; min-height: 78px; border: 3px solid #e9891d; border-radius: 11px; padding: 6px; color: #754100; background: #fff2cd; }
.rules-factor:nth-of-type(2) { border-color: #1689d8; color: #07588f; background: #e7f5ff; }
.rules-factor.answer { border-color: #506e87; color: #314c63; background: #f1f5f8; }
.rules-factor small { font-size: .62rem; font-weight: 900; text-align: center; }
.rules-factor strong { font-size: 1.7rem; line-height: 1; }
.rules-factor span { font-size: .65rem; font-weight: 900; }
.rules-special-panel { grid-column: 1 / -1; }
.rules-special-panel > img { display: block; width: min(680px, 100%); margin: auto; border-radius: 9px; box-shadow: 0 7px 15px rgba(31,66,95,.18); }
.rules-special-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.rules-special-steps span { display: grid; place-items: center; min-height: 58px; border-radius: 11px; padding: 8px; background: #fff; text-align: center; font-size: .78rem; line-height: 1.45; }
.rules-special-steps b { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; color: #fff; background: #173b63; font-size: 1rem; }

.record-tabs { display: flex; gap: 7px; margin-bottom: 12px; }
.tab-button {
  flex: 1;
  min-height: 44px;
  border: 2px solid #cddde6;
  border-radius: 11px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}
.tab-button.active { border-color: #e79b21; background: #fff2c5; }
.record-view { display: none; }
.record-view.active { display: grid; }
.stats-grid { grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat-card { display: grid; gap: 4px; place-items: center; min-height: 94px; border-radius: 13px; padding: 10px; background: #edf7fc; text-align: center; }
.stat-card span { color: var(--muted); font-size: .75rem; font-weight: 800; }
.stat-card strong { color: #176ba1; font-size: 1.5rem; }
.stat-card .record-context {
  color: #5f7381;
  font-size: .6rem;
  font-weight: 800;
  line-height: 1.35;
}
.achievement-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.achievement-card {
  min-height: 125px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-content: center;
  gap: 7px;
  border-radius: 14px;
  padding: 11px;
  background: #eef3f6;
  filter: grayscale(1);
  opacity: .58;
}
.achievement-card.unlocked { background: linear-gradient(145deg, #fff4bd, #fff); filter: none; opacity: 1; box-shadow: inset 0 0 0 2px #efc557; }
.achievement-icon { grid-row: 1 / 3; font-size: 2rem; align-self: center; }
.achievement-card strong { font-size: .86rem; }
.achievement-card span { color: var(--muted); font-size: .7rem; line-height: 1.45; }

/* Modals */
.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 27, 48, .72);
  backdrop-filter: blur(5px);
}
.modal-global-actions {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 7px;
}
.modal-global-actions .button {
  min-height: 38px;
  padding: 7px 11px;
  font-size: .78rem;
  white-space: nowrap;
}
.modal {
  width: min(760px, 94vw);
  max-height: 92dvh;
  overflow: auto;
  border: 5px solid #fff;
  border-radius: 24px;
  padding: 23px;
  background: #fffdf6;
  box-shadow: 0 28px 60px rgba(0,0,0,.34);
  text-align: center;
  animation: popIn .25s ease-out;
}
.modal-kicker { margin: 0; color: var(--muted); font-weight: 900; }
.hand-overview-modal {
  width: min(1120px, 96vw);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}
.hand-overview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-right: 175px;
  text-align: left;
}
.hand-overview-heading p,
.hand-overview-guide { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 800; }
.hand-overview-heading h2 { margin: 2px 0 0; font-size: 1.55rem; }
.hand-overview-guide { text-align: left; }
.hand-overview-cards {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 4px;
}
.hand-overview-card {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
  border: 3px solid #b6ccd9;
  border-radius: 12px;
  padding: 5px;
  background: #fff;
  cursor: pointer;
}
.hand-overview-card.color-red { border-color: #d93d35; }
.hand-overview-card.color-blue { border-color: #087ebc; }
.hand-overview-card.color-green { border-color: #218b45; }
.hand-overview-card.color-purple { border-color: #7b43ad; }
.hand-overview-card.color-ticket { border-color: #e8ac18; }
.hand-overview-card img {
  display: block;
  width: 100%;
  height: min(43dvh, 245px);
  object-fit: contain;
  border-radius: 8px;
}
.hand-overview-card > span {
  border-radius: 7px;
  padding: 5px;
  color: #fff;
  background: #176ba1;
  font-size: .76rem;
  font-weight: 900;
}
.hand-overview-card.color-red > span { background: #d93d35; }
.hand-overview-card.color-green > span { background: #218b45; }
.hand-overview-card.color-purple > span { background: #7b43ad; }
.hand-overview-card.color-ticket > span { color: #553700; background: #f2bd31; }
.roulette-modal { width: min(620px, 92vw); overflow: hidden; }
.roulette-modal h2 { margin: 7px 0 12px; color: var(--navy); }
.roulette-name {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 8px solid #d7e6ef;
  border-radius: 50%;
  width: 150px;
  margin: 0 auto 12px;
  color: var(--navy);
  background: radial-gradient(circle, #fff 42%, #e9f7ff 43% 58%, #f5b82e 59% 66%, #fff 67%);
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.15;
  box-shadow: 0 10px 24px rgba(24,66,95,.22);
  transition: color .08s, transform .08s;
}
.roulette-name.winner { animation: rouletteWinner .6s ease-out; }
.roulette-order { min-height: 46px; margin: 0 0 13px; font-weight: 900; line-height: 1.5; }
.roulette-opening-hand {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 auto 13px;
  border-radius: 14px;
  padding: 8px 12px;
  color: #173b63;
  background: #eaf6fc;
  font-weight: 900;
}
.roulette-opening-hand > span { font-size: .8rem; }
.roulette-opening-hand > div { display: flex; align-items: center; justify-content: center; gap: 8px; }
.roulette-opening-hand img { width: 54px; height: 76px; border-radius: 7px; object-fit: contain; background: #fff; }
.turn-modal h2 { margin: 8px 0; font-size: clamp(2rem, 6vw, 3.7rem); color: var(--navy); }
.turn-modal p { font-weight: 800; }
.calculation-modal { width: min(1000px, 96vw); }
.calculation-owner {
  display: inline-block;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 6px 15px;
  font-weight: 900;
}
.calculation-owner.owner-self,
.effect-owner-badge.owner-self { color: #fff; background: #187a42; }
.calculation-owner.owner-other,
.effect-owner-badge.owner-other { color: #fff; background: #1769a6; }
.calculation-body { display: grid; grid-template-columns: minmax(170px, 230px) 1fr; gap: 22px; align-items: center; }
.focus-card-wrap { position: relative; min-width: 0; padding-top: 31px; }
.focus-card-wrap img { display: block; width: 100%; max-height: 58dvh; object-fit: contain; border-radius: 10px; box-shadow: 0 10px 24px rgba(27,55,72,.2); }
.card-count-badge {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 5px 16px;
  background: #176fb2;
  color: #fff;
  font-size: .88rem;
  font-weight: 900;
  white-space: nowrap;
}
.effect-kind-banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 14px;
  color: #fff;
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .02em;
}
.effect-kind-banner.red { background: #d93d35; }
.effect-kind-banner.blue { background: #087ebc; }
.effect-kind-banner.green { background: #218b45; }
.effect-kind-banner.purple { background: #7b43ad; }
.effect-kind-banner.ticket { color: #553700; background: #f2bd31; }
.calculation-modal > .effect-kind-banner { margin: 0 0 10px 8px; }
.calculation-work h2 { margin: 0 0 8px; color: var(--navy); }
.modifier-badges { min-height: 30px; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.modifier-badge { border-radius: 999px; padding: 6px 10px; color: #fff; background: #6c52ac; font-size: .76rem; font-weight: 900; }
.modifier-badge.special { background: linear-gradient(90deg, #f07e31, #e04d72); }
.calculation-prompt { min-height: 24px; margin: 2px 0 8px; color: #4c6475; font-size: .82rem; font-weight: 800; }
.factor-guide {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}
.factor-guide-card {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 100px;
  border: 4px solid;
  border-radius: 15px;
  padding: 9px;
  text-align: center;
}
.factor-guide-card > span { font-size: .75rem; font-weight: 900; }
.factor-guide-card.unit-factor { border-color: #e9891d; color: #5e3700; background: #fff1c8; }
.factor-guide-card.count-factor { border-color: #1689d8; color: #084f80; background: #e3f3ff; }
.factor-guide-card.count-factor > strong,
.factor-trace.simple strong { font-size: 2.25rem; line-height: 1; }
.factor-guide-card strong small { margin-left: 3px; font-size: .72rem; }
.factor-guide-times { display: grid; place-items: center; color: #263d50; font-size: 2.1rem; }
.factor-trace { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.factor-base { display: grid; place-items: center; min-width: 32px; height: 32px; border-radius: 8px; color: #fff; background: #9b6419; font-size: 1.35rem; font-weight: 900; }
.factor-change { border-radius: 8px; padding: 5px 7px; color: #fff; font-size: .68rem; font-weight: 900; }
.factor-change.silver { background: #6e7690; }
.factor-change.special { background: #d95455; }
.factor-equals { color: #7a6545; font-size: 1.35rem; font-weight: 900; }
.factor-trace > strong { color: #a94e00; font-size: 1.85rem; line-height: 1; }
.calculation-form { display: grid; gap: 13px; }
.equation-inputs {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1.25fr;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}
.equation-inputs.answer-only {
  display: flex;
  justify-content: center;
}
.answer-entry {
  display: grid;
  grid-template-columns: auto minmax(120px, 190px) auto;
  align-items: center;
  gap: 10px;
  color: #314c63;
  font-size: 1.15rem;
  font-weight: 900;
}
.equation-inputs .answer-entry input {
  height: 64px;
  border: 4px solid #5a7690;
  border-radius: 13px;
  background: #fff;
  color: var(--navy);
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
}
.equation-inputs > b { color: #263d50; font-size: 2rem; }
.equation-field {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 66px;
  align-items: center;
  border: 3px solid;
  border-radius: 13px;
  padding: 6px;
}
.equation-field > span { grid-column: 1 / -1; font-size: .7rem; }
.equation-field > small { padding: 0 4px; font-size: .68rem; }
.equation-field.unit-field { border-color: #e9891d; color: #744000; background: #fff5dc; }
.equation-field.count-field { border-color: #1689d8; color: #07588f; background: #edf8ff; }
.equation-field.answer-field { border-color: #5a7690; color: #314c63; background: #f1f5f8; }
.equation-inputs input,
.equation-inputs .given {
  min-width: 0;
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 9px;
  background: #fff;
  color: var(--navy);
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
}
.equation-inputs .given { display: grid; place-items: center; }
.equation-inputs input:focus { outline: 4px solid rgba(255,190,40,.5); }
.answer-button { font-size: 1.1rem; }
.attempt-message { min-height: 26px; margin: 0; font-weight: 900; color: #c66222; }
.attempt-message.correct { color: var(--green); font-size: 1.2rem; }
.attempt-message.wrong { animation: shake .3s; color: var(--red); }

.card-preview-modal { width: min(800px, 94vw); }
.card-preview-body {
  display: grid;
  grid-template-columns: minmax(220px, 330px) 1fr;
  gap: 24px;
  align-items: center;
}
.card-preview-image-wrap { position: relative; min-width: 0; padding-top: 32px; }
.card-preview-image-wrap img {
  display: block;
  width: 100%;
  max-height: 68dvh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 12px 27px rgba(27,55,72,.22);
}
.preview-stock-badge {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 5px 15px;
  color: #fff;
  background: #163f68;
  font-weight: 900;
  white-space: nowrap;
}
.card-preview-details { display: grid; gap: 14px; }
.preview-owned-count {
  margin: 0;
  border-radius: 12px;
  padding: 11px;
  color: #164f7a;
  background: #e8f5ff;
  font-weight: 900;
}
.preview-card-status {
  min-height: 64px;
  display: grid;
  place-items: center;
  margin: 0;
  border-radius: 12px;
  padding: 11px;
  color: #5d4400;
  background: #fff2b7;
  font-size: 1.04rem;
  font-weight: 900;
  line-height: 1.55;
  white-space: pre-line;
}
.preview-card-status.unavailable { color: #71363a; background: #f9e5e5; }
.card-preview-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }
.card-preview-actions .button { width: 100%; }
.card-preview-modal.special-preview { width: min(1120px, 96vw); }
.special-preview .card-preview-body { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.special-preview .card-preview-image-wrap { padding-top: 34px; }
.special-preview .card-preview-image-wrap img { width: 100%; max-height: 65dvh; }
.special-preview .card-preview-details { grid-template-columns: 1fr 1.4fr auto; align-items: center; gap: 10px; }
.special-preview .preview-owned-count,
.special-preview .preview-card-status { min-height: 58px; margin: 0; }
.special-preview .card-preview-actions { grid-template-columns: 150px; }

.effect-resolution-modal { width: min(860px, 96vw); }
.effect-modal-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.effect-owner-badge, .effect-special-status {
  border-radius: 999px;
  padding: 6px 13px;
  font-size: .78rem;
  font-weight: 900;
}
.effect-special-status { color: #563900; background: #fff0a2; }
.effect-resolution-modal h2 { margin: 9px 0 13px; color: var(--navy); font-size: 1.7rem; }
.effect-resolution-body {
  display: grid;
  grid-template-columns: minmax(210px, 310px) 1fr;
  gap: 24px;
  align-items: center;
}
.effect-card-wrap { position: relative; min-width: 0; padding-top: 31px; }
.effect-card-wrap img {
  display: block;
  width: 100%;
  max-height: 59dvh;
  border-radius: 11px;
  object-fit: contain;
  box-shadow: 0 11px 25px rgba(27,55,72,.22);
}
.effect-card-count {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 5px 16px;
  color: #fff;
  background: #176fb2;
  font-size: 1rem;
  font-weight: 900;
  white-space: nowrap;
}
.effect-result-panel { display: grid; gap: 11px; }
.effect-formula {
  margin: 0;
  border-radius: 13px;
  padding: 11px;
  color: #163f68;
  background: #e8f5ff;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  font-weight: 900;
  letter-spacing: .04em;
}
.effect-modifiers { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 4px; }
.effect-modifiers span { border-radius: 999px; padding: 5px 9px; color: #fff; background: #8d55c7; font-size: .72rem; font-weight: 900; }
.effect-coin-result {
  border-radius: 15px;
  padding: 13px;
  color: #5b3900;
  background: linear-gradient(135deg, #ffe263, #ffb830);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 900;
  animation: resultPop .45s ease-out;
}
.effect-detail { min-height: 50px; margin: 0; color: #4e6475; font-weight: 800; line-height: 1.55; white-space: pre-line; }

.event-modal { position: relative; overflow: hidden; background: linear-gradient(145deg, #24184a, #624397 58%, #d35b7a); color: #fff; }
.event-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 18% 25%, #fff 0 2px, transparent 3px), radial-gradient(circle at 80% 20%, #ffe65b 0 2px, transparent 3px);
  background-size: 70px 70px, 95px 95px;
  animation: sparkleBg 1.8s linear infinite;
}
.event-modal > * { position: relative; z-index: 1; }
.event-icon { padding-block: 8px; font-size: 5rem; line-height: 1.2; animation: bounce 1s ease-in-out infinite; }
.event-icon.dice-event {
  min-height: 122px;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: visible;
  font-size: 0;
  line-height: 1;
}
.event-modal h2 { margin: 5px 0; font-size: clamp(2rem, 6vw, 4rem); text-shadow: 0 4px 0 rgba(0,0,0,.22); }
.event-modal p { font-size: 1.1rem; font-weight: 800; line-height: 1.7; white-space: pre-line; }
.confirm-actions { display: flex; justify-content: center; gap: 10px; }

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 28px;
  max-width: min(620px, 88vw);
  transform: translate(-50%, 30px);
  border-radius: 999px;
  padding: 11px 20px;
  background: rgba(18,54,94,.94);
  color: #fff;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Results */
.results-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: linear-gradient(#16264f, #523875 60%, #e86879);
}
.results-sky, .results-sky::before, .results-sky::after {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 80% 12%, #ffdb4d 0 2px, transparent 3px);
  background-size: 85px 85px, 110px 110px;
  animation: sparkleBg 2.2s linear infinite;
}
.results-card {
  position: relative;
  z-index: 2;
  width: min(800px, 94vw);
  border: 5px solid #fff;
  border-radius: 26px;
  padding: 24px;
  background: rgba(255,253,247,.97);
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,.32);
}
.results-card h2 { margin: 0 0 14px; color: var(--navy); font-size: 2.3rem; }
.ranking-list { display: grid; gap: 9px; }
.ranking-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 10px;
  border-left: 9px solid var(--player-color);
  border-radius: 13px;
  padding: 10px 16px;
  background: #edf5fa;
  opacity: 0;
  transform: translateY(12px);
}
.ranking-row.reveal { animation: rankReveal .45s forwards; }
.ranking-row.winner { background: linear-gradient(90deg, #fff1a5, #fff); box-shadow: inset 0 0 0 3px #eebb37; }
.rank-number { font-size: 1.55rem; font-weight: 900; color: var(--navy); }
.rank-name { text-align: left; font-size: 1.1rem; font-weight: 900; }
.rank-coins { font-size: 1.2rem; font-weight: 900; color: #785200; }
.unlocked-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 11px; }
.unlock-pill { border-radius: 999px; padding: 6px 10px; background: #fff1b2; color: #754f00; font-size: .75rem; font-weight: 900; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }

/* States and animation */
body.special-day .game-screen { background: linear-gradient(#1b2754, #43316c 48%, #74426c); }
body.special-day .market-section { border-color: #ad7dcc; background: rgba(255,250,239,.95); }
body.special-day .turn-panel { box-shadow: 0 0 30px rgba(255,202,68,.28); }

@keyframes diceRoll { to { transform: rotate(360deg) scale(1.05); } }
@keyframes popIn { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
@keyframes sparkle { 0%,100% { opacity: .25; transform: scale(.5) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(35deg); } }
@keyframes sparkleBg { to { background-position: 85px 85px, -110px 110px; } }
@keyframes float { 50% { transform: translateY(-12px) rotate(12deg); } }
@keyframes bounce { 50% { transform: translateY(-10px) scale(1.07); } }
@keyframes rankReveal { to { opacity: 1; transform: translateY(0); } }
@keyframes effectPulse { to { box-shadow: 0 0 0 5px rgba(255,195,40,.85), 0 8px 18px rgba(28,66,95,.22); } }
@keyframes coinFloat {
  0% { opacity: 0; transform: translateY(12px) scale(.75); }
  25% { opacity: 1; transform: translateY(0) scale(1.08); }
  100% { opacity: 0; transform: translateY(-42px) scale(1); }
}
@keyframes resultPop { from { transform: scale(.82); opacity: .2; } to { transform: scale(1); opacity: 1; } }
@keyframes specialCardGlow { to { box-shadow: 0 0 0 3px rgba(255,225,108,.42), 0 5px 15px rgba(73,38,99,.35); } }
@keyframes currentCountPulse { to { transform: translateX(-50%) scale(1.12); } }
@keyframes rouletteWinner {
  0% { transform: scale(.72) rotate(-12deg); }
  65% { transform: scale(1.14) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 170px minmax(470px, 1fr) 205px; gap: 7px; padding: 7px; }
  .turn-panel { padding: 8px; }
  .market-section { padding: 6px; }
  .market-grid, .ticket-grid { gap: 5px; }
  .owned-chip { font-size: 0; padding-right: 4px; }
  .owned-chip b { font-size: .7rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 700px) and (orientation: landscape) {
  .game-header { min-height: 49px; padding-block: 4px; }
  .game-layout { padding: 6px; }
  .current-hand-panel { flex-basis: 132px; margin: 0 6px 6px; padding: 6px; }
  .current-hand-heading { padding: 7px; }
  .ticket-grid { height: 100px; }
  .turn-panel { gap: 5px; }
  .dice { width: 72px; font-size: 4.6rem; }
  .dice-stage p { min-height: 26px; margin: 0; }
  .player-panel { padding: 6px; }
  .owned-chip { min-height: 21px; }
  .calculation-body { grid-template-columns: 200px 1fr; }
  .focus-card-wrap img { max-height: 65dvh; }
  .effect-resolution-modal { padding: 14px; }
  .effect-resolution-body { grid-template-columns: 190px 1fr; gap: 16px; }
  .effect-card-wrap img { max-height: 62dvh; }
  .special-day-board-card { min-height: 66px; grid-template-columns: minmax(170px, 205px) auto; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .hand-overview-heading { padding-right: 0; margin-top: 42px; }
  .hand-overview-cards { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }
  .title-screen { padding: 12px; }
  .title-card { padding: 17px; }
  .title-festival { grid-template-columns: 74px minmax(150px, 1fr) 78px; gap: 2px; min-height: 100px; padding-inline: 0; }
  .title-card-fan img { width: 58px; max-height: 90px; }
  .title-coin-stack { transform: scale(.68); transform-origin: center; }
  .title-attraction-icons { min-height: 88px; font-size: 3rem; }
  .title-wheel { right: 10px; }
  .title-tent { font-size: 2rem; }
  .title-coins { font-size: 1.15rem; }
  .setup-grid { grid-template-columns: 1fr; }
  .player-setup { grid-template-columns: repeat(2, 1fr); }
  .game-screen { min-width: 980px; }
  .info-screen { padding: 10px; }
  .rules-columns { grid-template-columns: 1fr; }
  .rules-visual { grid-template-columns: 1fr; }
  .rules-card-reading { grid-row: auto; }
  .rules-special-panel { grid-column: auto; }
  .rules-flow { flex-wrap: wrap; justify-content: center; }
  .rules-special-steps { grid-template-columns: 1fr; }
  .rules-math-example { grid-template-columns: 70px 1fr auto 1fr; }
  .rules-math-example > img { width: 70px; }
  .rules-math-example > .answer { grid-column: 2 / -1; }
  .card-reading-layout { grid-template-columns: 1fr minmax(145px, 200px) 1fr; }
  .achievement-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .calculation-body { grid-template-columns: 1fr; }
  .focus-card-wrap { width: 180px; margin: auto; }
  .card-preview-body { grid-template-columns: 1fr; }
  .card-preview-image-wrap { width: 210px; margin: auto; }
  .effect-resolution-body { grid-template-columns: 1fr; }
  .effect-card-wrap { width: 190px; margin: auto; }
  .current-hand-panel { grid-template-columns: 145px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
