[hidden] { display: none !important; }
/* Layout: one narrow column like a card table. Title at left, the 4x4 spread of cards is the hero, controls and rules sit quietly below. */
:root {
  --ground: #e3e7ee;      /* 藍染を薄めた地 */
  --ground-2: #d5dbe6;
  --ink: #18203a;
  --muted: #55607c;
  --line: #b9c2d2;
  --card: #fbf8ef;        /* 札の紙 */
  --card-ink: #1b1c22;
  --frame: #14161c;       /* 札の黒縁 */
  --accent: #b47b00;      /* 山吹 */
  --accent-ink: #1b1400;
  --ok: #2c7a4d;
  --m0: #b93225;          /* 朱 */
  --m1: #1e4b8a;          /* 藍 */
  --m2: #35722f;          /* 若草 */
  --m3: #763b8c;          /* 藤紫 */
  --gold: #d9a514;
  --shadow: rgba(20, 28, 55, .28);
  --display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  --body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121829; --ground-2: #1a2238; --ink: #e9edf6; --muted: #9ba6c0; --line: #303b58;
    --card: #efe9d9; --card-ink: #1b1c22; --frame: #04060b; --accent: #e7b527; --accent-ink: #1b1400;
    --ok: #6fd09a; --m0: #b93225; --m1: #1e4b8a; --m2: #35722f; --m3: #763b8c; --gold: #d9a514;
    --shadow: rgba(0, 0, 0, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #121829; --ground-2: #1a2238; --ink: #e9edf6; --muted: #9ba6c0; --line: #303b58;
  --card: #efe9d9; --card-ink: #1b1c22; --frame: #04060b; --accent: #e7b527; --accent-ink: #1b1400;
  --ok: #6fd09a; --m0: #b93225; --m1: #1e4b8a; --m2: #35722f; --m3: #763b8c; --gold: #d9a514;
  --shadow: rgba(0, 0, 0, .55); color-scheme: dark;
}

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.7;
  padding-block: 1.5rem 3rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 27rem; margin-inline: auto; display: flex; flex-direction: column; gap: 1.25rem; }

header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
h1 { font-family: var(--display); font-weight: 800; font-size: 2.4rem; line-height: 1.1; margin: 0; letter-spacing: .08em; }
.issue { color: var(--muted); font-size: .85rem; text-align: right; line-height: 1.5; }
.issue b { color: var(--ink); font-family: var(--display); font-size: 1.05rem; }

.lead { margin: 0; font-size: .95rem; }

.meter { display: flex; gap: 1.25rem; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter b { color: var(--ink); font-size: 1.15rem; font-family: var(--display); margin-left: .25rem; }

/* board: 4 cards + lamp column, 4 rows + lamp row */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) .75rem; gap: .45rem; align-items: center; justify-items: stretch; }
.tile {
  position: relative; aspect-ratio: 3 / 4; max-width: 100%;
  border: 3px solid var(--frame); border-radius: 5px;
  background: var(--card); color: var(--card-ink);
  font: inherit; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--frame), 0 7px 12px var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tile.sel { transform: translateY(-7px); outline: 3px solid var(--accent); outline-offset: 2px; box-shadow: 0 3px 0 var(--frame), 0 14px 18px var(--shadow); }
.tile.fixed { cursor: default; box-shadow: none; border-width: 3px; background: color-mix(in srgb, var(--card) 86%, var(--frame)); }
.tile.fixed::after { content: ""; position: absolute; bottom: 7%; left: 50%; width: .42rem; height: .42rem; margin-left: -.21rem; border-radius: 50%; background: var(--frame); }
.flower { font-family: var(--display); font-weight: 800; font-size: min(11.5vw, 3rem); line-height: 1; }
.m0 .flower { color: var(--m0); } .m1 .flower { color: var(--m1); } .m2 .flower { color: var(--m2); } .m3 .flower { color: var(--m3); }
.month { position: absolute; left: 7%; bottom: 5%; font-size: .62rem; color: var(--card-ink); opacity: .7; line-height: 1; }
.rank { position: absolute; top: 6%; right: 7%; font-size: .7rem; font-weight: 700; line-height: 1; display: grid; place-items: center; color: var(--card-ink); }
.rk0 { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--gold); }
.rk1 { width: 1.4rem; height: 1.4rem; border: 2px solid var(--card-ink); border-radius: 3px; }
.rk2 { width: 1rem; height: 1.9rem; color: var(--card); }
.m0 .rk2 { background: var(--m0); } .m1 .rk2 { background: var(--m1); } .m2 .rk2 { background: var(--m2); } .m3 .rk2 { background: var(--m3); }
.rk3 { font-size: .58rem; opacity: .7; padding-top: .15rem; }

.lamp { width: .6rem; height: .6rem; border-radius: 50%; border: 2px solid var(--line); justify-self: center; transition: background .15s, border-color .15s; }
.lamp.on { background: var(--ok); border-color: var(--ok); }
.corner { width: .6rem; height: .6rem; }

.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: .9rem; font-weight: 700; color: var(--ink);
  background: transparent; border: 2px solid var(--line); border-radius: 4px;
  padding: .5rem .9rem; cursor: pointer; min-height: 2.75rem;
}
.btn:hover { border-color: var(--ink); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.done { border-top: 3px solid var(--ink); padding-top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.done h2 { font-family: var(--display); font-size: 1.7rem; margin: 0; letter-spacing: .1em; }
.done p { margin: 0; }
#shareText { width: 100%; box-sizing: border-box; font: inherit; font-size: .85rem; color: var(--ink); background: var(--ground-2); border: 1px solid var(--line); border-radius: 4px; padding: .5rem; resize: none; }
.note { font-size: .85rem; color: var(--muted); }

section h2 { font-family: var(--display); font-size: 1.15rem; margin: 0 0 .4rem; letter-spacing: .06em; }
section ul { margin: 0; padding-left: 1.2rem; font-size: .92rem; }
section li + li { margin-top: .25rem; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; margin-top: .6rem; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend .rank { position: static; }
.legend .chip { background: var(--card); border: 2px solid var(--frame); border-radius: 3px; padding: .2rem .3rem; display: inline-grid; place-items: center; min-width: 1.8rem; min-height: 2.2rem; }
.legend .rk2 { background: var(--m0); }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

@media (prefers-reduced-motion: reduce) { .tile, .lamp { transition: none; } }
