:root {
  --ink: #425064;
  --muted: #718095;
  --mint: #bdebdc;
  --mint-deep: #50a987;
  --pink: #ffd1df;
  --lavender: #dcd3ff;
  --cream: #fff8de;
  --board: #4fad7d;
  --board-dark: #267358;
  --white: #fffdf8;
  --shadow: 0 18px 44px rgba(77, 89, 118, .18);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eaf8f1; }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: linear-gradient(145deg, #dff7ed 0%, #fff7e1 52%, #f4eaff 100%);
  font-family: "M PLUS Rounded 1c", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button, a { touch-action: manipulation; }
button { color: inherit; }

.app { position: relative; min-height: 100vh; min-height: 100svh; isolation: isolate; }
.background { position: fixed; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; }
.bubble { position: absolute; border-radius: 50%; opacity: .65; filter: blur(1px); }
.bubble-a { top: -80px; left: -70px; width: 250px; height: 250px; background: #c8ecff; }
.bubble-b { top: 30%; right: -130px; width: 330px; height: 330px; background: #f8d4e4; }
.bubble-c { bottom: -130px; left: 8%; width: 300px; height: 300px; background: #dad3ff; }
.flower { position: absolute; color: rgba(255, 255, 255, .86); font-size: 66px; }
.flower-a { top: 18%; left: 6%; transform: rotate(-15deg); }
.flower-b { right: 7%; bottom: 12%; transform: rotate(20deg); }

.screen { display: none; width: min(100%, 720px); min-height: 100vh; min-height: 100svh; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
.screen.active { display: block; }
.title-screen.active { display: flex; flex-direction: column; }
.title-header, .game-header { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; }
.home-link, .back-button {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid rgba(85, 120, 117, .2); border-radius: 999px;
  color: #4b6c68; background: rgba(255,255,255,.72); text-decoration: none; font-size: 11px; font-weight: 900; box-shadow: 0 4px 10px rgba(72, 102, 103, .08);
}
.back-button { cursor: pointer; }
.coin-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; margin-left: auto; padding: 4px 10px; border: 1px solid rgba(217, 168, 36, .28); border-radius: 999px; background: rgba(255,255,255,.8); font-size: 13px; }
.coin-pill img { display: block; width: 20px; height: 20px; object-fit: contain; }
.sound-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(99, 99, 135, .18); border-radius: 50%; background: rgba(255,255,255,.8); font-size: 18px; line-height: 1; cursor: pointer; }
.sound-button[aria-pressed="true"] { background: rgba(255,255,255,.5); }

.title-card {
  width: min(100%, 460px); margin: auto; padding: 27px 26px 22px; border: 5px solid rgba(255,255,255,.78); border-radius: 36px;
  background: rgba(255,255,255,.72); box-shadow: var(--shadow), inset 0 0 0 1px rgba(106, 148, 141, .12); text-align: center; backdrop-filter: blur(12px);
}
.title-logo { display: block; width: min(100%, 360px); height: auto; margin: -8px auto 4px; object-fit: contain; filter: drop-shadow(0 7px 10px rgba(88, 64, 47, .16)); }
.title-character { display: block; width: min(100%, 230px); max-height: 180px; margin: -7px auto 4px; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(55, 68, 74, .16)); }
.title-character[hidden] { display: none; }
.title-copy { margin: 0 0 18px; color: #6c7788; font-size: 13px; font-weight: 700; line-height: 1.7; }

.difficulty-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 0 0 15px; padding: 0; border: 0; }
.difficulty-picker legend { width: 100%; margin-bottom: 7px; color: #647b7a; font-size: 11px; font-weight: 900; }
.difficulty-picker label { position: relative; cursor: pointer; }
.difficulty-picker input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-picker span { display: grid; place-items: center; min-height: 59px; padding: 6px 3px; border: 2px solid transparent; border-radius: 15px; background: #f4f6f6; transition: .18s ease; }
.difficulty-picker label:nth-of-type(1) span { background: #e5f8ef; }
.difficulty-picker label:nth-of-type(2) span { background: #fff1c9; }
.difficulty-picker label:nth-of-type(3) span { background: #f0e8ff; }
.difficulty-picker b { font-size: 12px; }
.difficulty-picker small { margin-top: 2px; color: #849096; font-size: 9px; }
.difficulty-picker small::after { content: " コイン"; }
.difficulty-picker input:checked + span { border-color: #ee91af; box-shadow: 0 4px 12px rgba(224, 119, 155, .22); transform: translateY(-2px); }
.difficulty-picker input:focus-visible + span { outline: 3px solid rgba(64, 124, 255, .3); outline-offset: 2px; }

.primary-button, .secondary-button, .danger-button { width: 100%; min-height: 52px; border: 0; border-radius: 18px; font-weight: 900; cursor: pointer; }
.primary-button { color: white; background: linear-gradient(135deg, #62bd99, #45a47f); box-shadow: 0 8px 0 #348866, 0 12px 22px rgba(51, 137, 105, .2); font-size: 17px; }
.primary-button:active { transform: translateY(5px); box-shadow: 0 3px 0 #348866; }
.primary-button.compact { min-height: 48px; font-size: 14px; }
.secondary-button { border: 2px solid #b6d7cc; color: #4d756d; background: #f2fbf7; }
.danger-button { margin-bottom: 9px; color: #92556b; background: #ffe3ec; }
.title-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.title-actions button { min-height: 43px; border: 1px solid rgba(100, 118, 137, .15); border-radius: 14px; background: #fff; font-size: 12px; font-weight: 900; cursor: pointer; }
.title-actions span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 7px; color: #fff; background: #b3a5e3; }
.record-line { margin: 15px 0 0; color: #859194; font-size: 10px; }
.record-line b { color: #59766e; font-size: 12px; }

.game-screen { padding-inline: 12px; }
.game-header { margin-bottom: 10px; }
.difficulty-badge { min-height: 32px; padding: 7px 11px; border-radius: 999px; color: #776da0; background: rgba(255,255,255,.65); font-size: 10px; font-weight: 900; }
.score-panel { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(116px, 1.2fr) minmax(100px, 1fr); align-items: center; gap: 8px; width: min(100%, 560px); margin: 0 auto 9px; }
.score-side { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 49px; padding: 6px 8px; border: 2px solid rgba(255,255,255,.8); border-radius: 17px; background: rgba(255,255,255,.68); box-shadow: 0 5px 15px rgba(72,94,105,.09); }
.score-side span { color: #748083; font-size: 10px; font-weight: 900; }
.score-side strong { font-size: 22px; }
.turn-message { min-height: 44px; display: grid; place-items: center; padding: 6px 8px; border-radius: 14px; color: #417965; background: rgba(210, 246, 232, .82); font-size: 12px; font-weight: 900; text-align: center; line-height: 1.35; }
.turn-message.cpu { color: #776697; background: rgba(235, 226, 255, .82); }

.mini-disc { display: inline-block; width: 27px; height: 27px; flex: 0 0 auto; border-radius: 50%; }
.mini-disc.black { border: 2px solid #313a43; background: radial-gradient(circle at 35% 28%, #69737b 0, #283239 42%, #11181e 100%); }
.mini-disc.white { border: 2px solid #d6dad8; background: radial-gradient(circle at 35% 28%, #fff 0, #f7f5ef 48%, #d8dcd9 100%); }

.board-wrap { position: relative; width: min(100%, 560px); margin: 0 auto; padding: 9px; border: 5px solid #f5cf90; border-radius: 23px; background: linear-gradient(145deg, #ffe4ab, #eab875); box-shadow: 0 14px 30px rgba(57, 89, 76, .2), inset 0 0 0 2px rgba(255,255,255,.45); }
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); overflow: hidden; aspect-ratio: 1; border: 3px solid var(--board-dark); border-radius: 13px; background: var(--board-dark); gap: 1px; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 0; border: 0; background: var(--board); cursor: default; }
.cell:nth-child(16n + 1), .cell:nth-child(16n + 3), .cell:nth-child(16n + 5), .cell:nth-child(16n + 7),
.cell:nth-child(16n + 10), .cell:nth-child(16n + 12), .cell:nth-child(16n + 14), .cell:nth-child(16n + 16) { background: #56b485; }
.cell.legal { cursor: pointer; }
.cell.legal::before { width: 22%; aspect-ratio: 1; border-radius: 50%; content: ""; background: rgba(244,255,220,.72); box-shadow: 0 0 0 5px rgba(255,255,255,.09); transition: transform .15s ease; }
.cell.legal:hover::before, .cell.legal:focus-visible::before { transform: scale(1.4); background: #fff5a9; }
.cell.hint { z-index: 2; animation: hint-cell .8s ease-in-out infinite alternate; }
.cell.hint::after { position: absolute; inset: 7%; border: 4px solid #fff077; border-radius: 12px; content: ""; box-shadow: 0 0 13px #fff; }
.cell.change-target { cursor: pointer; animation: change-cell .75s ease-in-out infinite alternate; }
.cell.change-target::after { position: absolute; inset: 8%; border: 3px dashed #fff4a8; border-radius: 50%; content: ""; }
.cell:focus-visible { z-index: 3; outline: 3px solid #fff; outline-offset: -4px; }

.disc { position: absolute; display: grid; place-items: center; width: 96%; height: 96%; transform-style: preserve-3d; }
.disc.black, .disc.white { border: 0; border-radius: 0; background: none; box-shadow: none; }
.disc.placed { animation: disc-in .26s ease-out; }
.disc.changed { animation: disc-change .42s ease; }
.disc img { display: block; width: 100%; height: 100%; border-radius: 0; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(20,53,43,.3)); }
.disc img[hidden] { display: none; }

.thinking { position: absolute; z-index: 5; inset: 9px; display: none; align-items: center; justify-content: center; gap: 6px; border-radius: 13px; color: white; background: rgba(41,75,68,.25); backdrop-filter: blur(1px); pointer-events: none; }
.thinking.active { display: flex; }
.thinking span { width: 8px; height: 8px; border-radius: 50%; background: white; animation: dots .75s ease-in-out infinite alternate; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
.thinking b { margin-left: 3px; font-size: 11px; text-shadow: 0 1px 4px rgba(0,0,0,.3); }

.item-panel { width: min(100%, 560px); margin: 10px auto 0; padding: 10px; border: 2px solid rgba(255,255,255,.75); border-radius: 20px; background: rgba(255,255,255,.62); box-shadow: 0 7px 20px rgba(74,90,111,.08); }
.item-heading { margin: 0 0 7px 3px; color: #657774; font-size: 11px; font-weight: 900; }
.item-heading small { margin-left: 4px; color: #9aa19f; font-size: 8px; }
.item-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.item-button { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 48px; padding: 5px; border: 1px solid #d8d8e5; border-radius: 13px; background: #fff; cursor: pointer; }
.item-button:disabled { opacity: .4; cursor: default; }
.item-button.active { border-color: #e796aa; background: #fff0f5; box-shadow: 0 0 0 3px rgba(238,141,169,.16); }
.item-symbol, .shop-symbol { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px; color: #fff; background: #b1a3df; font-size: 17px; font-style: normal; font-weight: 900; }
.item-button:nth-child(1) .item-symbol, .shop-item:nth-child(1) .shop-symbol { background: #f0ad6c; }
.item-button:nth-child(3) .item-symbol, .shop-item:nth-child(3) .shop-symbol { background: #65b994; }
.shop-item.start-item .shop-symbol { width: 38px; color: #62577e; background: #e5ddff; font-size: 10px; letter-spacing: -.15em; }
.item-button b { display: block; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.item-button small { display: block; color: #8b929a; font-size: 8px; }
.item-button em { color: #526d68; font-style: normal; }
.item-message { min-height: 16px; margin: 6px 3px -3px; color: #d16686; font-size: 10px; font-weight: 900; text-align: center; }

.overlay { position: fixed; z-index: 20; inset: 0; display: none; place-items: center; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom)); background: rgba(66,76,91,.42); backdrop-filter: blur(6px); }
.overlay.open { display: grid; }
.modal { position: relative; width: min(100%, 440px); max-height: calc(100vh - 36px); max-height: calc(100svh - 36px); overflow-y: auto; padding: 27px 23px 22px; border: 4px solid rgba(255,255,255,.8); border-radius: 30px; background: #fffdf8; box-shadow: 0 24px 65px rgba(50,61,75,.28); text-align: center; }
.modal-close { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; color: #7d8590; background: #eff2f2; font-size: 21px; font-weight: 900; cursor: pointer; }
.modal-kicker { margin: 0; color: #85a69e; font-size: 9px; font-weight: 900; letter-spacing: .2em; }
.modal h2 { margin: 2px 0 18px; color: #496c65; font-size: 24px; }
.shop-balance { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 10px 13px; border-radius: 15px; background: #fff4cf; font-size: 11px; }
.shop-balance strong { display: flex; align-items: center; gap: 4px; color: #8d6d25; font-size: 18px; }
.shop-balance img { width: 24px; height: 24px; object-fit: contain; }
.shop-list { display: grid; gap: 8px; }
.shop-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 9px; padding: 10px; border: 1px solid #e4e5e7; border-radius: 16px; background: #fff; text-align: left; }
.shop-item h3 { margin: 0; color: #4e6065; font-size: 13px; }
.shop-item p { margin: 2px 0; color: #7f898d; font-size: 9px; line-height: 1.45; }
.shop-item small { color: #9a929c; font-size: 9px; }
.shop-item > button { display: flex; align-items: center; justify-content: center; gap: 3px; min-width: 58px; min-height: 37px; padding: 5px 8px; border: 0; border-radius: 12px; color: #7b6324; background: #ffe7a1; font-size: 11px; font-weight: 900; cursor: pointer; }
.shop-item > button:disabled { opacity: .5; cursor: wait; }
.shop-item > button img { width: 17px; height: 17px; object-fit: contain; }
.shop-status { min-height: 21px; margin: 9px 0 3px; color: #5f9d79; font-size: 10px; font-weight: 900; }
.shop-status.error { color: #d1657d; }
.rules-list { margin: 0 0 14px; padding-left: 24px; color: #66757b; font-size: 12px; line-height: 1.65; text-align: left; }
.rules-list li + li { margin-top: 7px; }
.rules-note { margin-bottom: 16px; padding: 12px; border-radius: 15px; color: #6b687a; background: #f1edff; font-size: 11px; text-align: left; }
.rules-note p { margin: 3px 0 0; line-height: 1.55; }

.color-overlay { z-index: 30; }
.color-modal { overflow: hidden; padding-bottom: 25px; }
.color-modal h2 { margin-bottom: 13px; }
.color-choice-panel[hidden], .roulette-stage[hidden] { display: none; }
.color-choice-panel > p { margin: 0 0 12px; color: #6a777d; font-size: 12px; font-weight: 900; }
.color-choice-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-choice-buttons button { display: grid; place-items: center; min-height: 145px; padding: 8px; border: 2px solid transparent; border-radius: 20px; background: #f3f5f4; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.color-choice-buttons button:first-child { background: #eef1f3; }
.color-choice-buttons button:last-child { background: #fff7e3; }
.color-choice-buttons button:hover, .color-choice-buttons button:focus-visible { border-color: #ee9bb4; box-shadow: 0 7px 18px rgba(214,111,145,.18); transform: translateY(-3px); }
.color-choice-buttons img { display: block; width: 82px; height: 82px; object-fit: contain; filter: drop-shadow(0 4px 4px rgba(41,55,59,.2)); }
.color-choice-buttons b { font-size: 13px; }
.color-choice-buttons small { color: #899193; font-size: 9px; }
.color-choice-panel .text-button { margin-top: 11px; }
.choice-stock { display: block; margin-top: -3px; color: #9a929c; font-size: 9px; }
.roulette-stage { position: relative; display: grid; place-items: center; min-height: 220px; padding-top: 4px; }
.roulette-halo { position: absolute; top: 43%; left: 50%; width: 166px; height: 166px; border-radius: 50%; background: radial-gradient(circle, rgba(255,245,159,.8), rgba(205,239,229,.46) 52%, transparent 72%); transform: translate(-50%, -50%); animation: roulette-halo 1s ease-in-out infinite alternate; }
.roulette-stage img { position: relative; z-index: 1; display: block; width: 132px; height: 132px; object-fit: contain; filter: drop-shadow(0 9px 7px rgba(40,55,59,.24)); }
.roulette-stage.switching img { animation: roulette-switch .13s ease-in-out infinite alternate; }
.roulette-stage.settled img { animation: roulette-settle .55s cubic-bezier(.18,.8,.3,1.25); }
.roulette-stage p { position: relative; z-index: 1; min-height: 28px; margin: 13px 0 0; color: #6f668c; font-size: 15px; font-weight: 900; }
.roulette-stage.settled p { color: #477d69; font-size: 17px; }

.result-label { margin: 0; color: #92a09d; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.result-modal h2 { margin-bottom: 12px; color: #df7698; font-size: 28px; }
.final-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 5px 0 14px; }
.final-score > div { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 5px; border-radius: 15px; background: #f3f5f4; }
.final-score span { color: #899190; font-size: 10px; }
.final-score strong { font-size: 24px; }
.reward-box { display: grid; place-items: center; margin-bottom: 17px; padding: 12px; border-radius: 18px; background: #fff2c8; }
.reward-box > span { color: #88743b; font-size: 10px; font-weight: 900; }
.reward-box strong { display: flex; align-items: center; gap: 5px; color: #85661d; font-size: 28px; }
.reward-box img { width: 28px; height: 28px; object-fit: contain; }
.reward-box small { min-height: 14px; color: #a57479; font-size: 9px; }
.text-button { min-height: 38px; margin-top: 8px; border: 0; background: transparent; color: #79878a; font-size: 11px; font-weight: 900; text-decoration: underline; cursor: pointer; }
.confirm-modal p { margin: -7px 0 18px; color: #7f878c; font-size: 11px; }

@keyframes disc-in { from { opacity: .25; transform: scale(.4) rotateY(90deg); } to { opacity: 1; transform: scale(1) rotateY(0); } }
@keyframes disc-change { 0% { transform: rotateY(0); } 50% { transform: rotateY(90deg) scale(1.12); } 100% { transform: rotateY(0); } }
@keyframes hint-cell { to { filter: brightness(1.13); } }
@keyframes change-cell { to { filter: brightness(1.17) saturate(1.12); } }
@keyframes dots { to { transform: translateY(-6px); opacity: .55; } }
@keyframes roulette-halo { to { transform: translate(-50%, -50%) scale(1.12); opacity: .7; } }
@keyframes roulette-switch { from { transform: scale(.88) rotate(-3deg); opacity: .72; } to { transform: scale(1.04) rotate(3deg); opacity: 1; } }
@keyframes roulette-settle { 0% { transform: scale(.74) rotate(-8deg); } 65% { transform: scale(1.15) rotate(3deg); } 100% { transform: scale(1) rotate(0); } }

@media (max-width: 520px) {
  .game-screen { padding-inline: 7px; }
  .score-panel { grid-template-columns: 1fr 1.15fr 1fr; gap: 4px; }
  .score-side { gap: 4px; min-height: 43px; padding-inline: 4px; }
  .score-side span { font-size: 8px; }
  .score-side strong { font-size: 19px; }
  .score-side .mini-disc { width: 22px; height: 22px; }
  .turn-message { min-height: 41px; padding-inline: 3px; font-size: 10px; }
  .board-wrap { padding: 6px; border-width: 4px; border-radius: 18px; }
  .thinking { inset: 6px; }
  .item-panel { margin-top: 7px; padding: 7px; border-radius: 16px; }
  .item-buttons { gap: 4px; }
  .item-button { gap: 3px; min-height: 43px; padding: 3px 2px; }
  .item-symbol { width: 24px; height: 24px; border-radius: 7px; font-size: 14px; }
  .item-button b { font-size: 8px; }
  .title-card { padding-inline: 18px; }
  .title-logo { width: min(100%, 320px); }
  .title-character { width: min(100%, 205px); max-height: 155px; }
}

@media (max-height: 710px) and (min-width: 380px) {
  .game-header { margin-bottom: 5px; }
  .score-panel { margin-bottom: 5px; }
  .item-panel { margin-top: 5px; }
  .item-heading { display: none; }
}

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