/* ==========================================================
   さんすうクラフト — スタイル
   マイクラ風ブロックUI / スマホ・PC対応
   ========================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --theme: #43a047;
  --wood: #8d6e63;
  --dark: #3e2723;
  --paper: #fffdf5;
  --sky1: #7ec8f7;
  --sky2: #b3e5fc;
}

html, body { height: 100%; }
body {
  font-family: 'Hiragino Maru Gothic ProN', 'BIZ UDGothic', 'Yu Gothic', 'Meiryo', system-ui, sans-serif;
  background: linear-gradient(#6ec0f5, #b3e5fc 55%, #aed581 55.2%, #8bc34a 62%, #795548 62.2%, #6d4c41);
  background-attachment: fixed;
  color: #33261f;
  min-height: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding: 10px 10px 40px; }

ruby rt { font-size: 0.5em; color: #7a6a5f; }

h3 { font-size: 1.15em; margin-bottom: 8px; color: var(--dark); }
p { line-height: 1.7; }

/* ---------- ブロックふうの部品 ---------- */
.blocky {
  border: 3px solid var(--dark);
  border-radius: 6px;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .14), inset 4px 4px 0 rgba(255, 255, 255, .35), 0 4px 0 rgba(0, 0, 0, .25);
}

.btn {
  display: inline-block;
  font: inherit;
  font-weight: bold;
  font-size: 1.05em;
  padding: 12px 18px;
  border: 3px solid var(--dark);
  border-radius: 8px;
  background: #ffca28;
  color: var(--dark);
  cursor: pointer;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .15), inset 4px 4px 0 rgba(255, 255, 255, .4), 0 5px 0 rgba(0, 0, 0, .3);
  transition: transform .06s;
  text-align: center;
  min-height: 52px;
}
.btn:active { transform: translateY(4px); box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .15), inset 4px 4px 0 rgba(255, 255, 255, .4), 0 1px 0 rgba(0, 0, 0, .3); }
.btn.green { background: #66bb6a; color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.btn.blue { background: #42a5f5; color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.btn.red { background: #ef5350; color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.btn.gray { background: #cfd8dc; }
.btn.big { font-size: 1.3em; padding: 16px 26px; width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- 上のバー ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  background: rgba(62, 39, 35, .88);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 3px solid #271713;
}
.topbar .back {
  font-size: 1.2em; background: #ffca28; color: var(--dark);
  border: 2px solid var(--dark); border-radius: 8px; padding: 4px 12px; cursor: pointer; font-weight: bold;
}
.topbar .t { flex: 1; font-weight: bold; font-size: 1.05em; text-align: center; text-shadow: 1px 1px 0 #000; }
.topbar .coins { background: rgba(255, 214, 64, .18); border: 2px solid #ffd640; border-radius: 8px; padding: 3px 10px; font-weight: bold; color: #ffe082; white-space: nowrap; }

/* ---------- タイトル画面 ---------- */
.title-wrap { text-align: center; padding-top: 8vh; }
.game-logo {
  display: inline-block;
  font-size: clamp(2em, 9vw, 3.4em);
  font-weight: 900;
  color: #fff;
  letter-spacing: .04em;
  text-shadow: 3px 3px 0 #2e7d32, 6px 6px 0 rgba(0, 0, 0, .35);
  transform: rotate(-2deg);
  margin-bottom: 6px;
}
.game-logo .craft { color: #ffd54f; text-shadow: 3px 3px 0 #e65100, 6px 6px 0 rgba(0, 0, 0, .35); }
.title-sub { color: #fff; font-weight: bold; text-shadow: 1px 1px 0 rgba(0,0,0,.5); margin-bottom: 26px; font-size: 1.05em; }
.title-chars { font-size: 2.6em; margin: 12px 0 22px; letter-spacing: .15em; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- ホーム ---------- */
.hero-strip { text-align: center; margin: 4px 0 12px; }
.hero-strip .mini-logo { font-size: 1.5em; font-weight: 900; color: #fff; text-shadow: 2px 2px 0 #2e7d32, 3px 3px 0 rgba(0,0,0,.3); }
.player-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border: 3px solid var(--dark); border-radius: 12px;
  padding: 8px 12px; margin-bottom: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.player-chip .face { font-size: 2em; background: #e3f2fd; border: 2px solid var(--dark); border-radius: 10px; padding: 2px 6px; cursor: pointer; }
.player-chip .stats { flex: 1; font-size: .92em; font-weight: bold; line-height: 1.5; }
.player-chip .gear { font-size: 1.5em; cursor: pointer; background: none; border: none; }

.world-card {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: var(--paper);
  border: 3px solid var(--dark);
  border-left: 12px solid var(--wc, #43a047);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.06), 0 4px 0 rgba(0, 0, 0, .25);
  text-align: left;
  font: inherit;
  transition: transform .06s;
}
.world-card:active { transform: translateY(3px); }
.world-card .we { font-size: 2.2em; }
.world-card .wt { font-weight: bold; font-size: 1.1em; }
.world-card .ws { font-size: .82em; color: #7a6a5f; margin-top: 2px; }
.world-card .winfo { flex: 1; }
.world-card .prog { height: 12px; background: #e0d7cd; border: 2px solid var(--dark); border-radius: 6px; margin-top: 6px; overflow: hidden; }
.world-card .prog i { display: block; height: 100%; background: var(--wc, #43a047); }
.world-card.locked { filter: grayscale(1); opacity: .65; }
.world-card.special { background: linear-gradient(135deg, #fff8e1, #ffecb3); }
.world-card .lock { font-size: 1.6em; }
.mode-row { display: flex; gap: 10px; margin: 14px 0; }
.mode-row .btn { flex: 1; font-size: 1em; }

/* ---------- ワールドマップ ---------- */
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.stage-node {
  background: var(--paper);
  border: 3px solid var(--dark);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
  font: inherit;
  transition: transform .06s;
  position: relative;
}
.stage-node:active { transform: translateY(3px); }
.stage-node .se { font-size: 1.9em; }
.stage-node .sn { font-size: .78em; font-weight: bold; margin-top: 4px; line-height: 1.3; min-height: 2.1em; }
.stage-node .stars { color: #f9a825; font-size: .9em; letter-spacing: -1px; margin-top: 2px; }
.stage-node .num { position: absolute; top: -8px; left: -6px; background: var(--theme); color: #fff; border: 2px solid var(--dark); border-radius: 50%; width: 24px; height: 24px; font-size: .75em; font-weight: bold; line-height: 20px; }
.stage-node.locked { filter: grayscale(1); opacity: .55; }
.stage-node.boss { background: linear-gradient(135deg, #fce4ec, #f8bbd0); grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left; }
.stage-node.boss .se { font-size: 2.6em; }
.stage-node.boss .sn { font-size: 1em; min-height: 0; }

/* ---------- レッスン ---------- */
.lesson-card {
  background: var(--paper);
  border: 3px solid var(--dark);
  border-radius: 14px;
  padding: 18px 16px;
  min-height: 320px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
  font-size: 1.05em;
  overflow-x: auto;
}
.lesson-nav { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.lesson-nav .dots { flex: 1; text-align: center; color: #fff; text-shadow: 1px 1px 0 #000; letter-spacing: .3em; }

/* ---------- バトル ---------- */
.battle-top {
  background: rgba(62, 39, 35, .85);
  border: 3px solid #271713;
  border-radius: 12px;
  padding: 10px;
  color: #fff;
  margin-bottom: 10px;
}
.enemy-row { display: flex; align-items: center; gap: 12px; }
.enemy-face { font-size: 3em; filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, .4)); transition: transform .1s; }
.enemy-info { flex: 1; }
.enemy-name { font-weight: bold; font-size: .95em; text-shadow: 1px 1px 0 #000; }
.hpbar { height: 16px; background: #4e342e; border: 2px solid #000; border-radius: 8px; overflow: hidden; margin-top: 4px; }
.hpbar i { display: block; height: 100%; background: linear-gradient(#ef5350, #c62828); transition: width .5s; }
.fight-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.hearts { font-size: 1.25em; letter-spacing: 2px; }
.player-face { font-size: 2.1em; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.4)); display: inline-block; transition: transform .15s; }
.combo { font-weight: bold; color: #ffd54f; text-shadow: 1px 1px 0 #000; font-size: .9em; }
.qnum { font-size: .8em; color: #d7ccc8; }

.qcard {
  background: var(--paper);
  border: 3px solid var(--dark);
  border-radius: 14px;
  padding: 16px 14px;
  font-size: 1.25em;
  font-weight: bold;
  text-align: center;
  min-height: 90px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
  margin-bottom: 12px;
  line-height: 1.7;
  overflow-x: auto;
}
.qcard .vis { font-size: 1.15em; line-height: 1.6; margin: 6px 0; font-weight: normal; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.one-col { grid-template-columns: 1fr; }
.choice-btn {
  font: inherit; font-weight: bold; font-size: 1.2em;
  background: var(--paper);
  border: 3px solid var(--dark);
  border-radius: 12px;
  min-height: 64px;
  padding: 10px;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.08), 0 4px 0 rgba(0, 0, 0, .25);
  transition: transform .06s;
  overflow-x: auto;
}
.choice-btn:active { transform: translateY(3px); }
.choice-btn.good { background: #a5d6a7; border-color: #1b5e20; }
.choice-btn.bad { background: #ef9a9a; border-color: #b71c1c; animation: shake .4s; }

/* キーパッド */
.inputline { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.inputbox {
  min-width: 130px; padding: 8px 14px; font-size: 1.7em; font-weight: bold; text-align: center;
  background: #fff; border: 3px solid var(--dark); border-radius: 10px; min-height: 56px;
}
.inputbox.active { border-color: #e65100; background: #fff8e1; box-shadow: 0 0 0 3px rgba(255, 167, 38, .5); }
.inputbox .ph { color: #ccc; }
.unit-label { font-size: 1.2em; font-weight: bold; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kbtn {
  font: inherit; font-size: 1.35em; font-weight: bold;
  background: var(--paper); border: 3px solid var(--dark); border-radius: 10px;
  min-height: 56px; cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.08), 0 4px 0 rgba(0, 0, 0, .25);
}
.kbtn:active { transform: translateY(3px); }
.kbtn.ok { grid-row: span 2; background: #66bb6a; color: #fff; }
.kbtn.del { background: #ffab91; }

/* とけいをあわせる */
.clockset { text-align: center; }
.clockset .cs-time { font-size: 1.5em; font-weight: bold; margin: 6px 0; }
.cs-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }

/* ---------- エフェクト ---------- */
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.shake { animation: shake .45s; }
@keyframes popdmg { 0% { transform: translateY(0) scale(.6); opacity: 0; } 25% { opacity: 1; transform: translateY(-14px) scale(1.25); } 100% { transform: translateY(-46px) scale(1); opacity: 0; } }
.dmg-pop { position: absolute; font-size: 1.6em; font-weight: 900; color: #ffeb3b; text-shadow: 2px 2px 0 #b71c1c; animation: popdmg .8s forwards; pointer-events: none; }
.dmg-pop.smash { font-size: 2.2em; color: #ff5252; text-shadow: 2px 2px 0 #fff; }
@keyframes lunge { 0% { transform: translateX(0); } 40% { transform: translateX(26px) rotate(8deg); } 100% { transform: translateX(0); } }
.lunge { animation: lunge .35s; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .2; } }
.confetti { position: fixed; top: -20px; font-size: 1.3em; animation: fall linear forwards; pointer-events: none; z-index: 99; }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 20, 15, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.panel {
  background: var(--paper);
  border: 4px solid var(--dark);
  border-radius: 16px;
  padding: 20px 16px;
  width: 100%; max-width: 480px;
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .4);
  text-align: center;
  animation: pop-in .25s;
}
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h2 { margin-bottom: 10px; color: var(--dark); }
.panel .explain {
  text-align: left; background: #fff; border: 2px dashed #bcaaa4; border-radius: 10px;
  padding: 12px; margin: 12px 0; line-height: 1.8; font-size: 1.02em; overflow-x: auto;
}
.panel .btn { margin-top: 6px; }
.big-emoji { font-size: 3.2em; margin: 6px 0; }
.stars-big { font-size: 2.4em; letter-spacing: .1em; margin: 8px 0; }
.stars-big .off { opacity: .25; filter: grayscale(1); }
.reward-line { font-weight: bold; font-size: 1.15em; margin: 6px 0; }

/* ---------- サバイバル ---------- */
.surv-top { background: rgba(62,39,35,.85); border: 3px solid #271713; border-radius: 12px; color: #fff; padding: 10px; margin-bottom: 10px; text-align: center; }
.surv-top .alive { font-size: 1.4em; font-weight: 900; color: #ffd54f; text-shadow: 1px 1px 0 #000; }
.surv-dots { line-height: 1.1; font-size: .62em; letter-spacing: 1px; margin-top: 6px; word-break: break-all; opacity: .9; }
.surv-dots .out { opacity: .18; }
.zone-msg { color: #ff8a65; font-weight: bold; margin-top: 4px; font-size: .9em; }

/* ---------- マイきち ---------- */
.base-wrap { background: linear-gradient(#90caf9, #c5e1a5); border: 3px solid var(--dark); border-radius: 14px; padding: 14px 8px 4px; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.base-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 1px; max-width: 480px; margin: 0 auto; }
.base-grid .cell { aspect-ratio: 1; border-radius: 2px; }
.base-grid .cell.empty { background: rgba(255, 255, 255, .18); border: 1px dashed rgba(62, 39, 35, .25); }
.base-caption { text-align: center; font-weight: bold; padding: 8px 0 6px; }
.char-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.char-item { background: var(--paper); border: 3px solid var(--dark); border-radius: 12px; padding: 10px; text-align: center; cursor: pointer; font: inherit; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.char-item .ce { font-size: 2.2em; }
.char-item .cn { font-size: .8em; font-weight: bold; margin-top: 2px; }
.char-item.locked { filter: grayscale(1); opacity: .55; }
.char-item.selected { background: #fff9c4; border-color: #e65100; box-shadow: 0 0 0 3px rgba(255, 152, 0, .5), 0 4px 0 rgba(0,0,0,.25); }

/* ---------- 分数・図 ---------- */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; margin: 0 3px; line-height: 1.15; }
.frac .fn { border-bottom: 2.5px solid currentColor; padding: 0 6px; }
.frac .fd { padding: 0 6px; }
.fwhole { font-size: 1.25em; margin-right: 2px; vertical-align: middle; }
.vis { text-align: center; margin: 8px 0; }
.tenstick { letter-spacing: -2px; }
table.mq { border-collapse: collapse; margin: 8px auto; }
table.mq td, table.mq th { border: 2px solid var(--dark); padding: 4px 10px; font-size: .95em; background: #fff; }
table.mq th { background: #ffe0b2; }

/* ---------- せつめい内の時計ならび ---------- */
.clock-pair { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock-pair .arrow { font-size: 1.6em; font-weight: 900; color: #e65100; }

/* ---------- PC ---------- */
@media (min-width: 700px) {
  #app { max-width: 720px; padding-top: 20px; }
  .choices { gap: 12px; }
  .qcard { font-size: 1.4em; }
}
