* { box-sizing: border-box; }
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 { touch-action: none; position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* the お題 (room and the owner's words) on the left, the total on the right */
#hud { min-height: 58px; flex: 1 1 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; }
#hud.off { visibility: hidden; }
#odai { min-width: 0; }
#odai b { display: inline-block; font-size: 12px; border: 2px solid #1b1b1d; padding: 1px 6px; background: #fff; }
#odai p { margin: 2px 0 0; font-size: 12px; line-height: 1.3; font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#sum { flex: none; text-align: right; line-height: 1.1; }
#sum small { display: block; font-size: 11px; font-weight: 700; color: #45433e; }
#sum b { font-size: 24px; color: #d23a2c; font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-block; }
#sum.bump b { animation: bump .28s ease-out; }
#sum.jackpot b { color: #d23a2c; animation: jackpot .18s steps(2) infinite; -webkit-text-stroke: 1px #c8961e; }
@keyframes jackpot { 50% { transform: scale(1.18) rotate(-3deg); } }
@keyframes bump { 30% { transform: scale(1.22); } }
#timer { height: 6px; flex: none; margin: 0 12px 4px; border: 1.5px solid #1b1b1d; background: #fff; }
#timer i { display: block; height: 100%; background: #1b1b1d; transform-origin: left; }
#timer.last i { background: #d23a2c; }
#stage { position: relative; flex: 1; min-height: 0; }
/* a tall phone: the room keeps its shape and the space above goes to the お題 and the total */
#hud.tall { flex-direction: column; justify-content: center; align-items: stretch; gap: 12px; padding: 6px 16px 4px; }
#hud.tall #odai { display: flex; flex-direction: column; align-items: flex-start; }
#hud.tall #odai b { font-size: 13px; }
#hud.tall #odai p { position: relative; display: block; font-size: 18px; line-height: 1.4; background: #fff; border: 2px solid #1b1b1d; border-radius: 14px;
  padding: 8px 14px; margin-top: 8px; align-self: stretch; }
#hud.tall #sum { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
#hud.tall #sum small { display: inline; font-size: 14px; flex: none; }
#hud.tall #sum b { font-size: 40px; }
#hud.tall #sum.long b { font-size: 30px; }
#sum.long b { font-size: 17px; }
#hud.tall #sum.xlong b { font-size: 25px; }
#sum.xlong b { font-size: 14.5px; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* the first time: a thumb wiping low on the screen (anywhere works; low is where a thumb is) */
#hint { position: absolute; left: 50%; bottom: 13%; width: 0; height: 0; pointer-events: none; }
#hint[hidden] { display: none; }
#hint i { position: absolute; width: 30px; height: 38px; margin: -19px -15px; border-radius: 50% 50% 46% 46%; border: 3px solid #1b1b1d; background: rgba(255,255,255,.88);
  animation: wiper 0.9s ease-in-out infinite alternate; transform-origin: 50% 160px; }
#hint b { position: absolute; left: -60px; width: 120px; top: 30px; text-align: center; font-size: 20px; letter-spacing: 2px;
  -webkit-text-stroke: 5px #fff; paint-order: stroke; }
@keyframes wiper { from { transform: rotate(-32deg); } to { transform: rotate(32deg); } }

.panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(245,243,238,.86); overflow-y: auto; overscroll-behavior: contain; padding: 16px; z-index: 10; }
.panel[hidden] { display: none; }
#title { background: rgba(245,243,238,.95); }
.box { width: 100%; max-width: 360px; text-align: center; margin: auto; }
.box.wide { max-width: 520px; }
#tart { width: 100%; height: clamp(120px, 24vh, 190px); display: block; margin: 0 auto 6px; }
h1 { font-size: 64px; letter-spacing: 10px; margin: 0 0 4px; -webkit-text-stroke: 8px #f5f3ee; paint-order: stroke; }
.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: 14px; font-size: 18px; margin-top: 12px; }
.big { font-size: 20px; font-weight: 700; }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.row > * { flex: 1; }
/* Xでポスト is the main button */
#r-post { flex: 1.7; background: #1b1b1d; color: #fff; font-size: 18px; padding: 13px 10px; }
#r-post svg { width: 18px; height: 18px; }
#r-img { font-size: 14px; padding: 10px 6px; }
#r-after { margin-top: 18px; }
/* The post / save row stays on screen: on a short phone (390×667, X's in-app browser ~390×600) a big report would
   push it to the bottom edge. It sticks to the bottom of the scrolling result until its own place comes up. */
