:root{
  --bg:#0b1220;
  --bg2:#141d38;
  --panel:rgba(18,24,48,.82);
  --panel-soft:rgba(255,255,255,.05);
  --line:rgba(255,255,255,.10);
  --text:#eef2ff;
  --muted:#b8c2e4;
  --accent:#7ea2ff;
  --accent-2:#9ec6ff;
  --mint:#87f0da;
  --danger:#ff9db4;
  --shadow:0 24px 60px rgba(0,0,0,.28);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  min-height:100vh;
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans JP","Yu Gothic",sans-serif;
  background:
    radial-gradient(circle at top, rgba(126,162,255,.16), transparent 32%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}
button,input,textarea{font:inherit}
a{color:inherit;text-decoration:none}

.page-shell{
  width:min(1120px, calc(100% - 24px));
  margin:18px auto 28px;
}
.card{
  border:1px solid var(--line);
  border-radius:26px;
  background:linear-gradient(180deg, rgba(20,29,60,.82), rgba(12,18,42,.88));
  box-shadow:var(--shadow);
}

.hero{
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:flex-start;
  padding:20px;
  margin-bottom:18px;
}
.eyebrow,.section-kicker{
  margin:0;
  color:var(--mint);
  font-size:13px;
  font-weight:700;
  letter-spacing:.04em;
}
.hero h1{
  margin:6px 0 0;
  font-size:clamp(28px,4vw,44px);
  line-height:1.15;
}
.hero-sub{
  margin:12px 0 0;
  color:var(--muted);
  line-height:1.8;
}
.hero-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.nav-btn,.ghost-btn,.action-btn,.tab-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:0 16px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
}
.nav-btn:hover,.ghost-btn:hover,.action-btn:hover,.tab-btn:hover,.count-btn:hover{transform:translateY(-1px)}
.main-grid{
  display:grid;
  grid-template-columns:minmax(0,1.35fr) minmax(320px,.85fr);
  gap:18px;
}
.counter-panel,.share-panel,.history-panel{padding:20px}
.side-stack{display:grid;gap:18px;align-content:start}
.panel-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:18px;
}
.panel-head.compact{margin-bottom:14px}
.panel-head h2{margin:4px 0 0;font-size:clamp(24px,3vw,34px);line-height:1.2}
.panel-head h3{margin:4px 0 0;font-size:22px;line-height:1.2}
.save-indicator,.history-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:0 14px;
  border-radius:999px;
  border:1px solid rgba(135,240,218,.28);
  background:rgba(135,240,218,.10);
  color:var(--text);
  font-weight:700;
  white-space:nowrap;
}

