/* =============================================
   4つ目のダルマ  見た目
   ============================================= */
:root {
  --bg: #f6eddc;
  --bg2: #efe1c6;
  --card: #fffaf0;
  --ink: #2a1a12;
  --muted: #7a6352;
  --red: #ff4d5e;
  --red2: #ff8a95;
  --indigo: #3f8cff;
  --indigo2: #86b8ff;
  --gold: #e5ae3e;
  --line: rgba(42, 26, 18, 0.12);
  --shadow: 0 12px 30px rgba(90, 50, 20, 0.16);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  --display: "Dela Gothic One", "M PLUS Rounded 1c", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1714; --bg2: #2a211c; --card: #2f2620; --ink: #f7ecdd; --muted: #c2ab96;
    --line: rgba(255, 255, 255, 0.12); --shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #1d1714; --bg2: #2a211c; --card: #2f2620; --ink: #f7ecdd; --muted: #c2ab96;
  --line: rgba(255, 255, 255, 0.12); --shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  background-image: radial-gradient(circle at 20% 10%, rgba(216, 50, 58, .08), transparent 40%), radial-gradient(circle at 90% 90%, rgba(45, 78, 168, .08), transparent 45%);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button, a.btn { font-family: inherit; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  border: 0; border-radius: 16px; padding: 13px 18px; font-size: 17px; font-weight: 900; cursor: pointer;
  color: #fff; background: linear-gradient(180deg, #ffb13d, #f08a3c);
  box-shadow: 0 5px 0 #c4621d, 0 10px 20px rgba(60, 30, 10, .2); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c4621d; }
.btn.wide { width: 100%; }
.btn.red { background: linear-gradient(180deg, var(--red2), var(--red)); box-shadow: 0 5px 0 #c81d3a, 0 10px 20px rgba(255, 77, 94, .3); }
.btn.red:active { box-shadow: 0 1px 0 #c81d3a; }
.btn.indigo { background: linear-gradient(180deg, var(--indigo2), var(--indigo)); box-shadow: 0 5px 0 #1f55d6, 0 10px 20px rgba(63, 140, 255, .3); }
.btn.indigo:active { box-shadow: 0 1px 0 #1f55d6; }
.btn.sub { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.sub:active { box-shadow: none; }
.btn:disabled { opacity: .5; }

/* ---------- タイトル ---------- */
#title { align-items: center; justify-content: center; overflow-y: auto; }
.title-box { width: min(420px, 92vw); text-align: center; padding: 18px 0 24px; margin: auto; }
#logo-canvas { width: 240px; height: 80px; display: block; margin: 0 auto 4px; }
.logo { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(50px, 15vw, 70px); line-height: 1; color: var(--red); letter-spacing: .04em; text-shadow: 0 4px 0 #c81d3a; }
.logo small { display: block; font-size: .42em; color: var(--ink); text-shadow: none; letter-spacing: .2em; margin-bottom: 6px; }
.tagline { margin: 14px 0 22px; font-size: 14px; color: var(--muted); line-height: 1.8; }
.tagline b { color: var(--red); }
.menu { display: flex; flex-direction: column; gap: 12px; }
.menu-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 12px 12px 16px; box-shadow: var(--shadow); }
.menu-label { margin: 0 0 10px; font-weight: 800; font-size: 14px; color: var(--muted); }
.level-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.lv { padding: 13px 0; font-size: 16px; }
.menu-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-sub .btn { font-size: 14px; padding: 11px 8px; }

/* ---------- ゲーム ---------- */
#game { flex-direction: column; align-items: center; }
.hud {
  width: 100%; max-width: 720px; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 12px 4px;
}
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 17px; font-weight: 900; cursor: pointer; }
.icon-btn.off { opacity: .4; }
.score { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 14px; }
.score b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pl { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 2px solid transparent; max-width: 32vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: background .2s, border-color .2s; }
.pl .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.p1 .dot { background: var(--red); } .p2 .dot { background: var(--indigo); }
.pl.turn.p1 { border-color: var(--red); background: rgba(216, 50, 58, .12); }
.pl.turn.p2 { border-color: var(--indigo); background: rgba(45, 78, 168, .14); }
.status { font-weight: 900; font-size: 17px; min-height: 28px; margin-top: 4px; }
.status .t { color: var(--muted); font-size: 14px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.board-area { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; touch-action: none; }
#board { display: block; cursor: pointer; filter: drop-shadow(0 16px 24px rgba(60, 30, 10, .28)); }
.hint-line { margin: 0 0 calc(14px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); font-weight: 800; }
.eyes { position: absolute; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); font-weight: 800; }

/* ---------- ダイアログ ---------- */
.overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(30, 18, 10, .5); backdrop-filter: blur(4px); z-index: 10; padding: 16px; }
.overlay.show { display: flex; }
.modal { z-index: 20; }
.dialog {
  width: min(380px, 100%); max-height: 94vh; overflow: auto; background: var(--card); border-radius: 24px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); border: 1px solid var(--line);
}
.dialog h2 { margin: 0 0 4px; text-align: center; font-family: var(--display); font-weight: 400; font-size: 28px; }
#result-daruma { width: 90px; height: 90px; margin: 0 auto; }
.result-sub { margin: 0 0 6px; text-align: center; color: var(--muted); font-size: 14px; }
.hint { margin: 0; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint:empty { display: none; }
.err { margin: 0; min-height: 1em; font-size: 13px; color: var(--red); text-align: center; font-weight: 800; }
.field-l { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.field-l input { font: inherit; font-size: 18px; font-weight: 800; color: var(--ink); padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); outline: none; -webkit-user-select: text; user-select: text; }
.field-l input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(216, 50, 58, .2); }
.wait-code { margin: 0; text-align: center; color: var(--muted); }
.wait-code b { color: var(--red); font-size: 20px; }
.wait-msg { margin: 4px 0 8px; text-align: center; font-weight: 800; }
.howto { width: min(460px, 100%); }
.howto ol { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--red); }
.howto-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.howto-keys div { background: var(--bg); border-radius: 12px; padding: 8px 10px; font-size: 12px; }
.howto-keys h3 { margin: 0 0 4px; font-size: 13px; color: var(--indigo); }
.howto-keys p { margin: 0; line-height: 1.6; color: var(--muted); }
body.watching #btn-again { display: none; }
body.watching .hint-line { visibility: hidden; }

/* ---------- ゲーム画面（ポップ版レイアウト） ---------- */
:root { --red: #ff4d5e; --red2: #ff8a95; --indigo: #3f8cff; --indigo2: #86b8ff; }
#game { justify-content: flex-start; }
.hud-title { font-family: var(--display); font-size: 18px; color: var(--red); letter-spacing: .04em; }
.stage { flex: 1; width: 100%; max-width: 720px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); min-height: 0; }
.players { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.vs { font-family: var(--display); color: var(--muted); font-size: 16px; }
.pcard { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 18px; background: var(--card); border: 3px solid transparent; box-shadow: var(--shadow); min-width: 0; transition: transform .2s, border-color .2s; }
.pcard.p2 { justify-content: flex-end; text-align: right; }
.pcard > div { display: flex; flex-direction: column; min-width: 0; }
.pname { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pwins { font-size: 12px; color: var(--muted); font-weight: 800; }
.pwins b { font-size: 18px; color: var(--ink); }
.pface { width: 44px; height: 44px; flex: none; }
.pcard.turn.p1 { border-color: var(--red); transform: scale(1.04); }
.pcard.turn.p2 { border-color: var(--indigo); transform: scale(1.04); }
.pcard.turn .pface { animation: hop .8s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-5px); } }
.status { margin: 0; font-size: 18px; }
.board-area { flex: 0 1 auto; width: 100%; }
.hammer-bar { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 900; font-size: 14px; border: 2px solid transparent; }
.hammer-bar.soon { border-color: var(--red); color: var(--red); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.hb-dots { display: inline-flex; gap: 4px; }
.hb-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.hb-dots i.on { background: #ffb13d; }
.hint-line { margin: 0; }
.pl { display: none; }
/* 背の低い画面ではカードを小さく */
@media (max-height: 640px) {
  .pface { width: 32px; height: 32px; } .pcard { padding: 5px 8px; } .hammer-bar { padding: 6px 12px; font-size: 13px; } .hint-line { display: none; }
}

.hammer-bar { white-space: nowrap; max-width: 100%; }
#hammer-text { overflow: hidden; text-overflow: ellipsis; }

/* ことばの切りかえ */
.langs{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin-top:14px}
.langs button{font:800 13px 'M PLUS Rounded 1c',sans-serif;background:transparent;color:#3b2a20;border:2px solid rgba(59,42,32,.45);border-radius:999px;padding:4px 12px;cursor:pointer}
.langs button[aria-pressed="true"]{background:#3b2a20;color:#fff;border-color:#3b2a20}
html[data-lang="ko"] .logo,html[data-lang="ko"] .hud-title{font-family:'Black Han Sans','Dela Gothic One',sans-serif;font-weight:400}
