/* まるっとスライドパズル — base.css（共通の見た目）
 * 色・角丸・ボタン・パネル。各画面の css はここの変数とクラスを使う。
 */
:root {
  --paper: #FFF4DE;        /* 生成りの紙 */
  --paper-2: #FBE7C3;
  --ink: #4A3426;          /* こげ茶の文字 */
  --ink-soft: #8A6F5C;
  --wood: #B9834F;         /* 木の枠 */
  --wood-dark: #8A5A33;
  --wood-light: #E2B98A;
  --fumi: #F39A3D;         /* ふみまる：オレンジ */
  --miso: #4A9AD4;         /* ミソマル：青 */
  --keika: #EE7FA4;        /* けいか：ピンク */
  --ok: #5DB075;
  --star: #F7B500;
  --white: #FFFDF8;
  --shadow: 0 6px 0 rgba(74, 52, 38, .18), 0 10px 24px rgba(74, 52, 38, .18);
  --shadow-sm: 0 3px 0 rgba(74, 52, 38, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Hiragino Maru Gothic ProN", "ヒラギノ丸ゴ ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--ink); font-weight: 700; line-height: 1.5;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; height: 100dvh; overflow: hidden; }
#backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
#screens { position: absolute; inset: 0; z-index: 1; }
#overlay-root { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#overlay-root > * { pointer-events: auto; }

.screen {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
}
.screen.is-active { display: flex; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ---- ボタン ---- */
.btn {
  appearance: none; border: 0; cursor: pointer; min-height: 48px; padding: 10px 18px;
  border-radius: 999px; background: var(--white); color: var(--ink); font-weight: 800; font-size: 17px;
  box-shadow: var(--shadow-sm), inset 0 0 0 2px rgba(74, 52, 38, .12);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,0), inset 0 0 0 2px rgba(74, 52, 38, .12); }
.btn:focus-visible { outline: 3px solid var(--miso); outline-offset: 2px; }
.btn[disabled] { opacity: .45; cursor: default; }
/* 白い文字をのせるボタンは、地を濃いめにして読みやすく（白とのコントラスト 4.5:1 以上）。
   キャラクターの差し色の変数（--fumi --miso --keika）はそのまま */
.btn-primary { background: #B85C14; color: #fff; box-shadow: 0 4px 0 #7E3D0A, 0 8px 16px rgba(126, 61, 10, .28); text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn-primary:active { box-shadow: 0 0 0 #7E3D0A; transform: translateY(4px); }
.btn-blue { background: #2E78B0; color: #fff; box-shadow: 0 4px 0 #1C4F78; }
.btn-pink { background: #B5527A; color: #fff; box-shadow: 0 4px 0 #7D3453; }
.btn-big { min-height: 60px; font-size: 20px; padding: 12px 26px; }
.btn-icon { width: 48px; min-width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn-ghost { background: transparent; box-shadow: none; }

/* ---- パネル・見出し ---- */
.panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; flex: 0 0 auto; }
.topbar .title { flex: 1 1 auto; font-size: 20px; font-weight: 900; text-align: center; }
.muted { color: var(--ink-soft); font-weight: 600; }
.stars { color: var(--star); letter-spacing: 2px; }
.stars .off { color: rgba(74, 52, 38, .2); }

/* ---- かさねる窓（モーダル） ---- */
.modal-back {
  position: absolute; inset: 0; background: rgba(60, 40, 28, .45); display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: sp-fade .18s ease both;
}
.modal { width: min(440px, 100%); max-height: 92%; overflow-y: auto; background: var(--white); border-radius: 24px; box-shadow: var(--shadow); padding: 20px; text-align: center; animation: sp-pop .28s cubic-bezier(.2, 1.4, .4, 1) both; }
.modal h2 { margin: 0 0 8px; font-size: 22px; }
.modal .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---- お知らせ ---- */
#toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 9;
  background: rgba(74, 52, 38, .92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; max-width: 88%; text-align: center;
}
#toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@keyframes sp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sp-pop { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .modal, .modal-back { animation: none; }
}
