/* ===== 学年カラー変数（デフォルト：ログイン前） ===== */
:root {
  --grade-bg:    #5a3e2b;
  --grade-light: #f5ede0;
  --grade-text:  #fff;
}

/* ===== リセット・ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: #f5f1eb;
  color: #3a2e25;
  min-height: 100vh;
}

/* ===== ルビ ===== */
ruby { ruby-align: center; }
rt {
  font-size: 0.55em;
  color: inherit;
  opacity: 0.75;
  letter-spacing: 0.02em;
}

/* ===== レイアウト ===== */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.main { flex: 1; max-width: 480px; margin: 0 auto; width: 100%; padding: 16px 12px 80px; }

/* ===== ナビバー ===== */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #5a3e2b; color: #fff;
  padding: 12px 16px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-brand { font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav-btn {
  background: transparent; border: none; color: #fff;
  padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: .8rem;
}
.nav-btn.active { background: rgba(255,255,255,.25); font-weight: 700; }
.nav-btn:hover { background: rgba(255,255,255,.15); }
.nav-btn.logout { color: #ffc; }

/* ===== ログイン ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #5a3e2b; padding: 16px;
}
.login-card {
  background: #fff8f0; border-radius: 16px;
  padding: 32px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
}
.logo-area { text-align: center; margin-bottom: 24px; }
.login-logo { width: 100%; max-width: 280px; height: auto; margin-bottom: 4px; }
.logo-sub { font-size: .8rem; color: #888; margin-top: 4px; }
.google-hint {
  text-align: center; font-size: .75rem; color: #999;
  background: #f0f0f0; border-radius: 6px; padding: 6px; margin-bottom: 16px;
}

/* ===== カード ===== */
.card {
  background: #fff; border-radius: 12px; padding: 16px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; color: #5a3e2b; }

/* ===== フォーム ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: #555; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 12px; border: 1.5px solid #ddd;
  border-radius: 8px; font-size: 1rem; background: #fff;
  appearance: none;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #c97c2e; box-shadow: 0 0 0 3px rgba(201,124,46,.15);
}

/* ===== ボタン ===== */
.btn-primary {
  background: #c97c2e; color: #fff; border: none;
  padding: 12px 20px; border-radius: 8px; font-size: 1rem;
  font-weight: 700; cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: #a8631f; }
.btn-ghost {
  background: transparent; color: #888; border: 1.5px solid #ddd;
  padding: 10px 20px; border-radius: 8px; font-size: .9rem; cursor: pointer;
  margin-top: 8px; transition: border-color .2s;
}
.btn-ghost:hover { border-color: #aaa; }
.btn-small {
  background: #e8f0fe; color: #3367d6; border: none;
  padding: 4px 10px; border-radius: 6px; font-size: .78rem; cursor: pointer;
}
.full { display: block; width: 100%; text-align: center; }

/* ===== ウェルカム・アクション ===== */
.welcome { margin-bottom: 12px; }
.user-badge {
  display: inline-block; background: #5a3e2b; color: #fff;
  padding: 6px 14px; border-radius: 20px; font-weight: 700; margin-bottom: 8px;
}
.time-ok { background: #e6f4ea; color: #2d7a47; border-radius: 8px; padding: 8px 12px; font-size: .85rem; }
.time-ng { background: #fff3e0; color: #e65100; border-radius: 8px; padding: 8px 12px; font-size: .85rem; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn {
  background: #fff; border: 1.5px solid #e0d5c5; border-radius: 12px;
  padding: 18px 8px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer; font-size: .9rem; font-weight: 600;
  transition: box-shadow .2s, transform .1s;
}
.action-btn:hover { box-shadow: 0 2px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.action-btn.accent { border-color: #c97c2e; color: #c97c2e; }
.action-icon { font-size: 1.8rem; }

/* ===== ユーザー情報カード ===== */
.user-info-card { background: #f9f4ec; }
.user-info-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: .9rem; }
.user-info-row .label { color: #888; }
.user-info-row .value { font-weight: 600; }

/* ===== テーブル ===== */
.mini-table, .data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mini-table th, .mini-table td,
.data-table th, .data-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid #f0e8dc;
}
.mini-table th, .data-table th { font-size: .78rem; color: #888; font-weight: 600; }
.my-row { background: #fff8e1; font-weight: 700; }
.rank-col { font-weight: 700; color: #c97c2e; width: 40px; }

/* ===== ランキング ===== */
.page-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; color: #5a3e2b; }
.tab-wrap { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-btn {
  flex: 1; padding: 8px; border: 1.5px solid #ddd; border-radius: 8px;
  background: #fff; font-size: .85rem; cursor: pointer;
}
.tab-btn.active { background: var(--grade-bg); color: var(--grade-text); border-color: var(--grade-bg); font-weight: 700; }
.ev-title { font-size: 1rem; font-weight: 700; color: #5a3e2b; margin-bottom: 10px; }
.empty { color: #aaa; font-size: .9rem; padding: 8px 0; }

/* ===== バッジ ===== */
.badge-edited {
  display: inline-block; background: #e3f2fd; color: #1565c0;
  font-size: .7rem; padding: 1px 6px; border-radius: 10px; margin-left: 4px;
}
.badge-offtime {
  display: inline-block; background: #fce4ec; color: #c62828;
  font-size: .7rem; padding: 1px 6px; border-radius: 10px; margin-left: 4px;
}

/* ===== アラート ===== */
.alert-banner {
  background: #fff3e0; border-left: 4px solid #e65100;
  padding: 10px 14px; border-radius: 8px; font-size: .85rem;
  margin-bottom: 12px; line-height: 1.6;
}
.alert-banner.info { background: #e3f2fd; border-color: #1565c0; }
.alert-banner.demo {
  background: #f3f0ff; border-color: #7c4dff;
  color: #4a148c; opacity: .8;
}
.demo-label {
  display: inline-block; background: #7c4dff; color: #fff;
  font-size: .7rem; font-weight: 700; padding: 1px 7px;
  border-radius: 8px; margin-right: 6px; vertical-align: middle;
}

/* ===== トースト ===== */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: .9rem; opacity: 0; transition: opacity .3s, transform .3s; z-index: 999;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 先生確認モーダル ===== */
#confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
#confirm-overlay.hidden { display: none; }
.confirm-box {
  background: #fff; border-radius: 20px; padding: 32px 24px;
  text-align: center; max-width: 300px; width: 90%;
  animation: popIn .3s cubic-bezier(.175,.885,.32,1.275);
}
.confirm-icon  { font-size: 3rem; margin-bottom: 8px; }
.confirm-title { font-size: 1.2rem; font-weight: 700; color: #3a2e25; margin-bottom: 8px; }
.confirm-msg   { font-size: .88rem; color: #666; line-height: 1.7; margin-bottom: 20px; }
.confirm-btns  { display: flex; gap: 8px; }
.confirm-btns .btn-ghost    { flex: 1; }
.confirm-btns .btn-primary  { flex: 2; font-size: .88rem; }

/* ===== 自己ベストオーバーレイ ===== */
#best-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
#best-overlay.hidden { display: none; }
.best-box {
  background: #fff; border-radius: 20px; padding: 40px 32px;
  text-align: center; max-width: 280px; width: 90%;
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes popIn {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.best-emoji { font-size: 4rem; margin-bottom: 8px; }
.best-title { font-size: 1.4rem; font-weight: 700; color: #c97c2e; margin-bottom: 8px; }
.best-score { font-size: 2rem; font-weight: 700; margin-bottom: 20px; }
.best-box button {
  background: #c97c2e; color: #fff; border: none;
  padding: 10px 32px; border-radius: 8px; font-size: 1rem; cursor: pointer;
}

/* ===== 順位ポップアップ ===== */
#rank-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1001;
}
#rank-overlay.hidden { display: none; }
.rank-box {
  background: #fff; border-radius: 20px; padding: 40px 32px;
  text-align: center; max-width: 280px; width: 90%;
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275);
}
.rank-medal   { font-size: 4rem; margin-bottom: 6px; }
.rank-scope   { font-size: 1rem; font-weight: 700; color: #888; margin-bottom: 2px; }
.rank-num-big { font-size: 2.6rem; font-weight: 900; color: #2b4a6b; margin-bottom: 8px; }
.rank-detail  { font-size: .88rem; color: #666; margin-bottom: 20px; }
.rank-box button {
  background: #2b4a6b; color: #fff; border: none;
  padding: 10px 32px; border-radius: 8px; font-size: 1rem; cursor: pointer;
}

/* ===== 教師バッジ ===== */
.student-badge { background: #5a3e2b; }
.teacher-badge { background: #2b4a6b; }

/* ===== 長なわ入力 ===== */
.team-card { border-left: 4px solid #2b4a6b; }
.team-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.team-label { font-weight: 700; color: #2b4a6b; }
.team-size-badge {
  font-size: .8rem; color: #555;
  background: #eef3f8; padding: 3px 8px; border-radius: 8px;
}
.cat-inline { color: #2e7d32; font-weight: 700; }
.btn-remove {
  background: #fce4ec; color: #c62828; border: none;
  padding: 3px 10px; border-radius: 6px; font-size: .78rem; cursor: pointer;
}
.cat-badge {
  display: inline-block; margin-top: 6px;
  background: #e8f5e9; color: #2e7d32;
  padding: 3px 10px; border-radius: 10px; font-size: .78rem; font-weight: 600;
}
.cat-badge.empty { background: #f5f5f5; color: #aaa; }

/* ===== 長なわ ランキング ===== */
.team-count {
  font-size: .75rem; color: #888;
  background: #f0f0f0; padding: 2px 6px; border-radius: 8px; margin-left: 4px;
}
.best-display { text-align: center; padding: 8px 0; }
.best-num { font-size: 2.4rem; font-weight: 700; color: #2b4a6b; }
.best-unit { font-size: 1rem; color: #888; margin-left: 4px; }
.best-none { color: #aaa; font-size: .9rem; }

/* ===== サブタブ ===== */
.sub-tab-wrap { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.sub-tab {
  flex: 1; text-align: center;
  padding: 6px 12px; border: 1.5px solid #ddd; border-radius: 8px;
  background: #fff; font-size: .8rem; cursor: pointer;
}
.sub-tab.active { background: var(--grade-bg); color: var(--grade-text); border-color: var(--grade-bg); font-weight: 700; }

/* ===== フィルターブロック ===== */
.filter-block { margin-bottom: 10px; }
.filter-label {
  font-size: .75rem; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 5px;
}

/* ===== 回数カテゴリ表示 ===== */
.range-section { margin-bottom: 14px; }
.range-section:last-child { margin-bottom: 0; }
.range-section-title {
  font-size: .78rem; font-weight: 700; color: #5a3e2b;
  background: #f5efe6; padding: 3px 8px; border-radius: 6px;
  display: inline-block; margin-bottom: 6px;
}
.range-badge-title {
  font-size: .8rem; font-weight: 600; color: #888;
  background: #f0f0f0; padding: 2px 8px; border-radius: 8px; margin-left: 6px;
}
.range-chip {
  display: inline-block; background: #e8f5e9; color: #2e7d32;
  font-size: .72rem; padding: 2px 7px; border-radius: 8px;
}

/* ===== 学年カラーバッジ ===== */
.grade-chip {
  display: inline-block;
  padding: 2px 8px; border-radius: 10px;
  font-size: .78rem; font-weight: 700;
  vertical-align: middle; margin-right: 2px;
}

/* ===== 削除済バッジ・行 ===== */
.badge-deleted {
  display: inline-block; background: #ffebee; color: #c62828;
  font-size: .7rem; padding: 1px 6px; border-radius: 10px; margin-left: 4px;
}
.row-deleted td { color: #bbb; text-decoration: line-through; }
.row-deleted td:last-child { text-decoration: none; }

/* ===== 管理画面 ===== */
.admin-note {
  font-size: .82rem; color: #888; margin-bottom: 12px;
  padding: 8px 12px; background: #f5f5f5; border-radius: 8px;
}
.admin-table th, .admin-table td { padding: 8px 10px; font-size: .85rem; }
.btn-del {
  background: #ffebee; color: #c62828;
  border: none; padding: 4px 10px; border-radius: 6px; font-size: .78rem; cursor: pointer;
  margin-left: 4px;
}
.btn-log {
  background: #f3e5f5; color: #6a1b9a;
  border: none; padding: 4px 10px; border-radius: 6px; font-size: .78rem; cursor: pointer;
}

/* ===== 履歴ログ ===== */
.log-row {
  padding: 10px 0; border-bottom: 1px solid #f0e8dc;
  display: flex; flex-direction: column; gap: 2px; font-size: .88rem;
}
.log-row:last-child { border-bottom: none; }
.log-row-del { color: #c62828; }
.log-time { font-size: .75rem; color: #999; }

/* ===== その他 ===== */
.empty-cell { text-align: center; color: #999; padding: 16px; }
.value.small { font-size: .8rem; }

