* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #030304;
  --card: #16161a;
  --card-2: #1e1e23;
  --card-soft: #101013;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(212, 175, 55, 0.35);
  --gold: #d9b654;
  --gold-2: #f3d98a;
  --gold-dim: rgba(217, 182, 84, 0.16);
  --text: #f3f1ec;
  --text-dim: #97959c;
  --text-faint: #5f5d64;
  --good: #59d38c;
  --warn: #f0b955;
  --bad: #ef6a6a;
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
}

html, body {
  height: 100%;
  background: #000;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(217, 182, 84, 0.25); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  background: radial-gradient(circle at 50% -10%, #1c1a14 0%, #050505 42%, #020202 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 480px) {
  body { padding: 26px 0; }
  .app-shell {
    min-height: 860px;
    height: 860px;
    margin: 0 auto;
    border-radius: 40px;
    box-shadow:
      0 40px 90px rgba(0, 0, 0, 0.75),
      0 0 0 9px #0b0a08,
      0 0 0 10px rgba(217, 182, 84, 0.3),
      0 0 60px rgba(217, 182, 84, 0.05);
  }
}

.screen { width: 100%; height: 100%; }
[hidden] { display: none !important; }

/* ---------- Registration ---------- */
.register-screen {
  overflow-y: auto;
  padding: 34px 22px 40px;
  background:
    radial-gradient(circle at 20% 0%, rgba(217, 182, 84, 0.14), transparent 55%),
    radial-gradient(circle at 100% 30%, rgba(217, 182, 84, 0.08), transparent 45%);
}

