/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: #fff7ed;
  color: #1c1917;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ─── Header ─────────────────────────────────────── */
header {
  background: #ea580c;
  color: #fff;
  padding: 0 1rem;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(234,88,12,.35);
}
.header-inner { max-width: 820px; width: 100%; margin: 0 auto; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }

/* ─── Main ───────────────────────────────────────── */
main { max-width: 820px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }

/* ─── Hero ───────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 1.5rem; }
.hero-icon { font-size: 3rem; margin-bottom: .5rem; }
.hero h1 { font-size: 1.75rem; font-weight: 800; color: #ea580c; margin-bottom: .5rem; }
.description { color: #57534e; font-size: .95rem; line-height: 1.7; }
.hero-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; margin-top: .85rem; }
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .28rem .75rem;
  background: #ffedd5; color: #9a3412;
  border: 1px solid #fdba74;
  border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}

/* ─── Card ───────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #fed7aa;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(234,88,12,.07);
  margin-bottom: 1rem;
}
.card h2 { font-size: 1.05rem; font-weight: 700; color: #ea580c; margin-bottom: .85rem; }

/* ─── Permission screen ───────────────────────────── */
#permission-screen {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.perm-card {
  background: #fff;
  border: 1.5px solid #fed7aa;
  border-radius: 16px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(234,88,12,.1);
}
.perm-icon { font-size: 3.5rem; margin-bottom: .75rem; }
.perm-card h2 { font-size: 1.15rem; font-weight: 700; color: #1c1917; margin-bottom: .75rem; }
.perm-card p { font-size: .88rem; color: #57534e; line-height: 1.7; margin-bottom: 1.25rem; }
.perm-note { font-size: .75rem !important; color: #a8a29e; margin-top: .75rem; margin-bottom: 0 !important; }

/* ─── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #ea580c; color: #fff;
  border: none; border-radius: 10px;
  padding: .7rem 1.75rem;
  font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .15s, transform .1s;
  box-shadow: 0 4px 12px rgba(234,88,12,.3);
}
.btn-primary:hover { background: #c2410c; transform: scale(1.03); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-stop {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #fff; color: #dc2626;
  border: 2px solid #dc2626; border-radius: 10px;
  padding: .5rem 1.5rem;
  font-size: .92rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.btn-stop:hover { background: #fef2f2; }

.btn-action {
  padding: .42rem .95rem;
  border: 1.5px solid #e7e5e4; border-radius: 8px;
  background: #fff; font-size: .82rem; font-weight: 600;
  color: #57534e; cursor: pointer;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.btn-action:hover { background: #f5f5f4; border-color: #d6d3d1; }
.btn-action.primary { background: #ea580c; color: #fff; border-color: #ea580c; }
.btn-action.primary:hover { background: #c2410c; }

/* ─── dB Panel (dark pro-meter panel) ────────────── */
.db-panel {
  background: linear-gradient(180deg, #111 0%, #0a0a0a 100%);
  border-radius: 16px;
  padding: 1.4rem 1.5rem 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
  border: 1.5px solid #222;
  box-shadow: 0 8px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
  transition: outline .2s;
}

/* Recording indicator */
.rec-row {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  margin-bottom: .6rem;
}
.rec-dot-wrap {
  display: flex; align-items: center; justify-content: center;
}
.rec-dot {
  width: 8px; height: 8px;
  border-radius: 50%; background: #ef4444;
  animation: recBlink 1.2s ease-in-out infinite;
  box-shadow: 0 0 6px #ef4444;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px #ef4444; }
  50%  { opacity: .2; box-shadow: none; }
}
.rec-text {
  font-size: .72rem; font-weight: 700;
  color: #6b7280; letter-spacing: .12em;
  text-transform: uppercase;
}

/* Level label */
.db-level-label {
  font-size: .9rem; font-weight: 700;
  color: #6b7280;
  margin-bottom: .35rem;
  letter-spacing: .06em;
  min-height: 1.3em;
  transition: color .25s;
}

/* dB number */
.db-number-wrap {
  display: flex; align-items: baseline; justify-content: center; gap: .4rem;
  margin-bottom: .9rem;
}
.db-number {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 5.5rem;
  color: #22c55e;
  line-height: 1;
  transition: color .15s, text-shadow .15s;
  font-variant-numeric: tabular-nums;
  min-width: 5ch;
  text-align: right;
}
.db-unit {
  font-family: 'Orbitron', monospace;
  font-weight: 700; font-size: 1.5rem;
  color: #4b5563;
}

/* ─── VU Meter ────────────────────────────────────── */
.vu-meter {
  display: flex; gap: 3px; align-items: flex-end; justify-content: center;
  height: 52px;
  margin: 0 auto .9rem;
  max-width: 520px;
}
.vu-seg {
  flex: 1; border-radius: 2px 2px 1px 1px;
  background: #22c55e;
  opacity: .12;
  transition: opacity .04s;
}
.vu-seg.active { opacity: 1; }
.vu-seg.seg-yellow { background: #f59e0b; }
.vu-seg.seg-orange { background: #f97316; }
.vu-seg.seg-red    { background: #ef4444; }

/* ─── Peak row ────────────────────────────────────── */
.db-peak-row {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
}
.db-peak-label { font-size: .78rem; color: #6b7280; }
.db-peak-val {
  font-family: 'Orbitron', monospace; font-weight: 700;
  color: #fb923c; font-size: .9rem;
  min-width: 6ch;
}
.btn-peak-reset {
  background: transparent; border: 1px solid #333; border-radius: 6px;
  color: #6b7280; font-size: .72rem; padding: .15rem .5rem;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.btn-peak-reset:hover { border-color: #fb923c; color: #fb923c; }

/* ─── Controls ────────────────────────────────────── */
.meter-controls { text-align: center; margin-bottom: 1rem; }

/* ─── Mode tabs ───────────────────────────────────── */
.mode-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.mode-tab {
  flex: 1; padding: .65rem;
  border: 2px solid #e7e5e4; border-radius: 10px;
  background: #fff; font-size: .9rem; font-weight: 700;
  color: #78716c; cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s, background .15s;
}
.mode-tab:hover { border-color: #fb923c; color: #ea580c; }
.mode-tab.active { border-color: #ea580c; color: #ea580c; background: #fff7ed; }

/* ─── Mode panels ─────────────────────────────────── */
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* ─── Level guide ─────────────────────────────────── */
.level-table { display: flex; flex-direction: column; gap: .45rem; }
.level-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .45rem .6rem;
  border-radius: 8px; background: #fafaf9;
}
.level-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--c, #22c55e);
  color: #fff;
  font-size: .73rem; font-weight: 700;
  min-width: 72px; text-align: center;
  flex-shrink: 0;
}
.level-name { font-weight: 700; font-size: .88rem; min-width: 90px; color: #292524; flex-shrink: 0; }
.level-desc { font-size: .8rem; color: #78716c; }
.calib-note { font-size: .75rem; color: #a8a29e; margin-top: .75rem; }

/* ─── Contest overlay ─────────────────────────────── */
.contest-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.contest-overlay-inner { text-align: center; padding: 1rem; }

.contest-count {
  font-family: 'Orbitron', monospace;
  font-size: 8rem; font-weight: 900;
  color: #ea580c; line-height: 1;
  text-shadow: 0 0 60px rgba(234,88,12,.7);
  animation: countPop .7s cubic-bezier(.23,1,.32,1) both;
}
.contest-msg {
  font-size: 1.3rem; font-weight: 700; color: #e5e7eb;
  margin-top: 1.2rem; letter-spacing: .04em;
}
@keyframes countPop {
  0% { transform: scale(2.2); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: scale(1); }
}

/* ─── Contest entry card ─────────────────────────── */
.contest-desc { font-size: .88rem; color: #57534e; margin-bottom: 1rem; line-height: 1.7; }
.field { margin-bottom: .85rem; }
.field-label { display: block; font-size: .82rem; font-weight: 700; color: #44403c; margin-bottom: .4rem; }
.contestant-input {
  width: 100%;
  border: 1.5px solid #e7e5e4; border-radius: 9px;
  padding: .6rem .85rem;
  font-size: .95rem; font-family: inherit; color: #1c1917;
  outline: none; background: #fafaf9;
}
.contestant-input:focus { border-color: #ea580c; background: #fff; }
.btn-contest { width: 100%; justify-content: center; font-size: 1.05rem; padding: .85rem; }

/* ─── Contest result card ────────────────────────── */
.contest-result-card { text-align: center; }
.result-icon { font-size: 3.2rem; margin-bottom: .4rem; }
.result-name { font-size: 1.15rem; font-weight: 700; color: #292524; margin-bottom: .4rem; min-height: 1.5em; }
.result-score-wrap {
  display: flex; align-items: baseline; justify-content: center; gap: .35rem;
  margin-bottom: .35rem;
}
.result-score {
  font-family: 'Orbitron', monospace;
  font-size: 4rem; font-weight: 900; color: #ea580c; line-height: 1;
}
.result-unit { font-family: 'Orbitron', monospace; font-size: 1.2rem; color: #9a3412; }
.result-comment { font-size: 1rem; color: #57534e; margin-bottom: .3rem; }
.result-rank-label { font-size: .92rem; color: #6b7280; margin-bottom: 1rem; min-height: 1.4em; }
.result-actions { display: flex; gap: .5rem; justify-content: center; }

/* ─── Leaderboard ────────────────────────────────── */
.leaderboard-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .85rem;
}
.leaderboard-header h2 { margin-bottom: 0; }
.btn-clear {
  background: transparent; border: 1px solid #e7e5e4; border-radius: 6px;
  color: #78716c; font-size: .75rem; padding: .2rem .65rem;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.btn-clear:hover { border-color: #dc2626; color: #dc2626; }
.leaderboard-empty { color: #a8a29e; font-size: .88rem; text-align: center; padding: 1rem 0; }
.lb-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .4rem; border-bottom: 1px solid #f5f5f4;
}
.lb-row:last-child { border-bottom: none; }
.lb-rank { font-weight: 700; min-width: 2rem; text-align: center; font-size: 1.1rem; flex-shrink: 0; }
.lb-name { flex: 1; font-weight: 600; color: #292524; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score {
  font-family: 'Orbitron', monospace; font-weight: 700;
  color: #ea580c; font-size: .88rem; flex-shrink: 0;
}
.lb-date { font-size: .72rem; color: #a8a29e; flex-shrink: 0; }

/* ─── Amazon ─────────────────────────────────────── */
.amazon-card h2 { margin-bottom: .25rem; }
.amazon-note { font-size: .82rem; color: #a8a29e; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.amazon-item {
  display: block;
  border: 1.5px solid #e7e5e4; border-radius: 10px;
  padding: .9rem; text-decoration: none; color: inherit;
  transition: border-color .2s, box-shadow .2s, transform .1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,.18);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: .35rem; }
.amazon-item-name { font-size: .88rem; font-weight: 700; margin-bottom: .2rem; color: #1c1917; }
.amazon-item-desc { font-size: .76rem; color: #78716c; line-height: 1.5; margin-bottom: .45rem; }
.amazon-item-link { font-size: .78rem; color: #FF9900; font-weight: 700; }
.amazon-notice { font-size: .73rem; color: #a8a29e; margin-top: .3rem; }

/* ─── Tips grid ───────────────────────────────────── */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: .05rem; }
.tip-text strong { display: block; font-size: .9rem; font-weight: 700; color: #292524; margin-bottom: .3rem; }
.tip-text p { font-size: .84rem; color: #57534e; line-height: 1.75; margin: 0; }

/* ─── Scene grid ─────────────────────────────────── */
.scene-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: .75rem; margin-top: .5rem;
}
.scene-item {
  background: #fff7ed; border: 1.5px solid #fed7aa;
  border-radius: 12px; padding: .9rem .85rem;
}
.scene-item .scene-icon { font-size: 1.5rem; margin-bottom: .35rem; }
.scene-item strong { display: block; font-size: .83rem; font-weight: 700; color: #9a3412; margin-bottom: .25rem; }
.scene-item p { font-size: .76rem; color: #78716c; line-height: 1.55; }

/* ─── FAQ ────────────────────────────────────────── */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #ea580c; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }

/* ─── Related tools ──────────────────────────────── */
.related-tools { display: flex; flex-direction: column; gap: .55rem; }
.related-tool-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .9rem;
  border: 1.5px solid #e7e5e4; border-radius: 10px;
  background: #fff; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #ea580c; box-shadow: 0 2px 8px rgba(234,88,12,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #ea580c; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #78716c; line-height: 1.5; margin: 0; }

/* ─── 計測完了 モーダル ──────────────────────────── */
.result-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.78);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.result-modal-inner {
  background: #fff;
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  text-align: center;
  max-width: 340px; width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,.45);
  animation: modalPop .35s cubic-bezier(.23,1,.32,1) both;
}
@keyframes modalPop {
  0%   { transform: scale(.72); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.result-modal-icon { font-size: 3.5rem; margin-bottom: .4rem; }
.result-modal-title {
  font-size: 1.45rem; font-weight: 800; color: #1c1917;
  margin-bottom: .75rem; letter-spacing: .02em;
}
.result-modal-score-wrap {
  display: flex; align-items: baseline; justify-content: center; gap: .3rem;
  margin-bottom: .4rem;
}
.result-modal-score {
  font-family: 'Orbitron', monospace;
  font-size: 4.2rem; font-weight: 900; color: #ea580c; line-height: 1;
}
.result-modal-unit { font-family: 'Orbitron', monospace; font-size: 1.2rem; color: #9a3412; }
.result-modal-comment {
  font-size: .92rem; color: #57534e;
  margin-bottom: 1.4rem; min-height: 1.4em;
}

/* ─── Toast ───────────────────────────────────────── */
#sm-toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: #1c1917; color: #fff;
  padding: .6rem 1.2rem; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
#sm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Footer ──────────────────────────────────────── */
footer {
  text-align: center; padding: 1.5rem 1rem;
  font-size: .82rem; color: #a8a29e;
  border-top: 1px solid #e7e5e4; margin-top: auto;
}
footer a { color: #ea580c; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: .3rem; }

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.35rem; }
  .db-number { font-size: 4rem; }
  .scene-grid { grid-template-columns: repeat(2, 1fr); }
  .amazon-grid { grid-template-columns: repeat(2, 1fr); }
  .perm-card { padding: 1.5rem 1.25rem; }
  .level-name { min-width: 72px; }
  .level-desc { font-size: .76rem; }
}
@media (max-width: 420px) {
  .db-number { font-size: 3.2rem; }
  .db-unit { font-size: 1.1rem; }
  .contest-count { font-size: 5.5rem; }
  .scene-grid { grid-template-columns: 1fr; }
  .amazon-grid { grid-template-columns: 1fr; }
  .result-score { font-size: 3rem; }
}
