/* =========================================================
   CSS変数・グローバル設定
   ========================================================= */
:root {
  --bg: #ffffff;
  --text: #383838;
  --text-muted: #747574;
  --text-caution: #C62828;
  --muted: #9ca3af;
  --line: #DBE4E0;
  --bg-light: #F1F5F3;

  /* ブランドカラー */
  --primary: #3AB67D;
  --border: #DBE4E0;

  --radius: 12px;
  --space-xs: 3px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 30px;
  --space-xl: 60px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* メダル画像 */
  --icon-diamond: url("../assets/icons/medal-diamond.png");
  --icon-gold: url("../assets/icons/medal-gold.png");
  --icon-silver: url("../assets/icons/medal-silver.png");
  --icon-bronze: url("../assets/icons/medal-bronze.png");
  --icon-iron: url("../assets/icons/medal-iron.png");

  /* レイアウト寸法 */
  --resultbar-h: calc(72px + var(--safe-bottom));
  --sheet-collapsed: 90px;

  /* シートフル表示時の高さ（固定値で定義） */
  /* メダルエリア(66px) + キーパッド(パディング20px + キー96px + ギャップ5px + ボーダー1px) + セーフエリア */
  --sheet-full-height: calc(66px + 122px + var(--safe-bottom));

  --ad-h: 92px;
}

/* =========================================================
   リセット・ベーススタイル
   ========================================================= */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html {
  max-width: 640px;
  margin: 0 auto;
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family:
    "Inter",
    "Noto Sans JP",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}



/* 見出し */
h1 {
  font-size: 32px;
  margin: 0 0 var(--space-lg);
}

h2 {
  font-size: 24px;
  margin: 0 0 var(--space-md);
}

h3 {
  font-size: 20px;
  margin: 0 0 var(--space-sm);
}

h4 {
  font-size: 18px;
  margin: 0 0 var(--space-sm);
}

/* テキスト */
.text-small {
  font-size: 14px;
}

.text-muted {
  color: var(--text-muted);
}

.text-caution {
  color: var(--text-caution);
}

p {
  margin: 0;
}

button,
input {
  font-family: inherit
}

.screen {
  display: none;
  min-height: 100svh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.container {
  padding: 0 var(--space-4)
}

#basePoint,
#rateBasePoint,
.medal-rate,
.rate-input,
#nearpin-point,
#rate-nearpin-point,
#dragon-point,
#rate-dragon-point,
.s2-body .cell--with-number {
  font-family: 'Roboto Mono', monospace;
}

/* =========================================================
   共通コンポーネント：ボタン
   ========================================================= */
.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: none;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  text-align: center;
}

.btn-secondary {
  background: #374151;
}

.btn-ghost {
  background: #e5e7eb;
  color: #111;
  font-weight: 700;
  border-radius: 10px;
  padding: 14px 16px;
}



.link-button {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #666;
  text-decoration: underline;
  cursor: pointer;
  margin-bottom: 30px;
}

/* =========================================================
   共通コンポーネント：入力フィールド
   ========================================================= */
input[type="text"] {
  width: 100%;
  padding: 14px 14px;
  outline: none;
  font-size: 16px;
  background: #fff;
}

input[type="number"] {
  outline: none;
  background: #fff;
}

input::placeholder {
  color: var(--muted)
}

input[type="text"],
input[type="number"] {
  border: 1px solid #C3C3C3;
  border-radius: 3px;
  outline: none;
  background: #fff;
  font-size: 16px;
}

.error {
  color: #b91c1c;
  font-size: 13px;
  margin: 12px 0 0;
}

/* =========================================================
   共通コンポーネント：モーダル
   ========================================================= */
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .60);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  /*width:min(92vw, 360px);*/
}

.modal__content {
  background: #fff;
  color: #111;
  border-radius: 14px;
  padding: 20px 16px 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.modal__text {
  margin: 0 0 16px 0;
  line-height: 1.6;
}

.modal__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-bottom: 4px;
}

/* モーダル内だけボタン色を調整 */
.modal .btn-primary {
  background: #1d4ed8;
}

.modal .btn-secondary {
  background: #d1d5db;
  color: #111;
}