/* ジャイクラAI工房 — 共通(設計図の方眼紙 × ゲームの部品) */
:root {
  --paper: #eef4ff;
  --grid: #d9e5fb;
  --ink: #1d2752;
  --ink-soft: #4a5684;
  --line: #1d2752;
  --card: #ffffff;
  --coin: #ffc83d;        /* 送る・大事なボタン */
  --coin-dark: #e9a800;
  --mint: #12b5a6;        /* できた・OK */
  --mint-soft: #d5f5f1;
  --berry: #ff4fa3;       /* あたらしい！ */
  --berry-soft: #ffe0ef;
  --violet: #7a5cff;      /* AI */
  --violet-soft: #e8e2ff;
  --orange: #ff8a1f;      /* 気をつけて */
  --orange-soft: #ffeed9;
  --red: #e5484d;
  --red-soft: #ffe1e1;
  --shadow: 4px 4px 0 var(--line);
  --shadow-s: 2px 2px 0 var(--line);
  --font: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  --r-l: 22px;
  --r-m: 14px;
  --r-s: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  line-height: 1.6;
  font-size: 16px;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
a { color: var(--violet); }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--line); border-radius: var(--r-s);
  background: var(--card); padding: 8px 14px; font-weight: 700;
  box-shadow: var(--shadow-s); transition: transform .06s, box-shadow .06s;
  min-height: 44px;
}
a.btn { text-decoration: none; color: inherit; }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-s); }
.btn.coin { background: var(--coin); }
.btn.mint { background: var(--mint); color: #fff; }
.btn.violet { background: var(--violet); color: #fff; }
.btn.berry { background: var(--berry); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn.big { font-size: 22px; padding: 12px 26px; border-radius: var(--r-m); box-shadow: var(--shadow); min-height: 60px; }
.btn.big:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--line); }
.btn.s { min-height: 34px; padding: 4px 10px; font-size: 14px; }

.panel {
  background: var(--card); border: 2.5px solid var(--line); border-radius: var(--r-m);
  box-shadow: var(--shadow);
}
.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  border: 2px solid var(--line); padding: 2px 10px; font-size: 14px; font-weight: 700; background: #fff;
  white-space: nowrap;
}
.chip.mint { background: var(--mint-soft); }
.chip.berry { background: var(--berry-soft); }
.chip.violet { background: var(--violet-soft); }
.chip.orange { background: var(--orange-soft); }
.chip.red { background: var(--red-soft); }
.chip.gray { background: #eef0f6; color: var(--ink-soft); border-color: #b8bfd8; }

input[type=text], input[type=password], input[type=number], input[type=url], textarea, select {
  border: 2px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
label.f { display: block; font-weight: 700; margin: 10px 0 4px; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 20px; font-weight: 700; line-height: 1.6; text-align: center;
  z-index: 1000; box-shadow: var(--shadow-s); max-width: calc(100vw - 32px);
}

.modal-back {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(29, 39, 82, .45); z-index: 900;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--r-l); box-shadow: 6px 6px 0 var(--line);
  width: min(880px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 2.5px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; flex: 1; }
.modal-body { padding: 16px; overflow: auto; }

.errpage main { max-width: 520px; margin: 18vh auto; text-align: center; padding: 0 16px; }
.errpage h1 { font-size: 22px; }
.bigemoji { font-size: 64px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* お絵描き(先生と生徒が同じ紙に描く。draw.js) */
.gd-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.gd-colors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gd-c { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .25); padding: 0; }
.gd-c.on { outline: 3px solid var(--violet); outline-offset: 2px; }

.gd-sizes { display: flex; gap: 6px; }
.gd-s { width: 40px; height: 34px; border-radius: 8px; border: 2px solid rgba(0, 0, 0, .25); background: #fff; display: grid; place-items: center; padding: 0; }
.gd-s i { display: block; border-radius: 50%; background: #333; }
.gd-s.on { outline: 3px solid var(--violet); outline-offset: 1px; }
.gd-acts { display: flex; gap: 6px; margin-left: auto; }
.gd-paper { position: relative; aspect-ratio: 4 / 3; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
  max-width: min(100%, calc((100vh - 280px) * 4 / 3)); margin: 0 auto; }
.gd-paper canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.gd-paper .gd-live { touch-action: none; cursor: crosshair; pointer-events: auto; }   /* いちばん上 = いま描いている線(ここで描く) */
.gd-pens { display: flex; flex-wrap: wrap; gap: 4px; }
.gd-t { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 50px; height: 48px;
  border-radius: 10px; border: 2px solid rgba(0, 0, 0, .22); background: #fff; padding: 2px 4px; line-height: 1.15; }
.gd-t span { font-size: 18px; }
.gd-t small { font-size: 10px; font-weight: 700; white-space: nowrap; }
.gd-t small rt { font-size: 7px; }
.gd-t.on { outline: 3px solid var(--violet); outline-offset: 1px; background: #f4f0ff; }
.gd-pick { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .25); display: grid; place-items: center;
  background: conic-gradient(#ff4d4d, #ffd84d, #6bff6b, #4dd2ff, #6b6bff, #ff4dd2, #ff4d4d); cursor: pointer; overflow: hidden; }
.gd-pick input { position: absolute; top: 0; right: 0; bottom: 0; left: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.gd-pick span { font-size: 14px; pointer-events: none; }
.gd-pick.on { outline: 3px solid var(--violet); outline-offset: 2px; }
.gd-note { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }

/* 古い iPad(Safari 14 以前)向け: お絵かきの紙の高さ */
@supports not (aspect-ratio: 1 / 1) { .gd-paper { height: 0; padding-top: 75%; } }