.control-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.field{display:grid;gap:8px}
.field-label{color:var(--muted);font-size:13px;font-weight:700}
.field-input{
  width:100%;
  min-height:48px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--text);
  padding:0 14px;
}
.count-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
  margin-top:16px;
}
.metric-card{
  border:1px solid var(--line);
  border-radius:24px;
  background:var(--panel-soft);
  min-height:170px;
  padding:18px;
  display:grid;
  align-content:start;
  gap:8px;
}
.metric-card.primary{
  background:linear-gradient(180deg, rgba(126,162,255,.18), rgba(255,255,255,.05));
  border-color:rgba(126,162,255,.35);
}
.metric-label{
  color:var(--mint);
  font-size:13px;
  font-weight:700;
}
.metric-card strong{
  font-size:clamp(54px,8vw,82px);
  line-height:1;
}
.action-stack{margin-top:18px}
.main-actions{
  display:grid;
  grid-template-columns:92px 1fr;
  gap:12px;
}
.count-btn{
  min-height:72px;
  border:0;
  border-radius:24px;
  color:#fff;
  cursor:pointer;
  font-weight:800;
  font-size:30px;
  transition:transform .14s ease, opacity .14s ease;
}
.count-btn.sub{
  background:rgba(255,255,255,.09);
  border:1px solid var(--line);
}
.count-btn.main{
  background:linear-gradient(135deg, var(--accent), var(--accent-2));
}
.action-note,.mini-note{
  margin:12px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.7;
}
.sub-actions{
  margin-top:14px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.ghost-btn.danger{color:#ffdbe5}

.share-tabs{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.tab-btn.is-active{
  background:rgba(126,162,255,.18);
  border-color:rgba(126,162,255,.35);
}
.share-box{
  margin-top:12px;
  border:1px solid var(--line);
  border-radius:20px;
  background:rgba(255,255,255,.04);
  overflow:hidden;
}
.share-text{
  width:100%;
  min-height:188px;
  resize:vertical;
  border:0;
  outline:none;
  color:var(--text);
  background:transparent;
  padding:14px 16px;
  line-height:1.8;
}
.share-meta{
  display:flex;
  justify-content:flex-end;
  padding:0 16px 12px;
  color:var(--muted);
  font-size:12px;
}
.share-actions{
  margin-top:12px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.action-btn.primary{
  background:linear-gradient(135deg, rgba(126,162,255,.28), rgba(158,198,255,.24));
}

.history-list{
  display:grid;
  gap:8px;
}
.history-item{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
}
.history-item strong{font-size:14px}
.history-item span{font-size:12px;color:var(--muted)}
.empty-text{
  margin:0;
  color:var(--muted);
  line-height:1.7;
}

.footer-note{
  margin-top:18px;
  color:var(--muted);
  font-size:12px;
  line-height:1.7;
  text-align:center;
}

@media (max-width: 900px){
  .main-grid{grid-template-columns:1fr}
}
@media (max-width: 640px){
  .page-shell{width:min(100%, calc(100% - 16px));margin-top:12px}
  .hero,.counter-panel,.share-panel,.history-panel{padding:16px}
  .hero{flex-direction:column}
  .hero-actions{justify-content:flex-start}
  .control-row,.count-grid,.sub-actions,.share-actions{grid-template-columns:1fr}
  .main-actions{grid-template-columns:84px 1fr}
  .metric-card{min-height:140px}
}


.hero{
  padding:16px 18px;
  margin-bottom:14px;
}
.hero h1{font-size:clamp(26px,3.6vw,40px)}
.hero-sub{margin-top:8px; line-height:1.65; font-size:14px}
.nav-btn,.ghost-btn,.action-btn,.tab-btn{min-height:40px; padding:0 14px}
.main-grid{
  grid-template-columns:minmax(0,1.45fr) minmax(300px,.78fr);
  gap:14px;
}
.counter-panel,.share-panel{padding:16px 18px}
.panel-head{margin-bottom:14px}
.panel-head h2{font-size:clamp(22px,2.6vw,30px)}
.panel-head h3{font-size:20px}
.save-indicator,.history-badge{min-height:34px; padding:0 12px; font-size:12px}
.control-row{gap:10px}
.field{gap:6px}
.field-input{min-height:44px; border-radius:14px}
.count-grid{gap:10px; margin-top:12px}
.metric-card{
  min-height:132px;
  padding:14px 16px;
  border-radius:20px;
}
.metric-card strong{font-size:clamp(44px,7vw,68px)}
.action-stack{margin-top:12px}
.main-actions{grid-template-columns:76px 1fr; gap:10px}
.count-btn{min-height:62px; border-radius:20px; font-size:28px}
.sub-actions{margin-top:10px}
.action-note,.mini-note{margin-top:10px; font-size:12px}
.share-tabs,.share-actions,.sub-actions{gap:8px}
.share-box{margin-top:10px; border-radius:18px}
.share-text{min-height:140px; padding:12px 14px; line-height:1.7}
.share-meta{padding:0 14px 10px}
.progress-wrap{margin-top:12px; display:grid; gap:8px}
.progress-meta{
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}
.progress-bar{
  height:12px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  overflow:hidden;
}
.progress-fill{
  height:100%;
  width:0;
  border-radius:999px;
  background:linear-gradient(90deg, var(--accent), var(--accent-2), var(--mint));
  transition:width .22s ease;
}
.metric-card.flash{
  animation: metricFlash .45s ease;
}
@keyframes metricFlash{
  0%{transform:scale(1); box-shadow:0 0 0 rgba(126,162,255,0)}
  35%{transform:scale(1.02); box-shadow:0 0 0 8px rgba(126,162,255,.08)}
  100%{transform:scale(1); box-shadow:0 0 0 rgba(126,162,255,0)}
}
@media (max-width: 900px){
  .main-grid{grid-template-columns:1fr}
}
@media (max-width: 640px){
  .hero,.counter-panel,.share-panel{padding:14px}
  .hero-sub{font-size:13px}
  .metric-card{min-height:118px}
  .metric-card strong{font-size:clamp(38px,11vw,56px)}
  .count-btn{min-height:58px}
}


.control-row.single{
  grid-template-columns: 1fr;
}
.sub-actions.single-action{
  grid-template-columns: 1fr;
}
.progress-wrap{
  margin-top:10px;
}
.progress-bar{
  position: relative;
}
.progress-fill.is-pulse{
  animation: progressPulse .42s ease;
}
@keyframes progressPulse{
  0%{filter:brightness(1); transform:scaleY(1)}
  40%{filter:brightness(1.22); transform:scaleY(1.08)}
  100%{filter:brightness(1); transform:scaleY(1)}
}
.metric-card.flash{
  animation: metricFlashStrong .55s ease;
}
@keyframes metricFlashStrong{
  0%{transform:scale(1); box-shadow:0 0 0 0 rgba(126,162,255,0)}
  35%{transform:scale(1.03); box-shadow:0 0 0 10px rgba(126,162,255,.12)}
  70%{transform:scale(1.015); box-shadow:0 0 0 4px rgba(135,240,218,.10)}
  100%{transform:scale(1); box-shadow:0 0 0 0 rgba(126,162,255,0)}
}
.page-shell{
  width:min(1080px, calc(100% - 20px));
  margin:14px auto 20px;
}
.hero{
  padding:14px 16px;
  margin-bottom:12px;
}
.hero-sub{
  max-width: 720px;
}
.counter-panel,.share-panel{
  padding:14px 16px;
}
.main-grid{
  gap:12px;
}
.share-text{
  min-height:118px;
}
@media (max-width: 640px){
  .page-shell{width:min(100%, calc(100% - 12px));margin-top:10px}
  .hero,.counter-panel,.share-panel{padding:12px}
  .hero-actions{
    width: 100%;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
  }
  .hero-actions .nav-btn{
    width:100%;
  }
  .metric-card strong{
    font-size: clamp(34px, 10vw, 50px);
  }
  .share-text{
    min-height:96px;
  }
}


/* Rescue controls: added without changing the main page layout */
.rescue-panel{
  margin-top:14px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:20px;
  background:rgba(255,255,255,.035);
}
.rescue-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  margin-bottom:10px;
}
.rescue-head h3{
  margin:4px 0 0;
  font-size:18px;
  line-height:1.25;
}
.rescue-note{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:30px;
  padding:0 10px;
  border-radius:999px;
  border:1px solid rgba(135,240,218,.22);
  background:rgba(135,240,218,.08);
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}
.rescue-list{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:8px;
}
.rescue-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) 82px 48px;
  gap:8px;
  align-items:end;
  min-width:0;
}
.rescue-row .field-input{
  min-height:40px;
  border-radius:14px;
}
.rescue-apply{
  min-width:52px;
  min-height:40px;
  padding:0;
  font-weight:800;
  font-size:20px;
  background:linear-gradient(135deg, rgba(126,162,255,.24), rgba(135,240,218,.16));
}
@media (max-width: 640px){
  .rescue-panel{padding:12px; margin-top:12px}
  .rescue-list{grid-template-columns:1fr}
  .rescue-row{
    grid-template-columns:minmax(0,1fr) 78px 46px;
    gap:6px;
  }
  .rescue-row .field-input{min-height:38px; padding:0 10px}
  .rescue-apply{min-width:46px; min-height:38px}
}


@media (min-width: 641px){
  .rescue-list{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px){
  .rescue-list{
    grid-template-columns:1fr;
  }
}

.share-text.is-iriam{
  white-space:pre-wrap;
  overflow-x:hidden;
  word-break:break-word;
}

[hidden]{
  display:none !important;
}

.qr-modal-backdrop{
  position:fixed;
  inset:0;
  z-index:80;
  display:grid;
  place-items:center;
  padding:18px;
  background:rgba(2,6,18,.72);
  backdrop-filter:blur(10px);
}
.qr-modal{
  width:min(420px, 100%);
  padding:16px;
}
.qr-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.qr-modal-head h3{
  margin:0;
  font-size:20px;
}
.qr-close{
  width:38px;
  height:38px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
  font-size:22px;
  line-height:1;
}
.qr-note{
  margin:0 0 12px;
  color:var(--muted);
  font-size:13px;
  line-height:1.7;
}
.qr-box{
  display:grid;
  place-items:center;
  padding:14px;
  border-radius:20px;
  background:#fff;
}
.qr-img{
  display:block;
  width:min(280px, 100%);
  height:auto;
  image-rendering:auto;
}
.qr-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:12px;
}
.mobile-share-text{
  min-height:130px;
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(255,255,255,.04);
  white-space:pre-wrap;
  overflow-x:hidden;
  word-break:break-word;
}
@media (max-width: 640px){
  .qr-actions{grid-template-columns:1fr}
}


/* Dynamic rescue / obstacle rules */
.rule-add{
  min-height:34px;
  padding:0 12px;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
}
.rule-remove{
  min-width:40px;
  min-height:40px;
  padding:0;
  color:#ffdbe5;
}
.rescue-row.has-remove{
  grid-template-columns:minmax(0,1fr) 82px 48px 40px;
}
.obstacle-panel{
  border-color:rgba(255,157,180,.16);
  background:rgba(255,157,180,.035);
}
.obstacle-panel .section-kicker{
  color:var(--danger);
}
.obstacle-apply{
  background:linear-gradient(135deg, rgba(255,157,180,.24), rgba(255,255,255,.08));
}
@media (max-width: 640px){
  .rescue-head{align-items:center}
  .rule-add{min-height:32px; padding:0 10px}
  .rescue-row.has-remove{
    grid-template-columns:minmax(0,1fr) 76px 44px 38px;
  }
  .rule-remove{min-width:38px; min-height:38px}
}
