* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #f5f3ee; color: #1b1b1d; touch-action: manipulation;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; padding: 34px 12px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
#app[hidden] { display: none; }

/* the slot: a calendar page with four reels (月・日・〇〇・〇〇の日) */
#slot { flex: none; position: relative; background: #fff; border: 3px solid #1b1b1d; border-top: 16px solid #d23a2c; padding: 10px 10px 12px; }
.srow { display: flex; align-items: center; justify-content: center; gap: 6px; }
.srow + .srow { margin-top: 8px; }
.srow small { font-size: 13px; font-weight: 800; color: #45433e; }
.srow span { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 24px; font-weight: 900; }
.reel { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; height: 50px; padding: 0 8px; border: 2px solid #1b1b1d; background: #fffdf7;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 24px; font-weight: 900; white-space: nowrap; overflow: hidden; }
#r-d { min-width: 128px; }
#r-mod, #r-noun { font-size: 22px; }
#r-noun { min-width: 96px; }
.reel.spinning { color: #8d8a82; filter: blur(.6px); }
.reel.stop { animation: thunk .2s ease-out; }
@keyframes thunk { 0% { transform: translateY(-5px); } 60% { transform: translateY(2px); } 100% { transform: none; } }
.reel.rare { background: #f6e7b8; border-color: #b8860b; box-shadow: 0 0 0 2px #e8c35a; }
#prize { position: absolute; right: -6px; top: -26px; font-style: normal; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 18px; font-weight: 900;
  color: #d23a2c; border: 3px double #d23a2c; border-radius: 50%; width: 76px; height: 76px; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.1;
  background: rgba(255,255,255,.92); transform: rotate(-12deg) scale(2); opacity: 0; pointer-events: none; padding: 4px; }
#prize.on { animation: hanko .26s cubic-bezier(.3,1.6,.6,1) forwards; }
#prize.sat, #prize.one { color: #6d6a63; border-color: #6d6a63; }
@keyframes hanko { to { transform: rotate(-12deg) scale(1); opacity: 1; } }

#spin-step, #way-step { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#spin-step[hidden], #way-step[hidden] { display: none; }
#pline { flex: none; margin: 0; min-height: 22px; font-size: 15px; font-weight: 800; text-align: center; }

/* the month of the drawn day */
#grid { flex: 1; min-height: 0; max-height: 300px; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto repeat(6, 1fr); border: 2px solid #1b1b1d; border-right-width: 1px; border-bottom-width: 1px; margin-top: 6px; background: #fff; }
#grid.blank { opacity: .35; }
#grid .dw { font-size: 11px; font-weight: 800; text-align: center; padding: 2px 0; border-right: 1px solid #1b1b1d; border-bottom: 2px solid #1b1b1d; }
#grid > .day, #grid > .void { display: flex; flex-direction: column; align-items: center; padding: 2px 1px 0; min-height: 0; border-right: 1px solid #b9b5ab; border-bottom: 1px solid #b9b5ab;
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; }
#grid > .void { background: #ebe8e0; }
#grid .sun, #grid .hol { color: #d23a2c; }
#grid .sat { color: #2c5fa8; }
#grid small { display: block; font-size: 8px; line-height: 1.1; font-weight: 700; color: #d23a2c; white-space: nowrap; max-width: 100%; overflow: hidden; letter-spacing: -.5px; }
#grid .inrun { background: #fbe1dc; }
#grid .new b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-top: -2px; border-radius: 50%; background: #d23a2c; color: #fff; }
#spin { flex: none; }
#after-spin { flex: none; margin-top: 10px; }
#after-spin[hidden] { display: none; }
#after-spin button { padding: 13px 6px; font-size: 17px; }
#ok { flex: 1.6; }

/* what the day is for */
#law { flex: none; margin: 0; padding: 8px 10px; background: #fffdf7; border: 2px solid #1b1b1d; outline: 1px solid #1b1b1d; outline-offset: -5px;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 15px; line-height: 1.55; font-weight: 700; }
#law .slot { color: #8d8a82; border-bottom: 3px solid #d23a2c; }
#own { flex: none; display: flex; gap: 6px; margin-top: 10px; }
#own input { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 700; padding: 10px; border: 2px solid #1b1b1d; border-radius: 0; background: #fff; color: #1b1b1d; -webkit-user-select: text; user-select: text; }
#own button { flex: none; padding: 10px 14px; }
#hand { flex: none; display: grid; gap: 8px; margin-top: 10px; }
#hand button { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-weight: 800; background: #fffdf7; text-align: left; justify-content: flex-start; line-height: 1.35;
  padding: 10px; font-size: 16px; min-height: 54px; border-width: 2px; box-shadow: 3px 3px 0 #1b1b1d; }
#hand button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #1b1b1d; }
#hand button.picked { background: #1b1b1d; color: #fff; }
#hand.deal button { animation: deal .22s ease-out backwards; }
#hand.deal button:nth-child(2) { animation-delay: .04s; }
#hand.deal button:nth-child(3) { animation-delay: .08s; }
@keyframes deal { from { transform: translateY(14px); opacity: 0; } }
#skip { flex: none; align-self: center; margin-top: 8px; }

.panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #f5f3ee; overflow-y: auto; overscroll-behavior: contain; padding: 16px; z-index: 10; }
.panel[hidden] { display: none; }
.box { width: 100%; max-width: 360px; text-align: center; margin: auto; }
.box.wide { max-width: 560px; }
#tart { width: 100%; height: clamp(110px, 22vh, 170px); display: block; margin: 0 auto 6px; }
h1 { font-size: 54px; letter-spacing: 6px; margin: 0 0 4px; }
.sub { margin: 0 0 26px; font-size: 16px; font-weight: 700; }
button, .button { font: inherit; font-size: 16px; font-weight: 700; color: #1b1b1d; background: #fff; border: 2px solid #1b1b1d; border-radius: 0;
  padding: 10px 18px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
button.primary, .button.primary { background: #1b1b1d; color: #fff; }
button.big { width: 100%; padding: 13px; font-size: 18px; margin-top: 12px; }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.row > * { flex: 1; }
button.link { background: none; border: 0; padding: 4px; font-size: 14px; text-decoration: underline; color: #45433e; }

/* the result: the newspaper of the day, then the post row (sticky, as ニクキリ) */
#result { padding: 10px 12px 0; align-items: flex-start; overflow-x: hidden; }
#result .box { min-height: 100%; display: flex; flex-direction: column; }
#paper-wrap { position: relative; }
#paper { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border: 2px solid #1b1b1d; background: #fbf8f0; -webkit-touch-callout: default; }
#paper.spin { animation: spin .62s cubic-bezier(.2,.7,.3,1) backwards; }
@keyframes spin { from { transform: rotate(-900deg) scale(.05); } to { transform: rotate(0) scale(1); } }
#hanko { position: absolute; width: 14.5%; aspect-ratio: 1; margin: -7.25% 0 0 -7.25%; opacity: 0; pointer-events: none; background-size: contain; }
#hanko.on { animation: hanko2 .24s cubic-bezier(.3,1.6,.6,1) forwards; }
@keyframes hanko2 { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#r-after { margin-top: 16px; margin-bottom: auto; }
#r-share { gap: 6px; position: sticky; bottom: 0; z-index: 3; margin: 14px -12px 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #f5f3ee; box-shadow: 0 -8px 10px -8px rgba(27,27,29,.28); }
#r-post { flex: 1.7; background: #1b1b1d; color: #fff; font-size: 18px; padding: 13px 8px; white-space: nowrap; }
#r-post svg { width: 18px; height: 18px; }
#again { flex: 1; font-size: 15px; padding: 10px 4px; white-space: nowrap; }
#r-row .sn-row { flex-wrap: nowrap; overflow: hidden; justify-content: center; gap: 3px; margin-top: 10px; max-width: none; font-size: 12.5px; }
#r-row .sn-row > span { flex: none; font-size: 10.5px; }
#r-row .sn-chip { flex: none; gap: 3px; padding: 4px 6px 4px 3px; white-space: nowrap; }
#r-row .sn-chip:last-child { flex: 0 1 auto; min-width: 0; }
#r-row .sn-chip b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#r-row .sn-chip img { flex: none; width: 20px; height: 20px; }

/* short screens (X の in-app browser, 530px) */
@media (max-height: 600px) {
  #app { gap: 6px; padding-top: 30px; }
  .reel { height: 42px; font-size: 21px; }
  #r-mod, #r-noun { font-size: 19px; }
  .srow + .srow { margin-top: 6px; }
  #grid > .day { font-size: 13px; padding-top: 0; }
  #grid small { font-size: 7.5px; }
  #grid .new b { width: 20px; height: 20px; }
  #after-spin button, #spin { padding: 11px 6px; }
  #hand button { min-height: 46px; padding: 7px 10px; font-size: 15px; }
}
