@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/MPLUSRounded1c-Regular.subset.woff2") format("woff2");
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/MPLUSRounded1c-Bold.subset.woff2") format("woff2");
}

:root {
  --bg: #faf5ed;
  --ink: #493f36;
  --accent: #c9a84c;
  --btn: #dce9d5;
  --btn-ink: #30462e;
  --sub: #e7ddef;
  --sub-ink: #3d2f4a;
  --line: #d8cfc2;
  --iro: #6f57c0;
  --brown: #8a5a3c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: "M PLUS Rounded 1c", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; padding: 14px 16px; }
.screen { min-height: 70vh; }

/* 共通ヘッダー（白い角丸アイコン。左＝ホーム/もどる/やめる、右＝マイク） */
.ir-hd { display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.ir-icon {
  width: 50px; height: 50px; border: 0; border-radius: 15px; background: #fff;
  color: #8a7f70; box-shadow: 0 1px 2px rgba(0,0,0,.1); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.ir-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ir-icon.ir-exit { color: var(--brown); }
/* マイク状態表示。ON/OFF操作は共通 mic-toggle モジュールで提供。 */
.ir-micwrap { width: 50px; height: 50px; border-radius: 50%; background: #ece4d6; display: grid; place-items: center; }
.ir-micwrap .mic { width: 27px; height: 27px; }
.ir-micwrap .mic .body { fill: #b3a892; }
.ir-micwrap .mic .slash { stroke: #d33; stroke-width: 2.4; display: none; }
.ir-micwrap.listening { background: #f2e2a8; }
.ir-micwrap.listening .mic .body { fill: #8a6d1f; }
.ir-micwrap.restarting { background: #f2e2a8; }
.ir-micwrap.restarting .mic .body { fill: #8a6d1f; animation: ir-blink .6s steps(2, end) infinite; }
.ir-micwrap.denied { background: #f0dcd6; }
.ir-micwrap.denied .mic .body { fill: #b98f86; }
.ir-micwrap.denied .mic .slash { display: block; }
@keyframes ir-blink { 50% { opacity: .3; } }

.ir-logo { text-align: center; font-weight: 800; font-size: 40px; letter-spacing: 1px; margin: 22px 0 6px; }
.ir-logo .a { color: var(--iro); }
.ir-logo .b { color: var(--brown); }
.ir-intro { font-size: 15px; color: #7a6f62; }
.ir-h2 { font-size: 20px; }
.ir-foot { text-align: center; margin-top: 26px; font-size: 12px; color: #9a8f80; }

.ir-menu { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.ir-sizes { display: grid; grid-template-columns: 1fr 1fr; }
.ir-big {
  font: inherit; font-weight: 700; font-size: 20px;
  padding: 18px; border: 0; border-radius: 20px;
  background: var(--btn); color: var(--btn-ink); min-height: 64px; cursor: pointer;
}
.ir-big.ir-sub { background: var(--sub); color: var(--sub-ink); }
.ir-big[data-go="free"] { background: #f5b18b; color: #542d20; }
.ir-big[data-go="free"]:hover { background: #efa078; }
.ir-big[data-go="free"]:active { background: #e9956b; }
.ir-continue { background: var(--accent); color: #332600; }

.ir-msg { min-height: 1.4em; font-weight: 700; color: #6b5f52; margin: 6px 2px; }

/* 盤面（四辺に列名A〜/行名1〜。角＋ヘッダー＋セルを1グリッドで） */
.ir-board {
  --n: 5; --hdr: 18px;
  display: grid;
  grid-template-columns: var(--hdr) repeat(var(--n), 1fr) var(--hdr);
  grid-template-rows: var(--hdr) repeat(var(--n), 1fr) var(--hdr);
  gap: 3px;
  width: min(86vw, 380px);
  aspect-ratio: 1 / 1;
  margin: 4px auto 10px;
  background: #cfc4b2;
  padding: 3px;
  border-radius: 12px;
}
.ir-hdr { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #8a7f70; user-select: none; }
.ir-hdr.is-cur { color: #b8862a; }
.ir-cell { border-radius: 4px; background: #efe7d8; position: relative; cursor: pointer; }
.ir-cell.ir-empty { background: repeating-linear-gradient(45deg, #efe7d8, #efe7d8 6px, #e7ddc9 6px, #e7ddc9 12px); }
.ir-cell.ir-preview::after {
  content: ""; position: absolute; inset: 0; border-radius: 4px;
  background: var(--preview); opacity: .55;
  outline: 3px dashed rgba(0,0,0,.35); outline-offset: -3px;
}
.ir-cell.ir-cursor { outline: 3px solid var(--accent); outline-offset: -1px; z-index: 1; }

.ir-confirm {
  display: block; width: min(86vw, 380px); margin: 0 auto 10px;
  background: var(--accent); color: #332600; padding: 11px; min-height: 48px; font-size: 17px;
  font-weight: 700; border: 0; border-radius: 16px; cursor: pointer;
}
.ir-confirm:disabled { opacity: .4; }

/* ツール（セグメント）＋保存 */
.ir-toolrow { display: flex; align-items: center; gap: 8px; max-width: 440px; margin: 0 auto; }
.ir-seg { display: flex; flex: 1; background: #e7ddc9; border-radius: 14px; padding: 3px; }
.ir-tool { flex: 1; font: inherit; font-weight: 700; font-size: 14px; border: 0; background: transparent; color: #7a6f5c; padding: 10px 0; border-radius: 11px; cursor: pointer; }
.ir-tool.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.ir-save { font: inherit; font-weight: 700; font-size: 15px; border: 0; border-radius: 14px; background: var(--accent); color: #332600; padding: 11px 16px; min-height: 46px; cursor: pointer; }

/* パレット見出し＋操作（けす・もどす・やりなおし・よみあげ） */
.ir-palhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; max-width: 440px; margin: 10px auto 0; }
.ir-pl { font-size: 12px; font-weight: 700; color: #8a7f70; flex: 0 0 auto; }
.ir-palctrls { display: flex; align-items: center; gap: 6px; }
.ir-pc { font: inherit; font-weight: 700; font-size: 12px; border: 0; border-radius: 10px; background: #efe7d8; color: #6b5f52; padding: 6px 8px; min-height: 38px; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.ir-pc svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ir-pc:disabled { opacity: .35; }
.ir-pc#btn-erase.is-sel { background: var(--accent); color: #332600; }
.ir-ytoggle { font: inherit; font-size: 12px; font-weight: 700; border: 0; border-radius: 10px; background: #efe7d8; color: #7a6f5c; padding: 6px 10px; min-height: 38px; cursor: pointer; }
.ir-ytoggle.is-active { background: var(--accent); color: #332600; }
/* 消しゴムのプレビュー（下地＋破線） */
.ir-cell.ir-preview-erase::after { content: ""; position: absolute; inset: 0; border-radius: 4px; background: repeating-linear-gradient(45deg, #efe7d8, #efe7d8 5px, #e0d6c2 5px, #e0d6c2 10px); outline: 3px dashed rgba(0,0,0,.4); outline-offset: -3px; }

/* パレット（6列×2段） */
.ir-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-width: 440px; margin: 6px auto 0; }
.ir-swatch { font: inherit; border: 0; background: transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; }
.ir-swatch .ir-chip { width: 100%; aspect-ratio: 1 / 1; border-radius: 8px; background: var(--sw); border: 2px solid rgba(0,0,0,.12); }
.ir-swatch .ir-cname { font-size: 10px; line-height: 1.1; color: var(--ink); }
.ir-swatch.is-sel { background: #fff5d6; outline: 2px solid var(--accent); }
.ir-swatch.is-sel .ir-chip { transform: scale(1.06); }

/* 一覧 */
.ir-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.ir-card { background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ir-thumb-btn { border: 0; background: transparent; padding: 0; width: 100%; cursor: pointer; }
.ir-thumb { width: 100%; aspect-ratio: 1 / 1; image-rendering: pixelated; background: #efe7d8; border-radius: 10px; display: block; }
.ir-card-meta { text-align: center; font-weight: 700; margin: 6px 0; }
.ir-card-acts { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.ir-mini { font: inherit; font-weight: 700; border: 0; border-radius: 12px; background: var(--btn); color: var(--btn-ink); padding: 8px 10px; min-height: 40px; font-size: 13px; cursor: pointer; }
.ir-mini.ir-del { background: #f3d9d6; color: #7a3a34; }
.ir-empty-note { color: #7a6f62; }

/* 完成プレビュー */
.ir-preview-wrap { margin-top: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #6b7f8c, #8a99a3); border-radius: 16px; padding: 18px; }
.ir-preview-canvas { width: min(84vw, 420px); aspect-ratio: 1 / 1; image-rendering: pixelated; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }

/* コエキット共通の文字ロゴと、必要なときに読み返す制作ガイド。 */
.ir-logo img { display: block; width: min(100%, 370px); height: auto; margin: auto; }
.ir-logo + .ir-intro { text-align: center; }
.ir-hd .ir-micwrap { margin-left: auto; margin-right: 10px; }
.ir-help-open { font-family: inherit; font-size: 24px; font-weight: 700; color: var(--brown); }
.ir-big:disabled { opacity: .55; cursor: default; }
.ir-big small { display: block; font-size: 12px; font-weight: 400; }
button:focus-visible, a:focus-visible { outline: 3px solid #8a5a3c; outline-offset: 3px; }
.ir-help { width: min(480px, calc(100% - 24px)); max-height: calc(100svh - 24px); padding: 22px; border: 0; border-radius: 28px; color: var(--ink); background: #fffcf7; box-shadow: 0 20px 80px #493f3638; }
.ir-help::backdrop { background: #493f3666; backdrop-filter: blur(5px); }
.ir-help-head { display: flex; align-items: center; gap: 8px; }
.ir-help h2 { font-size: 17px; margin: 0; flex: 1; }
.ir-help-close { width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 14px; background: #f2e9df; color: var(--ink); font: 26px/1 system-ui; }
.ir-help-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 12px 0 18px; }
.ir-help-tabs button { font: inherit; font-size: 13px; font-weight: 700; line-height: 1.4; min-height: 44px; padding: 6px 2px; border: 0; border-radius: 12px; color: #786b5d; background: #f2e9df; }
.ir-help-tabs button[aria-pressed="true"] { background: #dce9d5; color: #30462e; box-shadow: inset 0 -3px #94af88; }
.ir-help h3 { font-size: 17px; line-height: 1.6; margin: 12px 0; }
.ir-help p { font-size: 14px; line-height: 1.75; margin: 12px 0; }
.ir-help ol { padding-left: 28px; font-size: 17px; line-height: 2; }
.ir-help strong { color: #8a5a3c; }
.ir-help-pixels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 80px; margin: 0 auto; }
.ir-help-pixels i { aspect-ratio: 1; background: #ecdccd; border-radius: 5px; }
.ir-help-pixels i:nth-child(2n) { background: #cf977f; }
.ir-help-words, .ir-help-sequence { display: grid; grid-template-columns: max-content 1fr; align-items: center; gap: 10px; padding: 16px; border-radius: 18px; background: #f4ece2; font-size: 14px; }
.ir-help-words strong, .ir-help-sequence strong { font-size: 18px; }
.ir-help-phrase { text-align: center; padding: 12px 6px; background: #f4ece2; border-radius: 14px; font-size: 15px; }
.ir-help-readings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; font-size: 14px; }
.ir-help-readings b { display: inline-block; color: #8a5a3c; width: 20px; }
.ir-help-readings span:nth-child(1), .ir-help-readings span:nth-child(4), .ir-help-readings span:nth-child(8) { background: #f4e5d6; border-radius: 6px; font-weight: 700; }
#tutorial-status { flex: 1; min-width: 0; margin: 0 6px; text-align: center; font-size: 14px; line-height: 21px; font-weight: 700; color: #8a5a3c; }
#tutorial-status span, #tutorial-status strong { display: block; }
#tutorial-status span:first-child { color: #704b34; }
@media (max-width: 375px) {
  #tutorial-status { margin: 0 2px; }
  [data-screen="make"] .ir-icon { width: 44px; height: 44px; }
  [data-screen="make"] .ir-micwrap { width: 28px; height: 34px; }
}
/* 練習の目標は既存メッセージ欄の高さを利用。状態通知は読み上げ用に保持。 */
#tutorial-goal { margin: 6px 2px; min-height: 25.6px; font-size: 16px; line-height: 25.6px; font-weight: 700; text-align: center; color: #704b34; background: #f1e4d4; border-radius: 8px; }
.ir-practice-msg { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[data-screen="make"] .ir-icon, [data-screen="make"] .ir-micwrap { flex-shrink: 0; }
.ir-tutorial-dialog #tutorial-progress { flex: 1; font-size: 13px; font-weight: 700; color: #8a5a3c; }
.ir-tutorial-dialog #tutorial-heading { font-size: 18px; line-height: 1.6; margin: 12px 0; }
.ir-tutorial-dialog ol { margin: 10px 0; font-size: 16px; line-height: 1.9; }
.ir-tutorial-words { display: flex; flex-wrap: wrap; gap: 6px; }
.ir-tutorial-words span { background: #f1e4d4; color: #704b34; border-radius: 9px; padding: 5px 8px; font-size: 15px; font-weight: 700; }
.ir-tutorial-dialog .ir-tutorial-tip { font-weight: 700; color: #745b42; }
.ir-tutorial-dialog .ir-tutorial-voice { text-align: center; font-size: 12px; margin: 8px 0; }
.ir-tutorial-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.ir-tutorial-actions button { font-size: 12px; min-height: 44px; }
@media (max-height: 680px), (max-width: 350px) {
  .ir-tutorial-dialog #tutorial-heading { font-size: 16px; margin: 8px 0; }
  .ir-tutorial-dialog ol { font-size: 15px; }
}
.ir-cell.ir-tutorial-target { box-shadow: inset 0 0 0 2px #8a5a3c; }
.ir-help .ir-help-note { color: #766958; font-size: 13px; }
.ir-help-done { display: block; width: 100%; min-height: 58px; border: 0; border-radius: 18px; font: inherit; font-weight: 700; color: #30462e; background: #dce9d5; margin-top: 16px; }
@media (max-height: 680px), (max-width: 350px) {
  .ir-help { padding: 14px; }
  .ir-help h2 { font-size: 15px; }
  .ir-help h3 { font-size: 15px; margin: 8px 0; }
  .ir-help-tabs { margin: 8px 0 12px; }
  .ir-help p { font-size: 13px; margin: 6px 0; line-height: 1.6; }
  .ir-help-phrase { font-size: 13px; padding: 8px 4px; }
  .ir-help-words, .ir-help-sequence { padding: 10px; gap: 8px; font-size: 12px; }
  .ir-help-words strong, .ir-help-sequence strong { font-size: 15px; }
  .ir-help-done { margin-top: 10px; min-height: 52px; }
}

/* ドットの形から選べる見本棚。完成見本と作画データは分離する。 */
.ir-template-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ir-template-filters button { min-height: 44px; padding: 6px 12px; }
.ir-template-filters [aria-pressed="true"] { background: #dce9d5; color: #30462e; box-shadow: inset 0 -3px #94af88; }
.ir-template-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.ir-template-choice { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; border: 1px solid #e6d9c8; border-radius: 22px; padding: 18px 12px 12px; background: #fffaf2; color: var(--ink); cursor: pointer; }
.ir-template-choice strong { font-size: 16px; }
.ir-template-choice > span { font-size: 12px; color: #786b5d; }
.ir-template-picture { display: block; width: min(100%, 180px); aspect-ratio: 1; image-rendering: pixelated; background: #eae1d3; border: 8px solid #eae1d3; }
.ir-template-dialog .ir-template-picture { width: min(52vw, 210px); margin: 8px auto; }
.ir-template-dialog { text-align: center; }
.ir-template-dialog h2 { font-size: 18px; }
.ir-template-dialog #template-guide-toggle { min-height: 44px; }
#template-reference { display: block; width: 100%; font: inherit; font-size: 14px; font-weight: 700; color: #704b34; border: 0; border-radius: 12px; background: #f1e4d4; min-height: 44px; margin: 6px 0; cursor: pointer; }
.ir-template-cell { outline: 1px solid #9b8266; outline-offset: -1px; }
.ir-template-ghost { position: absolute; inset: 3px; border-radius: 2px; opacity: .32; pointer-events: none; }
.ir-cell.ir-preview .ir-template-ghost, .ir-cell.ir-preview-erase .ir-template-ghost { display: none; }

.ir-recipe-tabs { display: flex; gap: 8px; margin: 10px 0; }
.ir-recipe-tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 12px; font: inherit; font-weight: 700; background: #f1e4d4; color: #704b34; }
.ir-recipe-tabs [aria-pressed="true"] { background: #dce9d5; color: #30462e; }
.ir-recipe-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ir-recipe-nav button { min-height: 44px; min-width: 64px; }
.ir-recipe-dialog .ir-template-picture { width: min(28vw, 110px); margin: 6px auto; }
.ir-recipe-dialog #template-caption { font-size: 11px; margin: 4px 0; }
.ir-recipe-dialog #recipe-title { font-size: 16px; line-height: 1.5; margin: 8px 0; }
.ir-recipe-dialog #recipe-tip { font-size: 13px; line-height: 1.5; margin: 8px 0; }
.ir-recipe-dialog .ir-tutorial-words { justify-content: center; }
.ir-recipe-dialog .ir-tutorial-words span { font-size: 13px; padding: 3px 6px; }

.ir-heart-practice { display:flex; align-items:center; gap:16px; width:100%; margin:12px 0 20px; padding:16px; border:2px solid #dcb19b; border-radius:20px; background:#fff0e3; color:#69442f; text-align:left; font:inherit; }
.ir-heart-practice canvas { width:76px; height:76px; flex:none; image-rendering:pixelated; }
.ir-heart-practice span { display:grid; gap:6px; }
.ir-heart-practice strong { font-size:20px; }
.ir-heart-practice small,.ir-heart-practice span span { font-size:13px; line-height:1.5; }

/* 2026-09-20承認：ロゴ上端58px、説明176px、メニュー229px、フッター下8px。 */
#app:has([data-screen="mode"]:not([hidden])) { padding:0 16px; }
[data-screen="mode"] {position:relative;display:flex;flex-direction:column;min-height:100svh;padding:58px 0 max(8px,env(safe-area-inset-bottom));}
[data-screen="mode"] .ir-hd {position:absolute;top:8px;left:0;right:0;}
[data-screen="mode"] .ir-logo {width:min(380px,100%);height:93px;flex-shrink:0;margin:0 auto;line-height:1;}
[data-screen="mode"] .ir-logo img {display:block;width:100%;height:100%;object-fit:contain;object-position:top;}
[data-screen="mode"] .ir-intro {margin:25px 0 29px;text-align:center;line-height:24px;}
[data-screen="mode"] .ir-menu {width:min(420px,100%);margin:0 auto 24px;gap:12px;}
[data-screen="mode"] .ir-big {height:80px;min-height:80px;padding:12px 18px;}
[data-screen="mode"] .ir-foot {margin:auto 0 0;font-size:10px;line-height:14px;}
@media(max-height:779px){
[data-screen="mode"] .ir-logo {height:74px;width:min(300px,100%);}
[data-screen="mode"] .ir-intro {margin:10px 0 16px;}
[data-screen="mode"] .ir-menu {gap:8px;margin-bottom:16px;}
[data-screen="mode"] .ir-big {height:64px;min-height:64px;padding:8px 12px;}
}
@media(max-height:620px){
[data-screen="mode"] .ir-logo {height:56px;width:228px;}
[data-screen="mode"] .ir-intro {margin:8px 0 12px;}
}
