/* 色をまとめて定義（あとで変えやすいように） */
:root {
  --bg: #0f3d2e;        /* ポーカーテーブルの緑 */
  --panel: #14513c;
  --text: #f3f7f4;
  --muted: #b7cfc3;
  --raise: #e0a526;
  --fold: #5d7268;
  --good: #4cd38a;
  --bad: #ff6b6b;
  --card: #ffffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding-block: 16px;
  /* スマホの画面の端（ノッチなど）に文字がかからないようにする */
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

header h1 { font-size: 1.4rem; margin: 8px 0 4px; }
.sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

.controls { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.controls select { font-size: 1rem; padding: 4px 8px; border-radius: 6px; }

.table {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
}

.position { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.badge {
  background: var(--raise);
  color: #222;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 999px;
}
.note { color: var(--muted); font-size: 0.85rem; }

.cards { display: flex; justify-content: center; gap: 12px; margin: 20px 0 8px; }
.card {
  width: 80px;
  height: 112px;
  background: var(--card);
  color: #111;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.card.red { color: #d12a2a; }
.card .suit { font-size: 1.8rem; line-height: 1; }

.hand-code { color: var(--muted); font-size: 0.95rem; }

.actions { display: flex; gap: 12px; margin: 16px 0; }
.btn {
  flex: 1;
  font-size: 1.15rem;
  font-weight: bold;
  padding: 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.fold { background: var(--fold); color: var(--text); }
.btn.raise { background: var(--raise); color: #222; }
.btn.next { background: var(--text); color: #222; width: 100%; margin-top: 8px; }
kbd { font-size: 0.7rem; opacity: 0.6; font-family: inherit; }

.result { text-align: center; margin-bottom: 16px; }
.result p { font-size: 1.05rem; margin: 0; line-height: 1.6; }
.result .good { color: var(--good); font-weight: bold; font-size: 1.3rem; }
.result .bad { color: var(--bad); font-weight: bold; font-size: 1.3rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
}
.stats span { display: block; font-size: 1.4rem; font-weight: bold; }
.stats small { color: var(--muted); }
.link {
  grid-column: 1 / -1;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.8rem;
}

.range { margin-top: 16px; }
.range summary { cursor: pointer; padding: 8px 0; }
.legend { font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-block; width: 12px; height: 12px; vertical-align: middle; margin-right: 4px; }
.legend .in { background: var(--raise); }
.legend .now { outline: 2px solid var(--text); background: transparent; }

/* 13×13 のマス目 */
.grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; }
.cell {
  aspect-ratio: 1;
  font-size: clamp(0.45rem, 1.9vw, 0.7rem);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #24493c;
  color: var(--muted);
  border-radius: 3px;
}
.cell.in { background: var(--raise); color: #222; }
.cell.now { outline: 2px solid var(--text); outline-offset: -2px; font-weight: bold; }

footer { color: var(--muted); font-size: 0.75rem; margin-top: 16px; }

/* ===== 画面の切り替えタブ ===== */
.tabs-main { display: flex; gap: 8px; margin-bottom: 12px; }
.nav {
  flex: 1;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.nav.active { background: var(--text); color: #222; font-weight: bold; }

.controls { flex-wrap: wrap; }

/* ===== レンジ編集画面 ===== */
.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel h2 { font-size: 1rem; margin: 0; }
.panel label { font-size: 0.85rem; color: var(--muted); }
.panel select,
.panel input,
.panel textarea {
  font-size: 1rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--muted);
  width: 100%;
  font-family: inherit;
}
.panel textarea { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.small {
  padding: 8px 12px;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  background: var(--text);
  color: #222;
  cursor: pointer;
}
.small:disabled { opacity: 0.4; cursor: default; }
.small.danger { background: var(--bad); color: #fff; }

.pos-tabs { display: flex; gap: 4px; }
.pos-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: #24493c;
  color: var(--text);
  font-weight: bold;
  cursor: pointer;
}
.pos-tab.active { background: var(--raise); color: #222; }

/* 編集できるマス目は、指でなぞっても画面がスクロールしないようにする */
.grid.editable { touch-action: none; user-select: none; -webkit-user-select: none; }
.grid.editable .cell { cursor: pointer; }

/* もう一方のページへ移る目立つリンク */
.jump {
  display: inline-block; margin: 10px 0 8px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--raise);
  color: var(--raise); text-decoration: none; font-size: 0.9rem; font-weight: bold;
}
.jump:active { opacity: 0.7; }
footer a { color: var(--raise); }

/* 席の図 */
.seat-map {
  position: relative; height: 150px; max-width: 340px; margin: 0 auto 6px;
}
.seat-map .felt {
  position: absolute; inset: 22px 18%; border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.18); background: rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.75rem;
}
.seat {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 64px; padding: 3px 6px; border-radius: 10px; text-align: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.25); line-height: 1.2;
}
.seat b { display: block; font-size: 0.85rem; }
.seat small { display: block; font-size: 0.6rem; color: var(--muted); white-space: nowrap; }
.seat.folded b, .seat.folded small { opacity: 0.4; }
.seat.folded { border-color: rgba(255,255,255,0.1); }
.seat.me { background: var(--raise); color: #222; border-color: var(--raise); }
.seat.me small { color: #222; font-weight: bold; }
.seat-help { color: var(--muted); font-size: 0.7rem; text-align: center; margin: 0 0 10px; line-height: 1.5; }
/* 席の図で自分の席がわかるので、文字のバッジは隠す */
.position .badge { display: none; }
/* ディーラーボタン（BTNの席に置く白い丸） */
.seat .dealer {
  position: absolute; right: -9px; bottom: -9px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; color: #222; font-size: 0.7rem; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* アカウント（ログイン） */
.account { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; }
#account-in { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
#account-in[hidden], #account-out[hidden] { display: none; }
.login-panel { display: flex; flex-direction: column; gap: 8px; }
.login-panel[hidden] { display: none; }
.google {
  background: #fff; color: #222; border: none; border-radius: 10px;
  padding: 10px; font-size: 0.95rem; font-weight: bold; cursor: pointer;
}
.or { margin: 0; color: var(--muted); font-size: 0.8rem; text-align: center; }
.login-buttons { display: flex; gap: 8px; }
.login-buttons .small { flex: 1; }
.login-msg { margin: 0; color: var(--raise); font-size: 0.8rem; min-height: 1em; }
