/* SSU Live — ssu-soccer-class と同じ配色（slate 基調、白カード、emerald/amber のピル） */
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --fg: #0f172a;
  --card: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --faint: #94a3b8;
  --ink: #1e293b;
  --primary: #0f172a;
  --primary-fg: #ffffff;
  --emerald: #059669;
  --emerald-bg: #d1fae5;
  --emerald-fg: #047857;
  --amber-bg: #fef3c7;
  --amber-fg: #92400e;
  --rose: #e11d48;
  --rose-bg: #ffe4e6;
  --sky-bg: #e0f2fe;
  --sky-fg: #075985;
  --radius: 1rem;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", "Hiragino Sans", "Noto Sans JP", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: var(--fg); }
input::placeholder, textarea::placeholder { color: var(--faint); }

.header {
  position: sticky; top: 0; z-index: 30;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 48rem; margin: 0 auto; padding: 0.75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.brand { font-size: 0.875rem; font-weight: 700; letter-spacing: -0.01em; text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 0.4rem; }
.nav { display: flex; align-items: center; gap: 0.75rem; font-size: 0.75rem; color: var(--muted); }
.nav a, .nav button { color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
.nav a:hover, .nav button:hover { color: var(--fg); }

.wrap { max-width: 48rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.wrap.narrow { max-width: 28rem; }
h1 { font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 0.75rem; font-weight: 700; color: var(--muted); margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; font-weight: 700; margin: 0; }
p { margin: 0.5rem 0 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.xs { font-size: 0.75rem; }
.sm { font-size: 0.875rem; }
.lg { font-size: 1.125rem; }
.b { font-weight: 700; }
.mt1 { margin-top: 0.5rem; } .mt2 { margin-top: 1rem; } .mt3 { margin-top: 1.5rem; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-top: 1rem;
}
.card.dark { background: var(--primary); color: var(--primary-fg); }
.card.dark .muted { color: #cbd5e1; }
.card.compact { padding: 0.75rem 1rem; border-radius: 0.75rem; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.4rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 0.75rem; padding: 0.6rem 1rem; font-size: 0.875rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--primary); color: var(--primary-fg);
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.soft { background: #f1f5f9; color: var(--ink); }
.btn.good { background: var(--emerald); }
.btn.warn { background: #d97706; }
.btn.danger { background: var(--rose); }
.btn.sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; border-radius: 0.6rem; }
.btn.lg { padding: 0.85rem 1.25rem; font-size: 1rem; border-radius: 0.9rem; }
.btn.block { width: 100%; }

.pill {
  display: inline-block; border-radius: 9999px; padding: 0.1rem 0.6rem; font-size: 0.7rem; font-weight: 600;
  background: #f1f5f9; color: var(--muted);
}
.pill.good { background: var(--emerald-bg); color: var(--emerald-fg); }
.pill.live { background: var(--emerald); color: #fff; }
.pill.warn { background: var(--amber-bg); color: var(--amber-fg); }
.pill.bad { background: var(--rose-bg); color: var(--rose); }
.pill.info { background: var(--sky-bg); color: var(--sky-fg); }

label.field { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-top: 0.75rem; }
.input, textarea.input, select.input {
  display: block; width: 100%; margin-top: 0.3rem;
  border: 1px solid var(--line); border-radius: 0.75rem; padding: 0.65rem 0.8rem; font-size: 1rem; background: #fff;
}
.input:focus { outline: 2px solid #0f172a22; border-color: #94a3b8; }
textarea.input { min-height: 5.5rem; resize: vertical; }
.err { color: var(--rose); font-size: 0.8rem; margin-top: 0.5rem; min-height: 1.2em; }
.ok { color: var(--emerald-fg); font-size: 0.8rem; margin-top: 0.5rem; }

/* 選択肢（学生） */
.choices { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.choice {
  display: flex; align-items: center; gap: 0.75rem; text-align: left;
  background: #fff; border: 1.5px solid var(--line); border-radius: 0.9rem; padding: 0.8rem 0.9rem;
  font-size: 1rem; cursor: pointer;
}
.choice .k {
  flex: 0 0 auto; width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: #f1f5f9;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; color: var(--ink);
}
.choice.on { border-color: var(--primary); background: #0f172a; color: #fff; }
.choice.on .k { background: #fff; color: var(--primary); }
.choice.correct { border-color: var(--emerald); background: var(--emerald-bg); color: var(--emerald-fg); }
.choice.wrong { border-color: var(--rose); background: var(--rose-bg); color: var(--rose); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; margin-top: 0.75rem; }
.scale .choice { justify-content: center; padding: 0.9rem 0; font-size: 1.1rem; font-weight: 700; }

/* 集計バー */
.bars { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.bar { position: relative; }
.bar .lbl { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.2rem; gap: 0.5rem; }
.bar .track { height: 0.9rem; background: #f1f5f9; border-radius: 9999px; overflow: hidden; }
.bar .fill { height: 100%; background: #334155; border-radius: 9999px; transition: width 0.4s ease; }
.bar.correct .fill { background: var(--emerald); }
.bar.mine .lbl { font-weight: 700; }

/* リアクション */
.reactions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-top: 0.5rem; }
.react {
  border: 1.5px solid var(--line); background: #fff; border-radius: 0.9rem; padding: 0.7rem 0.3rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem; cursor: pointer; font-size: 0.75rem; font-weight: 600; color: var(--ink);
}
.react .emoji { font-size: 1.5rem; line-height: 1; }
.react:active { transform: scale(0.97); }
.react.sent { border-color: var(--emerald); background: var(--emerald-bg); }
.reaction-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255,255,255,0.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
}
.reaction-bar .inner { max-width: 48rem; margin: 0 auto; }
.pad-bottom { padding-bottom: 8rem; }

/* 教員コンソール */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0.5rem; }
table.tbl th, table.tbl td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.act {
  border: 1px solid var(--line); border-radius: 0.9rem; padding: 0.75rem 0.9rem; background: #fff; margin-top: 0.5rem;
}
.act.open { border-color: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-bg); }
.act .title { font-weight: 700; }
.kind { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.stat { text-align: center; }
.stat .n { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { font-size: 0.7rem; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 0.6rem 1rem; border-radius: 0.75rem; font-size: 0.85rem; z-index: 50;
  box-shadow: 0 8px 24px rgba(15,23,42,0.2); opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 9999px; background: var(--faint); margin-right: 0.35rem; }
.dot.on { background: var(--emerald); }

/* 投影画面 */
body.live { background: #f8fafc; }
.live-wrap { max-width: 100%; padding: 1.25rem 2rem; min-height: 100dvh; display: flex; flex-direction: column; }
.live-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.live-title { font-size: clamp(1.4rem, 2.6vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.live-sub { color: var(--muted); font-size: clamp(0.9rem, 1.4vw, 1.2rem); margin-top: 0.3rem; }
.live-main { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 18rem; gap: 1.5rem; margin-top: 1.25rem; min-height: 0; }
@media (max-width: 900px) { .live-main { grid-template-columns: 1fr; } }
.live-card { background: #fff; border-radius: 1.25rem; box-shadow: var(--shadow); padding: 1.5rem 1.75rem; min-height: 0; display: flex; flex-direction: column; }
.live-q { font-size: clamp(1.5rem, 3vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.live-prompt { color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.3rem); margin-top: 0.4rem; }
.live-body { flex: 1 1 auto; margin-top: 1rem; min-height: 0; position: relative; }
.live-bars .bar .lbl { font-size: clamp(1rem, 1.8vw, 1.5rem); }
.live-bars .bar .track { height: clamp(1.2rem, 2.4vw, 2rem); }
.live-bars .bar .fill { background: #1e293b; }
.live-bars .bar.correct .fill { background: var(--emerald); }
#cloud { width: 100%; height: 100%; min-height: 24rem; }
.cards { display: flex; flex-wrap: wrap; gap: 0.6rem; align-content: flex-start; overflow: hidden; }
.cards .c {
  background: #f1f5f9; border-radius: 0.9rem; padding: 0.6rem 0.9rem; font-size: clamp(1rem, 1.5vw, 1.35rem); max-width: 100%;
  animation: pop 0.35s ease;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.side { display: flex; flex-direction: column; gap: 1rem; }
.side .live-card { padding: 1.1rem 1.25rem; }
.big { font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.qr { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.qr canvas, .qr img { width: 100%; max-width: 12rem; height: auto; border-radius: 0.5rem; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: 0.08em; font-size: 1.4rem; }
.react-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; text-align: center; }
.react-row .n { font-size: 1.5rem; font-weight: 800; }
.react-row .l { font-size: 0.7rem; color: var(--muted); }
.react-row .e { font-size: 1.4rem; }
.live-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 20rem; color: var(--muted); font-size: clamp(1.1rem, 2vw, 1.6rem); text-align: center; gap: 0.5rem; }
.ticker { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column-reverse; gap: 0.4rem; pointer-events: none; }
.ticker .t { background: #0f172a; color: #fff; border-radius: 0.75rem; padding: 0.4rem 0.8rem; font-size: 0.95rem; animation: rise 3s ease forwards; box-shadow: 0 6px 20px rgba(15,23,42,0.25); }
@keyframes rise { 0% { opacity: 0; transform: translateY(0.5rem); } 10% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-0.5rem); } }
