:root {
  --cream: #FFF8F0;
  --warm: #FFF0DC;
  --brown: #6B3F1E;
  --accent: #E8704A;
  --accent2: #F5A623;
  --green: #5B8A5E;
  --green-light: #8BBF8E;
  --text: #3A2010;
  --muted: #7A5030;
  --border: #F0E0D0;
  --shadow: 0 8px 32px rgba(107,63,30,0.12);
  --radius: 20px;
}

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

html { overflow-x: hidden; width: 100%; }

body {
  font-family: 'Zen Maru Gothic', 'Noto Sans JP', sans-serif;
  background: var(--cream);
  color: var(--text);
  padding-bottom: 0;
  overflow-x: hidden;
  width: 100%;
  min-width: 0;
}

.header { background: linear-gradient(135deg, #FF6B6B, #FFB347); padding: 32px 20px; text-align: center; position: relative; overflow: hidden; }
.header::before { content: '🐾'; font-size: 120px; position: absolute; right: -20px; top: -20px; opacity: .15; pointer-events: none; }
.header h1 { color: #fff; font-size: 26px; font-weight: 900; line-height: 1.3; }
.header p { color: rgba(255,255,255,.9); font-size: 13px; margin-top: 8px; }

.main {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
  overflow-x: hidden;
}

.login-screen { text-align: center; padding: 48px 24px; background: #fff; border-radius: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.login-screen .icon { font-size: 64px; margin-bottom: 16px; }
.login-screen h2 { font-size: 20px; font-weight: 900; margin-bottom: 8px; }
.login-screen p { font-size: 13px; color: var(--muted); margin-bottom: 32px; line-height: 1.8; }
.btn-line { display: inline-flex; align-items: center; gap: 10px; background: #06C755; color: #fff; border: none; border-radius: 50px; padding: 16px 32px; font-size: 16px; font-weight: 700; cursor: pointer; text-decoration: none; box-shadow: 0 6px 20px rgba(6,199,85,.4); font-family: inherit; }

.user-bar { background: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; border: 1px solid var(--border); display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); width: 100%; }
.user-bar img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-bar strong { color: var(--text); }

.card { background: #fff; border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); margin-bottom: 16px; width: 100%; }
.card-title { font-size: 14px; font-weight: 900; color: var(--brown); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-title .num { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; background: var(--warm); border-radius: 50%; font-size: 12px; flex-shrink: 0; }

label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--cream);
  outline: none;
  transition: border-color .2s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--accent); background: #fff; }
.field { margin-bottom: 14px; width: 100%; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }

.optional { font-size: 10px; background: rgba(107,63,30,.08); color: var(--muted); padding: 2px 8px; border-radius: 99px; margin-left: 6px; font-weight: 400; }

.animal-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.animal-btn {
  width: 100%;
  min-width: 0;
  padding: 16px 14px;
  border: 2.5px solid var(--border);
  border-radius: 14px;
  background: var(--cream);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  color: var(--muted);
  transition: all .2s;
  text-align: center;
  letter-spacing: .05em;
}
.animal-btn.on { border-color: var(--accent); background: #FFF4EE; color: var(--accent); box-shadow: 0 4px 12px rgba(232,112,74,.18); }

.sel-wrap { position: relative; width: 100%; }
.sel-wrap::after { content: '▾'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 12px; }

.upload-area {
  border: 3px dashed var(--accent2);
  border-radius: 20px;
  background: #fff;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  width: 100%;
  overflow: hidden;
}
.upload-area.has-image { border-style: solid; border-color: var(--green); padding: 12px; }
.upload-area:hover { border-color: var(--accent); background: #FFF9F5; }
#fileInput { display: none; }
#previewImg { width: 100%; max-height: 280px; object-fit: cover; border-radius: 12px; display: none; }
.upload-text { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.upload-sub { font-size: 12px; color: var(--muted); }

.btn { width: 100%; padding: 17px; border: none; border-radius: 50px; font-family: inherit; font-size: 16px; font-weight: 900; cursor: pointer; transition: all .2s; display: block; text-align: center; }
.btn-diagnose { background: linear-gradient(135deg, #FF6B6B, #FFB347); color: #fff; box-shadow: 0 6px 20px rgba(255,107,107,.4); margin-bottom: 0; }
.btn-diagnose:disabled { opacity: .6; cursor: not-allowed; }
.btn-diagnose:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255,107,107,.5); }
.btn-green { background: linear-gradient(135deg, var(--green), #3D6640); color: #fff; box-shadow: 0 6px 20px rgba(91,138,94,.35); }
.btn-green:hover { transform: translateY(-2px); }
.btn-outline { background: #fff; color: var(--accent); border: 2px solid var(--accent); border-radius: 50px; padding: 14px; font-size: 14px; font-weight: 900; width: 100%; cursor: pointer; font-family: inherit; transition: all .2s; }
.btn-outline:hover { background: #FFF4EE; }

.diagnose-gap { height: 32px; }

.loading { display: none; text-align: center; padding: 32px; background: #fff; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.paw-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
.paw-row span { font-size: 32px; animation: pb 1.2s ease-in-out infinite; }
.paw-row span:nth-child(2) { animation-delay: .2s; }
.paw-row span:nth-child(3) { animation-delay: .4s; }
@keyframes pb { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-12px);opacity:1} }
.loading p { font-size: 14px; color: var(--muted); font-weight: 700; }

.error { display: none; background: #FFF0F0; border: 2px solid #FFB3B3; border-radius: 16px; padding: 16px 20px; color: #CC3333; font-size: 13px; text-align: center; margin-bottom: 16px; }

#resultCard { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; width: 100%; }
.rc-header { background: linear-gradient(135deg, #FF6B6B, #FFB347); padding: 20px; text-align: center; color: #fff; }
.rc-brand { font-size: 10px; letter-spacing: .2em; font-weight: 900; opacity: .9; margin-bottom: 6px; }
.rc-pet-photo { width: 88px; height: 88px; border-radius: 50%; border: 3px solid #fff; object-fit: cover; margin: 14px auto 0; display: block; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.rc-type { font-size: 21px; font-weight: 900; margin: 10px 0 3px; }
.rc-sub { font-size: 12px; opacity: .9; }
.rc-breed-line { font-size: 11px; opacity: .75; margin-top: 4px; }

.rc-body { padding: 20px; width: 100%; }
.rs { margin-bottom: 18px; width: 100%; }
.rst { font-size: 11px; font-weight: 900; color: var(--muted); letter-spacing: .1em; margin-bottom: 10px; padding-bottom: 7px; border-bottom: 2px solid var(--warm); }
.rst-large { font-size: 16px; color: var(--brown); letter-spacing: .05em; }
.rdesc { font-size: 13px; line-height: 1.85; color: var(--text); }

.special-attacks { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.special-attack-item { display: flex; align-items: flex-start; gap: 10px; background: linear-gradient(135deg, #FFF8E8, #FFF4EE); border: 1.5px solid rgba(232,112,74,.2); border-radius: 12px; padding: 10px 14px; font-size: 13px; color: var(--text); font-weight: 700; line-height: 1.5; width: 100%; }
.special-attack-item .atk-num { flex-shrink: 0; width: 22px; height: 22px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 900; display: flex; align-items: center; justify-content: center; margin-top: 1px; }

.traits { display: flex; flex-wrap: wrap; gap: 8px; }
.trait { border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700; }
.trait.r { background: #FFE8E8; color: #CC3333; }
.trait.g { background: #E8F5E9; color: #2E7D32; }
.trait.b { background: #E3F2FD; color: #1565C0; }
.trait.y { background: #FFF8E1; color: #F57F17; }

.meters { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.mlabel { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.mbar { height: 10px; background: var(--border); border-radius: 10px; overflow: hidden; width: 100%; }
.mfill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #FF6B6B, #FFB347); transition: width 1s ease; width: 0; }

.breed-badge { display: inline-flex; align-items: center; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 99px; margin-bottom: 10px; }

.food-banner-img { width: 100%; border-radius: 12px; display: block; transition: opacity .2s; }
.food-banner-img:hover { opacity: .9; }

.compat-block { background: linear-gradient(135deg, #EEFFF0, #F5FFEE); border: 2px solid rgba(91,138,94,.2); border-radius: 14px; padding: 16px; width: 100%; }
.compat-score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.compat-score-num { font-size: 36px; font-weight: 900; color: var(--green); line-height: 1; }
.compat-rank { font-size: 16px; font-weight: 900; color: var(--green); }
.compat-bar-wrap { background: rgba(91,138,94,.15); border-radius: 99px; height: 10px; overflow: hidden; margin-bottom: 10px; width: 100%; }
.compat-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--green-light), var(--green)); transition: width 1.2s ease; width: 0; }
.compat-desc { font-size: 12px; line-height: 1.75; color: var(--text); }

.rc-footer { background: var(--warm); padding: 12px 20px; text-align: center; font-size: 12px; letter-spacing: .2em; font-weight: 900; color: var(--brown); }

#compatFormCard { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; width: 100%; }
.gender-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.gender-btn { width: 100%; padding: 13px; border: 2.5px solid var(--border); border-radius: 12px; background: var(--cream); cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 700; color: var(--muted); transition: all .2s; text-align: center; }
.gender-btn.on { border-color: var(--green); background: #EEFFF0; color: var(--green); }

.action-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; width: 100%; }
.action-title { font-size: 13px; font-weight: 900; color: var(--brown); margin-bottom: 14px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; width: 100%; }
.btn-x { background: #000; color: #fff; border: none; border-radius: 50px; padding: 13px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.btn-tiktok { background: linear-gradient(135deg, #FF0050, #000); color: #fff; border: none; border-radius: 50px; padding: 13px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }

.line-cta { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; text-align: center; width: 100%; }
.line-cta p { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 14px; font-weight: 700; }

.btn-retry { width: 100%; background: #fff; color: var(--accent); border: 2px solid var(--accent); border-radius: 50px; padding: 14px; font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; margin-bottom: 16px; }

.site-footer { background: linear-gradient(135deg, #FF6B6B, #FFB347); padding: 32px 20px; text-align: center; width: 100%; }
.footer-logo { font-size: 28px; font-weight: 900; color: #fff; letter-spacing: .25em; }

.hidden { display: none !important; }