.brand { text-align: center; margin-bottom: 26px; }
.brand-mark {
  width: 58px; height: 58px; margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-2), #a9822f);
  color: #1a1608;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(217, 182, 84, 0.35);
}
.brand h1 {
  font-size: 26px; letter-spacing: 6px; font-weight: 700;
  background: linear-gradient(120deg, var(--gold-2), var(--gold), #b89544);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .tagline { color: var(--text-dim); font-size: 12.5px; margin-top: 6px; letter-spacing: 0.5px; }

.register-card { max-width: 360px; margin: 0 auto; }

.avatar-picker { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; gap: 14px; }
.avatar-preview {
  position: relative;
  width: 92px; height: 92px; border-radius: 50%;
  background: var(--card);
  border: 2px dashed rgba(217, 182, 84, 0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 40px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.avatar-preview:hover { border-color: var(--gold); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-edit-badge {
  position: absolute; right: -2px; bottom: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); color: #1a1608;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; border: 3px solid #050505;
}

.preset-avatars { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.preset-chip {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.preset-chip:hover { transform: translateY(-2px); }
.preset-chip.selected { border-color: var(--gold); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 7px; letter-spacing: 0.4px; }
.field input[type="text"], .field select {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); font-size: 14.5px; outline: none;
  transition: border-color 0.15s ease;
}
.field input[type="text"]:focus, .field select:focus { border-color: var(--border-strong); }
.field select { appearance: none; -webkit-appearance: none; }

.team-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.toggle-btn {
  flex: 1; padding: 9px 6px; font-size: 12px; text-align: center;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card-soft); color: var(--text-dim); cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-btn.active { background: var(--gold-dim); border-color: var(--border-strong); color: var(--gold-2); }

.btn-primary {
  width: 100%; padding: 15px; margin-top: 8px;
  border: none; border-radius: 999px; cursor: pointer;
  background: linear-gradient(120deg, var(--gold-2), var(--gold) 55%, #a9822f);
  color: #1a1608; font-weight: 700; font-size: 15px; letter-spacing: 1px;
  box-shadow: 0 10px 26px rgba(217, 182, 84, 0.25);
  transition: transform 0.12s ease;
}
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 12.5px; cursor: pointer;
}
.btn-danger {
  padding: 12px; width: 100%; border-radius: var(--radius-sm); border: 1px solid rgba(239, 106, 106, 0.35);
  background: rgba(239, 106, 106, 0.08); color: var(--bad); font-size: 13px; cursor: pointer; font-weight: 600;
}

/* ---------- App shell ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(217, 182, 84, 0.05), transparent);
}
.app-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 2px; font-size: 15px; }
.app-logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, var(--gold-2), #a9822f);
  color: #1a1608; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
}
.app-logo span { background: linear-gradient(120deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.header-date { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; letter-spacing: 0.5px; }

.self-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.self-chip .chip-name { font-size: 12.5px; text-align: right; line-height: 1.3; }
.self-chip .chip-name b { display: block; font-size: 13px; }
.self-chip .chip-name small { color: var(--text-dim); }

.app-main { flex: 1; overflow-y: auto; padding: 14px 14px 90px; }
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 10.5px; padding: 6px 2px; border-radius: 12px; transition: color 0.15s ease;
}
.nav-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-btn.active { color: var(--gold-2); }
.nav-btn.active svg { filter: drop-shadow(0 0 6px rgba(217, 182, 84, 0.5)); }

/* ---------- Section header / summary strip ---------- */
.section-title { font-size: 13.5px; font-weight: 700; letter-spacing: 1px; color: var(--text-dim); margin: 4px 2px 10px; text-transform: uppercase; }
.summary-strip { display: flex; gap: 8px; margin-bottom: 14px; }
.summary-box {
  flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; text-align: center;
}
.summary-box b { display: block; font-size: 17px; color: var(--gold-2); }
.summary-box span { font-size: 10px; color: var(--text-dim); }

/* ---------- Cards (sleep/meal/exercise/team) ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 9px; display: flex; align-items: center; gap: 11px;
  position: relative;
}
.card.you { border-color: var(--border-strong); background: linear-gradient(120deg, rgba(217, 182, 84, 0.09), var(--card) 60%); }

.avatar-ring {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  padding: 2.5px;
  background: conic-gradient(var(--ring-color, var(--good)) calc(var(--score, 70) * 1%), rgba(255, 255, 255, 0.08) 0);
}
.avatar-ring.lg { width: 74px; height: 74px; padding: 4px; }
.avatar-inner {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  border: 2px solid #0d0d0f; display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: var(--bg-fallback, #26232a);
}
.avatar-ring.lg .avatar-inner { font-size: 30px; }
.avatar-inner img { width: 100%; height: 100%; object-fit: cover; }

.card-body { flex: 1; min-width: 0; }
.card-name-row { display: flex; align-items: center; gap: 6px; }
.card-name { font-size: 13.5px; font-weight: 700; }
.you-badge { font-size: 8.5px; background: var(--gold-dim); color: var(--gold-2); padding: 2px 6px; border-radius: 999px; letter-spacing: 0.5px; }
.team-tag { font-size: 10px; color: var(--text-dim); }
.card-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

.card-right { text-align: right; flex-shrink: 0; }
.big-num { font-size: 19px; font-weight: 700; color: var(--gold-2); line-height: 1; }
.big-num small { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.pill { display: inline-block; font-size: 9.5px; padding: 2px 8px; border-radius: 999px; margin-top: 4px; }
.pill.good { background: rgba(89, 211, 140, 0.14); color: var(--good); }
.pill.warn { background: rgba(240, 185, 85, 0.14); color: var(--warn); }
.pill.bad { background: rgba(239, 106, 106, 0.14); color: var(--bad); }

.bar-track { height: 4px; background: rgba(255, 255, 255, 0.06); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }

/* ---------- Meal grid ---------- */
.meal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.meal-card.you { border-color: var(--border-strong); }
.meal-photo {
  height: 84px; display: flex; align-items: center; justify-content: center; font-size: 34px;
  position: relative;
}
.meal-photo::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 -18px 20px -10px rgba(0, 0, 0, 0.45); }
.meal-info { padding: 8px 10px 10px; }
.meal-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-sub { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 4px; }
.meal-owner { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.meal-owner span { font-size: 10.5px; color: var(--text-dim); }

/* ---------- Sharehouse slideshow ---------- */
.slideshow { position: relative; border-radius: var(--radius-lg); overflow: hidden; height: 260px; border: 1px solid var(--border); margin-bottom: 12px; }
/* ハウスタブ：ヘッダー/フッター以外は画像のみ。main いっぱいに広げる */
.tab-panel[data-tab="house"].active { display: flex; height: 100%; }
.slideshow.fill { flex: 1; height: 100%; margin-bottom: 0; }
.slide {
  position: absolute; inset: 0; display: flex; align-items: flex-end;
  opacity: 0; transition: opacity 0.9s ease;
  font-size: 54px;
}
.slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slide.active { opacity: 1; }
.slide-icon { position: absolute; top: 20px; left: 20px; font-size: 40px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); }
.slide-caption {
  width: 100%; padding: 18px 18px 16px; font-size: 15px; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.62), transparent);
}
.slide-caption small { display: block; font-size: 10.5px; font-weight: 400; color: rgba(255, 255, 255, 0.75); margin-top: 3px; letter-spacing: 0.5px; }
.slide-dots { position: absolute; top: 14px; right: 16px; display: flex; gap: 5px; }
.slide-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); display: block; cursor: pointer; }
.slide-dots i.active { background: var(--gold-2); width: 16px; border-radius: 4px; transition: width 0.2s ease; }

