/* レイアウト：原稿用紙のマス目を下敷きにした、スマホ1列のゲーム画面。広い画面では牧場が2列になる。 */
:root {
  --paper: #F3F6F1;
  --grid: #D9E7DD;
  --ink: #1E2A4A;
  --muted: #5B6680;
  --accent: #2747A8;
  --accent-ink: #FFFFFF;
  --seal: #C8402F;
  --card: #FFFFFF;
  --line: #D3DCD6;
  --soft: #EAF0EC;
  --good: #2E8B57;
  --hp: #3BAA6B;
  --hp-low: #D9822B;
  --f-display: "DotGothic16", "Hiragino Sans", "Noto Sans JP", monospace;
  --f-body: "Zen Maru Gothic", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121725; --grid: #1B2533; --ink: #E6EAF4; --muted: #98A2BC; --accent: #8AA6FF; --accent-ink: #0E1530;
    --seal: #FF7A63; --card: #1A2133; --line: #2A3448; --soft: #222B40; --good: #6FD39A; --hp: #5BCB8A; --hp-low: #F0A55A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.app { max-width: 920px; margin: 0 auto; padding: 16px 16px 72px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.logo { font-family: var(--f-display); font-weight: 400; font-size: 30px; letter-spacing: .12em; margin: 0; }
.topRight { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.acct { display: inline-flex; align-items: center; gap: 6px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct.cta { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.acct .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 20px; letter-spacing: .06em; background: var(--soft); border-radius: 10px; padding: 10px 12px; text-align: center; margin: 0; user-select: all; }
.sheet { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 48px); border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--card); color: var(--ink); }
.sheet::backdrop { background: rgba(14, 21, 48, .45); }
.sheetHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheetHead h2 { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 0; }
.sheet section { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sheet h3 { font-size: 15px; margin: 0; }
.sheet p { margin: 0; }
.nameprompt { margin-bottom: 16px; border-color: var(--accent); }
.sharecard { width: 100%; max-width: 360px; height: auto; align-self: center; border-radius: 12px; border: 1px solid var(--line); }
.sharetext { margin: 0; font-size: 14px; background: var(--soft); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.sharebtns { display: flex; flex-wrap: wrap; gap: 8px; }
.sharebtns .btn { text-decoration: none; display: inline-flex; align-items: center; }
.sharebtns a.btn:not(.primary) { color: var(--ink); }
.sharebtns a.btn.primary { color: var(--accent-ink); }
.status { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.chip { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip b { font-weight: 700; }

.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 4px; margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.tab { border: 0; background: transparent; padding: 8px 0; border-radius: 8px; font-family: var(--f-display); font-size: 16px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { .tab { font-size: 14px; } }
.rank { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.rank th, .rank td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.rank th { font-size: 12px; color: var(--muted); font-weight: 500; }
.rank th.n, .rank td.n { text-align: left; white-space: normal; word-break: break-word; width: 100%; }
.rank td.r { font-family: var(--f-display); font-size: 16px; text-align: center; width: 2.6em; }
.rank tr.top1 td.r { color: #C8962F; } .rank tr.top2 td.r { color: #8A94AA; } .rank tr.top3 td.r { color: #B0703C; }
.rank tr.me td { background: var(--soft); font-weight: 700; }
.rank tr.gap td { border-bottom: 0; text-align: center; color: var(--muted); padding: 2px; }
.rank .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.ranktabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ranktabs .choice { text-align: center; padding: 6px 0; font-size: 14px; }
.tab[aria-current="page"] { background: var(--ink); color: var(--paper); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2 { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lede { font-size: 16px; max-width: 34em; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
.login { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }

.btn { border: 1px solid var(--line); background: var(--card); padding: 9px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { font-size: 17px; padding: 12px 20px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.spell { font-family: var(--f-body); font-size: 13px; line-height: 1.7; background: var(--soft); border-radius: 10px; padding: 12px; margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto; }
textarea, select, input[type=text] { width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
textarea { min-height: 84px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.choices { display: flex; gap: 6px; flex-wrap: wrap; }
.choice { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.choice[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.stage { display: grid; place-items: center; border-radius: 12px; padding: 12px; background: var(--soft); }
canvas.sprite { image-rendering: pixelated; width: 100%; max-width: 216px; height: auto; aspect-ratio: 1 / 1; }
.reveal canvas.sprite { animation: rise .7s cubic-bezier(.2,.8,.2,1.2); }
@keyframes rise { from { transform: translateY(16px) scale(.6); opacity: 0; filter: brightness(3); } to { transform: none; opacity: 1; filter: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.mname { font-family: var(--f-display); font-size: 24px; line-height: 1.2; margin: 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.stars { color: var(--seal); letter-spacing: 1px; font-family: var(--f-display); }
.seal { display: inline-block; font-family: var(--f-display); color: #fff; background: var(--seal); padding: 2px 10px; border-radius: 4px; transform: rotate(-4deg); }

.stats { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.stats .v { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.bar { position: relative; height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }
.bar s { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--muted); opacity: .6; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; text-align: center; position: relative; }
.mcard[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.mcard canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.mcard .n { font-family: var(--f-display); font-size: 15px; line-height: 1.2; }
.mcard .s { font-size: 11.5px; color: var(--muted); }
.mcard .teamflag { position: absolute; top: 6px; left: 6px; font-size: 11px; background: var(--ink); color: var(--paper); border-radius: 4px; padding: 0 5px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .split { grid-template-columns: minmax(0, 1fr); } }

.arena { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fighter { background: var(--soft); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 0; }
.fighter canvas { width: 100%; max-width: 160px; margin: 0 auto; image-rendering: pixelated; aspect-ratio: 1/1; height: auto; }
.fighter.opp canvas { transform: scaleX(-1); }
.fighter .who { font-size: 12px; color: var(--muted); }
.hp { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.hp i { display: block; height: 100%; background: var(--hp); transition: width .4s; }
.hp.low i { background: var(--hp-low); }
.pips { display: flex; gap: 3px; }
.pips span { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); background: var(--card); }
.pips span.on { background: var(--accent); border-color: var(--accent); }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.act { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; }
.act b { font-family: var(--f-display); font-weight: 400; font-size: 18px; }
.act small { color: var(--muted); font-size: 11.5px; }
.act:disabled { opacity: .4; cursor: default; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.log li { background: var(--soft); border-radius: 8px; padding: 4px 10px; }
.result { font-family: var(--f-display); font-size: 26px; text-align: center; }

.zrow { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.zrow canvas { width: 72px; height: 72px; image-rendering: pixelated; }
.zrow.unseen canvas { filter: brightness(0) opacity(.35); }
.cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 4px; }
.cells span { height: 10px; border-radius: 2px; background: var(--soft); border: 1px solid var(--line); }
.cells span.on { background: var(--accent); border-color: var(--accent); }
.cells span.first { background: var(--seal); border-color: var(--seal); }

.appfoot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 28px; }
.appfoot a { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); font-size: 14px; z-index: 20; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 16px; margin: 0; }

/* 図鑑 */
.ranktabs.two { grid-template-columns: repeat(2, 1fr); }
.dexsum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 8px; }
.dexsum div { background: var(--soft); border-radius: 10px; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; }
.dexsum b { font-family: var(--f-display); font-size: 24px; font-weight: 400; line-height: 1.1; }
.dexsum span { font-size: 11.5px; color: var(--muted); }
.dexgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .dexgrid { grid-template-columns: repeat(3, 1fr); } }
.dexsp { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); font: inherit; cursor: pointer; text-align: center; }
.dexsp .pic canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.dexsp.unknown { cursor: default; border-style: dashed; }
.dexsp .bar { position: relative; width: 100%; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.dexsp .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.dexsp .bar i.w { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.dexsp .bar i.m { background: var(--accent); }
.dexlegend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-top: 10px; }
.lg { display: inline-block; width: 14px; height: 8px; border-radius: 3px; vertical-align: middle; }
.lg.w { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.lg.m { background: var(--accent); }
.lg.shadow { width: 12px; height: 12px; background: var(--ink); opacity: .25; border-radius: 50%; }
canvas.shadow { filter: brightness(0); opacity: .22; }
.dexmat { display: grid; grid-template-columns: 34px repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.dexmat .th { font-size: 10px; color: var(--muted); text-align: center; align-self: end; line-height: 1.2; overflow-wrap: anywhere; }
.dexmat .th.row { align-self: center; font-size: 10px; }
.dexcell { position: relative; aspect-ratio: 1; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; display: grid; place-items: center; }
.dexcell canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.dexcell.none { background: var(--soft); cursor: default; border-style: dashed; }
.dexcell.mine { border-color: var(--accent); border-width: 2px; }
.dexcell[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 1px; }
.dexcell small { position: absolute; right: 3px; bottom: 1px; font-size: 9.5px; color: var(--muted); }
.badge { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; font-size: 9px; color: #fff; vertical-align: middle; }
.dexcell .badge { position: absolute; top: -5px; right: -5px; }
.badge.m { background: var(--accent); }
.badge.f { background: var(--seal); }
.dexctl { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 14px; }
.dexctl select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.dexctl .chk { display: inline-flex; gap: 6px; align-items: center; }
.dexlist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .dexlist { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.dexitem { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font: inherit; cursor: pointer; min-width: 0; }
.dexitem.mine { border-color: var(--accent); }
.dexitem canvas { width: 72px; height: 72px; image-rendering: pixelated; }
.dexitem .n { font-size: 13px; font-weight: 700; }
.dexitem .s, .dexitem .by { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dexitem .stars { font-size: 11px; }
.dexhero { display: grid; place-items: center; }
.dexhero canvas { width: 160px; height: 160px; image-rendering: pixelated; }
.center { text-align: center; }
#dexBack { align-self: flex-start; }

/* 天気予報 */
.forecast h3 { margin: 4px 0 6px; font-size: 0.95rem; }
.fcrow { list-style: none; margin: 0; padding: 0 0 6px; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.fc { flex: 0 0 auto; min-width: 64px; padding: 6px 8px; border: 1px solid var(--line, #d3dcd6); border-radius: 10px; background: var(--paper, #fff); text-align: center; scroll-snap-align: start; display: flex; flex-direction: column; gap: 2px; }
.fc.today { border-color: var(--accent, #2747a8); box-shadow: inset 0 0 0 1px var(--accent, #2747a8); }
.fcd { font-size: 0.75rem; opacity: 0.7; }
.fcw { font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.fc { cursor: pointer; }
.fc.sel { background: var(--accent, #2747a8); color: var(--accent-ink, #fff); }
