@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;600;700;900&display=swap');

:root {
  --ink: #17110e;
  --paper: #e8dfcc;
  --paper-dark: #cabc9f;
  --red: #a21d19;
  --red-light: #c9342e;
  --gold: #d4ad57;
  --muted: #8f8170;
  --panel: rgba(35, 25, 20, .88);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% 34%, rgba(127, 27, 23, .22), transparent 28rem),
    linear-gradient(rgba(12, 9, 7, .25), rgba(12, 9, 7, .6)),
    repeating-linear-gradient(94deg, #1b1410 0, #1b1410 4px, #211814 5px, #17110e 9px);
  font-family: "Noto Serif JP", YuMincho, serif;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.grain {
  position: fixed;
  inset: 0;
  opacity: .15;
  pointer-events: none;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar {
  height: 82px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(220, 193, 137, .22);
  background: rgba(12, 9, 7, .7);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark, .section-title > span {
  display: grid; place-items: center; width: 45px; aspect-ratio: 1;
  color: var(--paper); background: var(--red); border: 1px solid #d15a50;
  box-shadow: inset 0 0 0 3px #86140f;
  font-size: 22px; font-weight: 900;
}
.brand b { display: block; font-size: 18px; letter-spacing: .2em; }
.brand small { display: block; color: var(--muted); font-size: 10px; letter-spacing: .16em; margin-top: 2px; }
.header-actions { display: flex; gap: 12px; }
.icon-button, .rules-button, .language-button {
  border: 1px solid rgba(220, 193, 137, .3); color: var(--paper); background: transparent; cursor: pointer;
}
.language-button { width: 43px; height: 43px; color: var(--gold); font: 700 10px sans-serif; letter-spacing: .08em; }
.icon-button { width: 43px; height: 43px; font-size: 17px; }
.rules-button { height: 43px; padding: 0 20px; letter-spacing: .12em; }
.rules-button span { margin-left: 16px; color: var(--gold); }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 70px; }
.hero { text-align: center; padding: 48px 0 34px; }
.eyebrow { color: var(--gold); font-size: 11px; letter-spacing: .3em; font-weight: 700; }
.hero .eyebrow { display: flex; justify-content: center; align-items: center; gap: 14px; }
.eyebrow span { width: 55px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.eyebrow span:last-child { transform: rotate(180deg); }
.hero h1 { margin: 5px 0 12px; font-size: clamp(42px, 6vw, 76px); line-height: 1.1; letter-spacing: .13em; font-weight: 900; text-shadow: 0 4px 18px #000; }
.hero > p:last-child { margin: 0; color: #a99b89; line-height: 1.8; font-size: 13px; letter-spacing: .1em; }

.game-shell { display: grid; grid-template-columns: 190px minmax(0, 760px) 190px; gap: 20px; align-items: start; justify-content: center; }
.score-card {
  border: 1px solid rgba(213, 180, 110, .24); background: linear-gradient(145deg, rgba(48, 35, 28, .75), rgba(20, 15, 12, .8));
  padding: 19px; margin-top: 38px; position: relative;
}
.score-card::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(213, 180, 110, .08); pointer-events: none; }
.score-heading { display: flex; align-items: center; gap: 11px; }
.avatar { display: grid; place-items: center; width: 43px; aspect-ratio: 1; border-radius: 50%; background: #e4d7bd; color: #2b1d16; font-weight: 900; border: 3px double #5c4335; }
.avatar.boss { background: #601a16; color: #eadcc2; border-color: #b56858; }
.score-heading small { color: var(--muted); letter-spacing: .22em; font-size: 8px; }
.score-heading strong { display: block; font-size: 15px; letter-spacing: .13em; }
.coin-row { display: flex; align-items: center; gap: 8px; margin-top: 23px; }
.coin { display: inline-grid; place-items: center; width: 23px; aspect-ratio: 1; border-radius: 50%; color: #432b15; background: var(--gold); border: 2px dotted #745c29; font-size: 10px; font-weight: 900; }
.coin-row b { font-size: 22px; letter-spacing: .08em; }
.meter { height: 3px; background: #362820; margin-top: 12px; }
.meter span { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #94702f, var(--gold)); transition: width .5s; }

.board {
  position: relative; min-height: 585px; padding: 26px 38px 33px;
  background:
    radial-gradient(circle at 50% 45%, rgba(126, 25, 18, .42), transparent 37%),
    linear-gradient(140deg, rgba(70, 23, 19, .9), rgba(37, 16, 13, .96));
  border: 1px solid #815a38;
  box-shadow: 0 25px 55px rgba(0,0,0,.45), inset 0 0 70px rgba(0,0,0,.55);
}
.board::before, .board::after { content: ""; position: absolute; pointer-events: none; }
.board::before { inset: 8px; border: 1px solid rgba(231, 196, 125, .2); }
.board::after {
  inset: 0; opacity: .07;
  background: repeating-linear-gradient(45deg, transparent 0 12px, #e9d6ae 13px, transparent 14px);
}
.round-status { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; font-size: 11px; letter-spacing: .15em; color: #b7a894; }
.round-status b { color: var(--paper); font-size: 14px; }
.round-status span:last-child { color: var(--gold); }
.opponent-zone { position: relative; z-index: 1; text-align: center; padding-top: 20px; }
.opponent-zone p { color: #bda98f; font-size: 10px; letter-spacing: .18em; }
.red-dot { display: inline-block; width: 5px; height: 5px; background: #e44b3e; border-radius: 50%; margin-right: 5px; }
.dice-row { display: flex; justify-content: center; gap: 13px; }
.die {
  --dot: #281711;
  position: relative; width: 66px; aspect-ratio: 1; border-radius: 11px;
  background: linear-gradient(145deg, #fff8e7, #cfc3aa);
  border: 1px solid #8d7a60;
  box-shadow: inset -5px -7px 10px rgba(81,58,41,.24), inset 3px 3px 4px #fff, 0 8px 12px rgba(0,0,0,.35);
}
.small .die { width: 42px; border-radius: 8px; }
.die::before {
  content: ""; position: absolute; inset: 10%; border-radius: 50%;
  background: transparent;
}
.die[data-value="1"]::before { background: #b5201c; inset: 35%; box-shadow: inset 1px 2px 2px #5f100e; }
.die[data-value="2"]::before { background: var(--dot); inset: 18% 62% 62% 18%; box-shadow: 29px 29px 0 var(--dot); }
.die[data-value="3"]::before { background: var(--dot); inset: 14% 66% 66% 14%; box-shadow: 16px 16px 0 var(--dot), 32px 32px 0 var(--dot); }
.die[data-value="4"]::before { background: var(--dot); inset: 17% 63% 63% 17%; box-shadow: 29px 0 0 var(--dot), 0 29px 0 var(--dot), 29px 29px 0 var(--dot); }
.die[data-value="5"]::before { background: var(--dot); inset: 14% 66% 66% 14%; box-shadow: 32px 0 0 var(--dot), 16px 16px 0 var(--dot), 0 32px 0 var(--dot), 32px 32px 0 var(--dot); }
.die[data-value="6"]::before { background: var(--dot); inset: 12% 68% 68% 12%; box-shadow: 32px 0 0 var(--dot), 0 16px 0 var(--dot), 32px 16px 0 var(--dot), 0 32px 0 var(--dot), 32px 32px 0 var(--dot); }
.small .die[data-value="2"]::before { box-shadow: 18px 18px 0 var(--dot); }
.small .die[data-value="3"]::before { box-shadow: 10px 10px 0 var(--dot), 20px 20px 0 var(--dot); }
.small .die[data-value="4"]::before { box-shadow: 18px 0 0 var(--dot), 0 18px 0 var(--dot), 18px 18px 0 var(--dot); }
.small .die[data-value="5"]::before { box-shadow: 20px 0 0 var(--dot), 10px 10px 0 var(--dot), 0 20px 0 var(--dot), 20px 20px 0 var(--dot); }
.small .die[data-value="6"]::before { box-shadow: 20px 0 0 var(--dot), 0 10px 0 var(--dot), 20px 10px 0 var(--dot), 0 20px 0 var(--dot), 20px 20px 0 var(--dot); }
.die.placeholder { opacity: .14; background: #d5c7aa; box-shadow: none; }
.hand-result { display: block; min-height: 20px; margin-top: 10px; color: var(--gold); font-size: 12px; letter-spacing: .15em; }
.versus { display: flex; align-items: center; gap: 15px; margin: 8px auto 4px; width: 70%; position: relative; z-index: 1; }
.versus span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #947f62); }
.versus span:last-child { transform: rotate(180deg); }
.versus b { font-size: 12px; color: #bda687; letter-spacing: .25em; }
.player-zone { position: relative; z-index: 1; text-align: center; }
.main-result { margin: 2px 0 1px; font-size: 21px; color: var(--paper); text-shadow: 0 2px 8px #000; }
.dice-stage { height: 175px; position: relative; display: grid; place-items: center; }
.bowl { position: absolute; width: 310px; height: 138px; border-radius: 50%; background: radial-gradient(ellipse at center, #2c1712 10%, #481b15 50%, #180d0b 72%); border: 9px solid #5b251c; box-shadow: 0 14px 20px rgba(0,0,0,.5), inset 0 0 30px #000, 0 0 0 2px #a05a40; }
.bowl::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 1px solid rgba(235,170,110,.18); }
.main-dice { position: relative; z-index: 2; transform: rotate(-4deg); gap: 17px; }
.main-dice .die:nth-child(2) { transform: translateY(10px) rotate(13deg); }
.main-dice .die:nth-child(3) { transform: rotate(7deg); }
.rolling .die { animation: tumble .17s linear infinite alternate; }
@keyframes tumble { to { transform: translate(4px, -7px) rotate(14deg) scale(.95); } }
.attempts { margin: -4px 0 15px; color: #b09d86; font-size: 10px; letter-spacing: .18em; }
.bet-panel { position: relative; z-index: 1; height: 72px; display: flex; align-items: center; gap: 10px; padding: 10px; background: rgba(15, 10, 8, .65); border: 1px solid rgba(216,181,112,.28); }
.bet-copy { width: 75px; padding-left: 8px; }
.bet-copy small { display: block; color: var(--red-light); letter-spacing: .2em; font-size: 8px; }
.bet-copy b { font-size: 12px; letter-spacing: .15em; }
.bet-adjust { width: 36px; height: 36px; color: var(--paper); background: #39251c; border: 1px solid #6e4b36; cursor: pointer; }
.bet-adjust:disabled { opacity: .35; cursor: not-allowed; }
.bet-value { min-width: 92px; text-align: center; }
.bet-value b { font-size: 20px; margin-left: 7px; }
.small-coin { width: 20px; font-size: 8px; vertical-align: 2px; }
.roll-button { margin-left: auto; min-width: 195px; align-self: stretch; border: 1px solid #df6f60; background: linear-gradient(#b42a22, #7b1713); color: white; box-shadow: inset 0 0 0 3px #8f1c17; cursor: pointer; }
.roll-button:hover { filter: brightness(1.12); }
.roll-button:active { transform: translateY(1px); }
.roll-button:disabled { filter: grayscale(.6); cursor: wait; }
.roll-button span { display: block; font-size: 17px; font-weight: 900; letter-spacing: .18em; }
.roll-button small { display: block; font-size: 7px; letter-spacing: .22em; opacity: .65; margin-top: 2px; }

.ad-section {
  width: 100%;
  min-height: 120px;
  margin: 38px auto 0;
  padding: 22px 12px 12px;
  position: relative;
  overflow: hidden;
  background: rgba(18, 13, 10, .46);
  border-top: 1px solid rgba(213, 180, 110, .14);
  border-bottom: 1px solid rgba(213, 180, 110, .14);
}
.ad-label {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  color: #72675b;
  font-family: sans-serif;
  font-size: 7px;
  letter-spacing: .22em;
}
.adsbygoogle { min-height: 90px; }
.bottom-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 55px; margin-top: 42px; }
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.section-title > span { width: 34px; font-size: 15px; }
.section-title small { display: block; color: var(--red-light); font-size: 8px; letter-spacing: .25em; }
.section-title b { letter-spacing: .17em; font-size: 14px; }
.role-list { display: grid; grid-template-columns: repeat(4,1fr); border: 1px solid rgba(213,180,110,.18); }
.role-list article { text-align: center; padding: 17px 8px; border-right: 1px solid rgba(213,180,110,.14); background: rgba(30,22,18,.55); }
.role-list article:last-child { border: 0; }
.mini-dice { display: flex; justify-content: center; gap: 4px; }
.mini-dice i { display: grid; place-items: center; width: 25px; height: 25px; background: #d9cdb5; color: #4a3328; font-size: 9px; font-style: normal; border-radius: 4px; }
.role-list b { display: block; font-size: 11px; margin-top: 9px; letter-spacing: .1em; }
.role-list span { font-size: 9px; color: var(--gold); }
.role-list .lose { color: #d65c53; }
.history-panel ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(213,180,110,.2); max-height: 154px; overflow: auto; }
.history-panel li { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; padding: 10px 3px; border-bottom: 1px solid rgba(213,180,110,.12); color: #aa9b88; font-size: 10px; }
.history-panel li b { color: var(--paper); }
.history-panel li .win { color: var(--gold); }
.history-panel li .lose { color: #da5a50; }
.history-panel li.empty-history { display: block; padding: 24px 3px; }

dialog { width: min(580px, calc(100% - 32px)); color: var(--paper); background: #211713; border: 1px solid #8c6341; padding: 38px; box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(8,5,4,.8); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; color: #aa9983; font-size: 25px; cursor: pointer; }
dialog h2 { margin: 5px 0 12px; font-size: 25px; }
dialog > p:not(.eyebrow) { color: #b9a994; line-height: 1.9; font-size: 12px; }
.rules-table { margin: 22px 0; border-top: 1px solid #4a3529; }
.rules-table div { display: grid; grid-template-columns: 1fr 1fr 1.4fr; padding: 10px 4px; border-bottom: 1px solid #4a3529; font-size: 11px; }
.rules-table span { color: #aa9983; }
.rules-table em { color: var(--gold); font-style: normal; text-align: right; }
.dialog-action { width: 100%; padding: 13px; color: white; border: 1px solid #d25b50; background: #8e1d18; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 30; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #e4d6ba; color: #2d1d15; padding: 11px 22px; font-size: 12px; box-shadow: 0 8px 25px #000; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .game-shell { grid-template-columns: 1fr 1fr; }
  .board { grid-row: 1; grid-column: 1 / -1; }
  .score-card { margin: 0; }
  .bottom-grid { grid-template-columns: 1fr; gap: 35px; }
}
@media (max-width: 640px) {
  .topbar { height: 67px; padding: 0 15px; }
  .brand small, .icon-button { display: none; }
  .brand-mark { width: 38px; }
  .brand b { font-size: 14px; }
  .rules-button { padding: 0 12px; font-size: 11px; }
  main { width: min(100% - 20px, 600px); }
  .hero { padding: 34px 0 25px; }
  .hero h1 { font-size: 39px; letter-spacing: .06em; }
  .hero > p:last-child { font-size: 11px; }
  .board { min-height: 555px; padding: 22px 14px 20px; }
  .round-status span:first-child { display: none; }
  .die { width: 57px; }
  .bowl { width: 280px; }
  .bet-panel { height: auto; flex-wrap: wrap; }
  .bet-copy { width: 60px; }
  .roll-button { width: 100%; min-width: 0; height: 54px; margin: 3px 0 0; }
  .game-shell { gap: 10px; }
  .score-card { padding: 13px; }
  .score-heading { gap: 7px; }
  .score-heading strong { font-size: 12px; }
  .avatar { width: 35px; }
  .coin-row { margin-top: 14px; }
  .coin-row b { font-size: 17px; }
  .role-list { grid-template-columns: 1fr 1fr; }
  .role-list article:nth-child(2) { border-right: 0; }
  .role-list article:nth-child(-n+2) { border-bottom: 1px solid rgba(213,180,110,.14); }
  .bottom-grid { margin-top: 35px; }
  .ad-section { min-height: 112px; margin-top: 28px; padding-inline: 0; }
  dialog { padding: 30px 20px; }
}

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