:root {
  color-scheme: light;
  --ink: #704e5a;
  --pink: #d990a0;
  --cream: #f8f1df;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: #233a31; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif; }
button, a { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .54; }
button:focus-visible, a:focus-visible { outline: 3px solid #e8a14e; outline-offset: 3px; }
#app { width: min(100%, 520px); min-height: 100dvh; margin: auto; padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 16px); background: var(--cream); }
header { height: 46px; display: flex; justify-content: space-between; align-items: center; }
header > a, #restart { min-width: 67px; min-height: 44px; display: grid; place-items: center; border: 0; background: none; color: #8c7772; text-decoration: none; }
header > a { font-size: 32px; }
#restart { font-size: 13px; letter-spacing: .07em; }
h1 { margin: 0; color: #795f60; font: 600 26px Georgia, serif; letter-spacing: .07em; }
main { display: flex; flex-direction: column; align-items: center; }
#rule { margin: 3px 0 16px; text-align: center; font-size: 13px; line-height: 1.5; color: #947e78; }
#tableau { position: relative; width: min(100%, 420px); aspect-ratio: 1 / .8660254; flex: none; overflow: visible; user-select: none; -webkit-user-select: none; }
.card { position: absolute; display: block; margin: 0; padding: 0; border: 0; border-radius: 11%; background: #fff7ed; box-shadow: 0 3px 6px #4c322c38; overflow: hidden; transform-origin: center; }
.card.face { border: 1.8px solid #d9b8ab; background: #fff7ed; }
.card.face::after { content: ""; position: absolute; inset: 4%; border: 1px solid #f2d8cd; border-radius: 9%; pointer-events: none; }
.card.back { background: #477e57; border: 2px solid #2d604a; }
.card .grass-art { width: 100%; height: 100%; display: block; }
.card .flower-art { position: absolute; width: 100%; height: 100%; inset: 0; overflow: visible; }
.card .rank { position: absolute; top: 2%; right: 10%; font: 800 clamp(12px, 4vw, 20px)/1.25 "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", sans-serif; color: #8d5964; z-index: 1; }
.card.face.selected { outline: 3px solid #db8298; outline-offset: 2px; box-shadow: 0 0 0 6px #f3cbd4; }
.card.face:disabled { opacity: 1; }
.card { backface-visibility: hidden; }
#controls { display: flex; width: min(100%, 420px); margin-top: 22px; justify-content: space-between; align-items: start; }
.pile-block { min-width: 76px; display: flex; justify-content: center; }
#undo, #stock, #waste > .card, #waste > .empty-waste { display: block; width: 68px; height: 96px; }
#undo { display: grid; place-items: center; border: 2px solid #d9b8ab; border-radius: 11px; background: #fff7ed; box-shadow: 0 3px 6px #4c322c38; color: #9c6977; }
#undo:disabled { opacity: .55; }
#undo svg { width: 50px; height: 56px; }
#stock { position: relative; padding: 0; border: 0; background: transparent; }
#stock:disabled { opacity: 1; }
#stock > .card { left: 0; width: 100%; height: 96px; }
#stock.empty { border: 2px dashed #a5b7a6; border-radius: 12px; color: #6d8b71; }
#waste { position: relative; width: 68px; height: 96px; }
#waste > .card { position: absolute; left: 0; }
#waste > .empty-waste { position: absolute; left: 0; top: 0; border: 2px dashed #d8c5bb; border-radius: 12px; }
.bloom { position: fixed; z-index: 100; pointer-events: none; }
.bloom .card { position: relative; width: 100%; height: 100%; border: 4px solid #d99a56; }
.bloom .flower-art { animation: blossom .36s cubic-bezier(.15,.75,.3,1) both; }
@keyframes blossom { 0% { transform: scale(.48); opacity: .6; } 75% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
#win-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: #233a31b8; }
#win-overlay[hidden] { display: none; }
#win-dialog { width: min(100%, 360px); padding: 27px 24px 24px; border: 3px solid #d9b8ab; border-radius: 24px; background: #fff7ed; box-shadow: 0 18px 45px #1b292860; text-align: center; }
#win-flower { width: 88px; height: 126px; margin: 0 auto 12px; }
#win-flower .card { position: relative; width: 100%; height: 100%; border: 2px solid #d9b8ab; }
#win-dialog h2 { margin: 0; color: #865d6c; font: 700 clamp(22px, 6vw, 28px) "Hiragino Maru Gothic ProN", sans-serif; }
#win-dialog p { margin: 10px 0 23px; color: #9a7477; font-size: 16px; }
#win-close { min-height: 46px; padding: 8px 25px; border: 2px solid #dcaeba; border-radius: 23px; background: #f5d8dd; color: #795464; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .bloom .flower-art { animation: none; }
}