#r-share { position: sticky; bottom: 0; z-index: 3; margin: 10px -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); }
#result { background: #f5f3ee; padding: 10px 12px; align-items: flex-start; }
button.link { background: none; border: 0; padding: 4px; font-size: 14px; text-decoration: underline; color: #45433e; }
.zk { margin: 10px 0 0; display: flex; justify-content: center; align-items: center; gap: 8px; }
.new { color: #d23a2c; font-weight: 700; font-size: 13px; }

/* ほかのゲームの1行（マドリと同じ） */
#r-row .sn-row { flex-wrap: nowrap; overflow-x: auto; justify-content: safe center; gap: 4px; margin-top: 10px; font-size: 12.5px; scrollbar-width: none; }
#r-row .sn-row::-webkit-scrollbar { display: none; }
#r-row .sn-row > span { flex: none; font-size: 10.5px; letter-spacing: .04em; }
#r-row .sn-chip { flex: none; gap: 3px; padding: 4px 7px 4px 4px; white-space: nowrap; }
#r-row .sn-chip img { width: 20px; height: 20px; }

/* the report */
#sheet { background: #fbfaf6; border: 3px solid #1b1b1d; outline: 1px solid #1b1b1d; outline-offset: -7px; padding: 12px 14px 10px; text-align: left; position: relative; }
.r-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; border-bottom: 2px solid #1b1b1d; padding-bottom: 4px; }
.r-head b { font-size: 22px; letter-spacing: 4px; white-space: nowrap; }
.r-head span { font-size: 11px; font-weight: 700; text-align: right; line-height: 1.3; }
.r-head small { display: block; font-weight: 400; color: #6f6c64; font-size: 9.5px; }
#r-room { margin: 5px 0 4px; font-size: 12.5px; font-weight: 700; color: #45433e; }
/* the tab on the diagram */
.r-dia { position: relative; }
#r-place { position: absolute; left: 0; top: 0; background: #1b1b1d; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; }
#r-big { position: absolute; right: 8px; top: 8px; color: #d23a2c; border: 3px double #d23a2c; padding: 2px 8px; font-style: normal; font-weight: 900; font-size: 18px;
  transform: rotate(-10deg); background: rgba(255,255,255,.7); animation: hanko .35s cubic-bezier(.2,1.6,.4,1) .5s both; }
#r-big[hidden] { display: none; }
/* 自己ベスト更新: bottom right of the diagram (the rare 重大事故 is top right) */
#r-best { position: absolute; right: 6px; bottom: 6px; color: #d23a2c; background: #fff6d8; border: 3px solid #d23a2c; outline: 1.5px solid #c8961e; outline-offset: -6px;
  padding: 3px 9px; font-style: normal; font-weight: 900; font-size: 15px; letter-spacing: .02em; transform: rotate(-6deg); animation: hanko2 .35s cubic-bezier(.2,1.6,.4,1) .7s both; }
#r-best[hidden] { display: none; }
@keyframes hanko2 { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } }
#r-evi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 5px; }
#r-evi canvas { width: 100%; height: clamp(64px, 11vh, 104px); display: block; }
#diagram { width: 100%; height: clamp(100px, 20vh, 200px); display: block; border: 1.5px solid #1b1b1d; }
.r-total { margin: 6px 0 2px; display: flex; align-items: baseline; gap: 10px; }
.r-total span { font-size: 14px; font-weight: 700; flex: none; }
.r-total b { color: #d23a2c; font-size: 36px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.r-total b.long { font-size: 28px; }
.r-total b small { font-size: 18px; margin-left: 2px; }
#r-list { list-style: none; margin: 0; padding: 4px 0 0; border-top: 2px solid #1b1b1d; font-size: 13.5px; line-height: 1.55; }
#r-list li { display: flex; gap: 6px; align-items: baseline; }
#r-list li i { font-style: normal; flex: none; width: 1.3em; height: 1.3em; line-height: 1.3em; border-radius: 50%; background: #d23a2c; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
#r-list li i.odd { background: none; color: #d23a2c; }
#r-list li span { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#r-list li b { flex: none; font-variant-numeric: tabular-nums; }
#r-list[hidden], #r-chain[hidden] { display: none; }
#r-chain { margin: 3px 0 0; font-size: 12px; font-weight: 700; color: #45433e; }
.r-foot { margin-top: 6px; border-top: 2px solid #1b1b1d; padding: 6px 66px 0 0; position: relative; min-height: 64px; }
#r-comment { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }
#r-verdict { margin: 4px 0 0; font-size: 12.5px; font-weight: 700; color: #d23a2c; }
#r-stamp { position: absolute; right: 0; top: 8px; width: 58px; height: 58px; border: 3px solid #d23a2c; border-radius: 50%; color: #d23a2c;
  font-style: normal; font-weight: 700; font-size: 20px; display: flex; align-items: center; justify-content: center; transform: rotate(-14deg);
  box-shadow: inset 0 0 0 4px #fbfaf6, inset 0 0 0 5px #d23a2c; opacity: .9; animation: hanko .35s cubic-bezier(.2,1.6,.4,1) .25s both; }
@keyframes hanko { from { transform: rotate(-14deg) scale(2.4); opacity: 0; } }
/* short screens: the chain on one line, a smaller comment and diagram */
@media (max-height: 760px) {
  #r-chain { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #r-comment { font-size: 16px; line-height: 1.3; }
  #diagram { height: clamp(90px, 17vh, 130px); }
  #r-evi canvas { height: clamp(58px, 10vh, 76px); }
  .r-foot { min-height: 58px; }
}
@media (max-height: 640px) {
  #diagram { height: 84px; }
  #r-evi canvas { height: 58px; }
  #r-list li:nth-child(n+3), #r-chain { display: none; }
  .r-total b { font-size: 30px; }
  #r-comment { font-size: 16px; }
  .r-foot { min-height: 58px; }
}

#zukan { z-index: 20; background: #f5f3ee; align-items: flex-start; }
#z-list { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; text-align: center; font-size: 12px; }
#z-list li { border: 2px solid #d9a520; background: #fff; padding: 4px; min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#z-list li canvas { width: 48px; height: 48px; }
#z-list li b { display: block; font-size: 11.5px; line-height: 1.25; }
#z-list li small { color: #d23a2c; font-weight: 700; font-size: 11px; }
#z-list li.no { border: 2px dashed #a9a59b; color: #a9a59b; background: transparent; font-size: 22px; font-weight: 700; }
