:root {
  --bg: #fbf4e8; --paper: #fffdf8; --ink: #5a4636; --sub: #9a8572; --line: #ecdcc6;
  --poka: #f0a04b; --pon: #6cb38a; --accent: #e8736c; --sky: #bfe3f2;
  --r1: #c9b9a6; --r2: #7fbf8e; --r3: #6aa8e0; --r4: #b07ee0; --r5: #f0b429;
  --nav-h: 80px; /* 下のタブバーの高さ(フッターが隠れないよう、本文の下にこのぶん余白をとる) */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { touch-action: manipulation; }
html, body { margin: 0; }
body {
  font-family: "M PLUS Rounded 1c", system-ui, sans-serif; background: var(--bg); color: var(--ink);
  min-height: 100vh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
body.in-game { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
button { font-family: inherit; color: inherit; cursor: pointer; border: none; }
button, .chip, .cell, .dest, nav button, .btn { user-select: none; -webkit-user-select: none; }
button:disabled { cursor: default; opacity: .55; }
.hidden { display: none !important; }
.screen { flex: 1 0 auto; width: 100%; }

/* ===== タイトル ===== */
#screen-title { background: linear-gradient(#cfeaf6 0%, #eaf6ee 55%, var(--bg) 100%); padding: 24px 20px 24px; }
.tbox { max-width: 400px; margin: 0 auto; text-align: center; }
.logo { font-size: 30px; font-weight: 800; line-height: 1.25; margin: 18px 0 4px; letter-spacing: .03em; }
.logo small { display: block; font-size: 14px; color: var(--sub); font-weight: 700; letter-spacing: .2em; }
.duo { display: flex; justify-content: center; gap: 4px; margin: 14px 0 18px; }
.duo div { width: 110px; }
.duo div:nth-child(2) svg { animation-delay: -1.5s; }
.tbtns { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.tpanel { background: var(--paper); border: 2px solid var(--line); border-radius: 20px; padding: 18px 16px; margin-top: 6px; text-align: center; }
.tpanel h2 { font-size: 17px; margin: 0 0 6px; }
.tpanel p { font-size: 13px; color: var(--sub); margin: 0 0 12px; line-height: 1.6; }
.tin { width: 100%; font-family: inherit; font-size: 20px; font-weight: 700; text-align: center; padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); outline: none; }
.tin:focus { border-color: var(--accent); }
.err { color: var(--accent); font-size: 13px; min-height: 20px; margin: 8px 0 4px; font-weight: 700; }
.err.info { color: var(--sub); }
.code { font-size: 28px; font-weight: 800; letter-spacing: .12em; background: #fff8e1; border: 3px dashed var(--r5); border-radius: 16px; padding: 14px 8px; margin: 10px 0; }
.tlink { background: none; color: var(--sub); font-size: 13px; padding: 10px; margin-top: 4px; }
.dev-note { font-size: 11px; color: var(--sub); margin-top: 14px; }

.link-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 400px; margin: 22px auto 0; }
.rules-link, .link-row .home-link, .share-button {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px;
  border: 2px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
  font-size: 12px; font-weight: 700; font-family: inherit; text-decoration: none;
}
.rules-link:hover, .link-row .home-link:hover, .share-button:hover { border-color: var(--accent); background: #fff6ef; }

/* ===== ゲーム画面 ===== */
.app { max-width: 480px; margin: 0 auto; }
.game-header { padding: 16px 18px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-header h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: .02em; white-space: nowrap; min-width: 0; }
.game-header h1 small { display: block; font-size: 11px; color: var(--sub); font-weight: 400; margin-top: 2px; }
.pill-name strong { color: var(--ink); font-weight: 800; }
.header-right { display: flex; gap: 6px; align-items: center; }
.comp { background: var(--paper); border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.comp b { color: var(--accent); font-size: 16px; display: inline-block; min-width: 1.6em; text-align: right; }
.hbtn { background: var(--paper); border: 2px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
main { padding: 6px 14px 20px; }
.view { display: none; }
.view.on { display: block; }

.sky { background: linear-gradient(#cfeaf6, #eaf6ee); border-radius: 22px; padding: 14px; margin-bottom: 14px; position: relative; overflow: hidden; }
.sky .cloud { position: absolute; background: #fff; border-radius: 999px; opacity: .8; }
.sky .home-title { position: relative; text-align: center; font-size: 13px; font-weight: 700; padding: 18px 0 6px; }
.charcard { background: var(--paper); border: 2px solid var(--line); border-radius: 20px; padding: 12px; display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.charcard .face { width: 76px; height: 76px; flex: none; }
.charcard .info { flex: 1; min-width: 0; }
.charcard .name { font-weight: 800; font-size: 16px; }
.charcard .name .tag { font-size: 10px; font-weight: 700; color: #fff; border-radius: 999px; padding: 2px 7px; margin-left: 6px; vertical-align: 2px; }
.charcard .st { font-size: 13px; color: var(--sub); margin: 3px 0 8px; }
.btn { background: var(--accent); color: #fff; font-weight: 800; border-radius: 14px; padding: 10px 16px; font-size: 14px; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.btn.sub { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.back { background: var(--r5); animation: bounce 1s infinite; }
.linkbtn { background: none; color: var(--accent); font-weight: 700; font-size: 12px; padding: 0; text-decoration: underline; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.bar { height: 10px; background: #f1e6d6; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), #7cc4e4); border-radius: 999px; }
.timer { font-size: 12px; color: var(--sub); margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.home-face svg { animation: sway 3s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.away { opacity: .35; filter: grayscale(.6); }
.hint { font-size: 12px; color: var(--sub); text-align: center; margin: 6px 0 0; line-height: 1.6; }
.recent { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 12px; margin-top: 12px; }
.recent h3 { margin: 0 0 8px; font-size: 14px; }
.recent ul { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--sub); line-height: 1.8; }
.recent .newmark { color: var(--accent); font-weight: 800; }

/* 行き先えらび */
.dest { display: flex; align-items: center; gap: 12px; background: var(--paper); border: 2px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; width: 100%; text-align: left; }
.dest .em { font-size: 30px; width: 40px; text-align: center; }
.dest .t { flex: 1; }
.dest .t b { display: block; font-size: 15px; }
.dest .t span { font-size: 12px; color: var(--sub); }
.dest .exp { font-size: 11px; color: var(--sub); text-align: right; white-space: nowrap; }
.dest .exp .s { color: var(--r5); font-size: 13px; letter-spacing: -1px; }

/* ずかん */
.filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.chip { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tierhead { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 14px; margin: 14px 2px 8px; }
.tierhead span { font-size: 12px; color: var(--sub); font-weight: 400; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.cell { aspect-ratio: 1; border-radius: 12px; background: #fff; border: 2px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 2px; min-width: 0; }
.cell .e { font-size: 24px; line-height: 1; }
.cell .n { font-size: 8.5px; margin-top: 3px; text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cell.unk { background: #f4ece0; border-style: dashed; color: #cbb9a3; }
.cell.unk .e { font-size: 18px; font-weight: 800; }
.cell .cnt { position: absolute; top: 1px; right: 4px; font-size: 9px; color: var(--sub); }
.r1 { border-color: var(--r1); } .r2 { border-color: var(--r2); } .r3 { border-color: var(--r3); } .r4 { border-color: var(--r4); }
.r5 { border-color: var(--r5); background: linear-gradient(135deg, #fff8e1, #fff); }

/* もちもの */
.itemrow { display: flex; align-items: center; gap: 12px; background: var(--paper); border: 2px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.itemrow .em { font-size: 30px; }
.itemrow .t { flex: 1; }
.itemrow .t b { display: block; }
.itemrow .t span { font-size: 12px; color: var(--sub); }
.itemrow .num { font-weight: 800; font-size: 18px; margin-right: 4px; font-variant-numeric: tabular-nums; }

/* 下のタブ */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 2px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabbar .in { max-width: 480px; width: 100%; display: flex; }
.tabbar button { flex: 1; background: none; padding: 10px 0 12px; font-size: 11px; font-weight: 700; color: var(--sub); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabbar button .i { font-size: 22px; }
.tabbar button.on { color: var(--ink); }
.tabbar button .dot { position: absolute; top: 6px; right: calc(50% - 20px); width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: none; }

/* 下から出るシート */
.modal { position: fixed; inset: 0; background: rgba(70,50,30,.45); display: none; align-items: flex-end; justify-content: center; z-index: 20; }
.modal.on { display: flex; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 12px; font-size: 17px; text-align: center; }
.close { display: block; margin: 10px auto 0; background: none; color: var(--sub); font-size: 13px; padding: 8px; }

/* おみやげ */
.postcard { background: #fff; border-radius: 18px; padding: 14px; border: 2px solid var(--line); text-align: center; }
.postcard .from { font-size: 12px; color: var(--sub); }
.postcard .line { font-size: 14px; margin: 8px 0 2px; }
.postcard .face { width: 90px; margin: 6px auto; }
.card { background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 18px 16px; text-align: center; margin-top: 12px; position: relative; animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.card .e { font-size: 64px; line-height: 1.1; }
.card .nm { font-size: 19px; font-weight: 800; margin-top: 6px; }
.card .pl { font-size: 12px; color: var(--sub); }
.card .stars { color: var(--r5); font-size: 16px; letter-spacing: 1px; margin: 4px 0; }
.card .stars .off { color: #e6dccd; }
.card .cat { display: inline-block; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: #f4ece0; margin-bottom: 4px; }
.card .tx { font-size: 13px; line-height: 1.75; text-align: left; background: #fbf6ee; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.card .new { position: absolute; top: -10px; left: -6px; background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; border-radius: 999px; padding: 3px 10px; transform: rotate(-8deg); }
.card.rr5 { border-color: var(--r5); box-shadow: 0 0 0 4px #fff3c4, 0 0 26px #f6cf5a; }
.card.rr4 { border-color: var(--r4); box-shadow: 0 0 0 4px #efe2fb; }
.card.rr3 { border-color: var(--r3); }
.card.item { border-color: var(--accent); border-style: dashed; }
.shine { position: absolute; inset: 0; border-radius: 18px; pointer-events: none; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.8) 45%, transparent 60%); background-size: 250% 100%; animation: shine 1.8s infinite; }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.prog { text-align: center; font-size: 12px; color: var(--sub); margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 30; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; }

/* ===== フッター ===== */
.site-footer { text-align: center; font-size: 11px; color: var(--sub); padding: 14px 16px 16px; line-height: 1.7; }
.site-footer p { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 4px; }
.site-footer a { color: var(--sub); }

/* ===== 規約ポップアップ ===== */
.legal-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.legal-modal-backdrop { position: absolute; inset: 0; background: rgba(70,50,30,.5); }
.legal-modal-box { position: relative; width: min(720px, 100%); height: min(86vh, 900px); background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.legal-modal-frame { width: 100%; height: 100%; border: 0; }
.legal-modal-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line); font-size: 16px; z-index: 1; }
