:root {
  --brown:   #7c5a3a;
  --brown-d: #5f4630;
  --cream:   #fff6e6;
  --line:    #f0d9c2;
  --card:    #fffdf8;
  --red:     #d94f3d;
  --red-d:   #c2402f;
  --tick:    #d8c3a8;
  --tick-d:  #a9855f;
  --shadow:  0 4px 14px rgba(95, 70, 48, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color: var(--brown-d);
  background:
    radial-gradient(circle at 50% -8%, rgba(217, 79, 61, 0.16) 0%, transparent 60%),
    linear-gradient(170deg, #fbf1e0 0%, #f3e0c2 100%);
  background-attachment: fixed;
  -webkit-user-select: none; user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
}

/* ---- ヘッダー ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px 6px; }
.logo { font-size: 1.18rem; margin: 0; letter-spacing: .01em; }
.paw { filter: drop-shadow(0 1px 1px rgba(0,0,0,.12)); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: #fff; color: var(--brown);
  font-size: 1.05rem; box-shadow: var(--shadow); cursor: pointer;
}
.icon-btn:active { transform: scale(.92); }

/* ---- コンパス ---- */
.compass-area {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 8px 0;
}

.readout { text-align: center; line-height: 1.1; }
.deg {
  font-size: 3.4rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--brown-d);
}
.deg-unit { font-size: 2rem; font-weight: 700; margin-left: 2px; color: var(--brown); }
.dir { font-size: 1.5rem; font-weight: 800; color: var(--red); margin-top: 2px; }

.dial-wrap {
  position: relative;
  width: min(84vw, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(95, 70, 48, 0.22);
}
.dial { width: 100%; height: 100%; display: block; will-change: transform; }
.dial-face {
  fill: var(--card);
  stroke: var(--brown);
  stroke-width: 5;
}

/* 盤面の文字（JSで生成） */
.lbl-n { fill: var(--red);   font-size: 26px; font-weight: 800; }
.lbl-c { fill: var(--brown); font-size: 24px; font-weight: 800; }
.lbl-i { fill: var(--tick-d); font-size: 11px; font-weight: 700; }

.needle {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.cat-msg {
  min-height: 1.4em;
  margin: 0; padding: 8px 18px;
  background: #fff; border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: .95rem; font-weight: 700; color: var(--brown);
  text-align: center;
}

/* ---- オーバーレイ ---- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(95, 70, 48, 0.45);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.overlay-card {
  background: var(--card); border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px 24px; max-width: 320px; width: 100%;
  text-align: center;
}
.overlay-emoji { font-size: 3rem; }
.overlay-card h2 { margin: 8px 0 6px; font-size: 1.3rem; }
.overlay-card p { margin: 0 0 18px; font-size: .95rem; line-height: 1.6; color: var(--brown); }

/* ---- モーダル ---- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(95, 70, 48, 0.45); }
.modal-card {
  position: relative;
  background: var(--card); border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px 20px; margin: 20px;
  max-width: 360px; width: calc(100% - 40px);
  max-height: 80dvh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 12px; font-size: 1.2rem; }
.howto { margin: 0 0 16px; padding-left: 1.2em; font-size: .92rem; line-height: 1.7; color: var(--brown-d); }
.howto li { margin-bottom: 6px; }
.howto .north { color: var(--red); }

.btn {
  border: none; border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem; font-weight: 800; cursor: pointer;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: var(--red); color: #fff;
  box-shadow: 0 4px 0 var(--red-d);
  width: 100%;
}
.btn-primary:active { box-shadow: 0 1px 0 var(--red-d); translate: 0 3px; }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  background: var(--brown-d); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 700;
  box-shadow: var(--shadow); z-index: 50;
  max-width: calc(100vw - 40px); text-align: center;
  transition: opacity .3s;
}

.hidden { display: none !important; }