.house-note { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px; font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.house-note b { color: var(--gold-2); }

/* ---------- Team tab ---------- */
.team-hero {
  background: linear-gradient(135deg, rgba(217, 182, 84, 0.14), var(--card) 70%);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 16px; display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.gauge { position: relative; width: 66px; height: 66px; border-radius: 50%; flex-shrink: 0; }
.gauge svg { transform: rotate(-90deg); }
.gauge-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; }
.team-hero-info h3 { font-size: 15px; letter-spacing: 0.5px; }
.team-hero-info p { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.invite-code { display: inline-block; margin-top: 6px; font-size: 10.5px; padding: 3px 9px; background: rgba(255, 255, 255, 0.06); border-radius: 999px; letter-spacing: 1px; }

.member-row-right { display: flex; align-items: center; gap: 8px; }
.cheer-btn {
  border: 1px solid var(--border); background: var(--card-soft); color: var(--text-dim);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; cursor: pointer; transition: all 0.15s ease;
}
.cheer-btn:active { transform: scale(0.94); background: var(--gold-dim); color: var(--gold-2); }

.settings-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 18px; overflow: hidden; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; padding: 13px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .row-label { display: flex; align-items: center; gap: 9px; }
.settings-row svg { width: 16px; height: 16px; stroke: var(--text-dim); }

.switch { width: 38px; height: 22px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.2s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #cfcfcf; transition: transform 0.2s ease, background 0.2s ease; }
.switch.on { background: var(--gold-dim); }
.switch.on::after { transform: translateX(16px); background: var(--gold-2); }

.settings-actions { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fadeIn 0.2s ease;
}
.modal-sheet {
  width: 100%; background: var(--card-2); border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0; padding: 22px 20px 26px; max-height: 86%; overflow-y: auto;
}
.modal-close { display: flex; justify-content: center; margin-bottom: 14px; }
.modal-close span { width: 38px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
.modal-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.modal-header h3 { font-size: 17px; }
.modal-header p { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.modal-stats { display: flex; gap: 8px; margin: 14px 0; }
.modal-stat { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.modal-stat b { display: block; font-size: 15px; color: var(--gold-2); }
.modal-stat span { font-size: 9.5px; color: var(--text-dim); }
.modal-bio { font-size: 12.5px; color: var(--text-dim); line-height: 1.7; margin-bottom: 6px; }

/* Toast */
.toast {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(20, 19, 16, 0.95); border: 1px solid var(--border-strong); color: var(--gold-2);
  padding: 10px 18px; border-radius: 999px; font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: all 0.25s ease; z-index: 80; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
