/* =========================================================
   盤上 — Table Game Portal
   設計トークン
   色:
     --ink          #1F2421  背景(漆塗りの卓を思わせる深いインク色)
     --ink-soft     #262B27  パネル背景
     --felt         #2E4034  サブパネル(対局台の緑)
     --wood-light   #D9B873  柾目(明るい升)
     --wood-dark    #7C5B33  柾目(暗い升)
     --parchment    #F1E9D8  本文(背景が暗い上の文字)
     --muted        #9CA89F  補助テキスト
     --vermilion    #B23A2E  朱(印・CTA)
     --vermilion-lt #D4574A  朱(ホバー)
   文字:
     見出し: Shippori Mincho(和文明朝・存在感)
     本文:   Zen Kaku Gothic New
     数値・コード: JetBrains Mono
   ========================================================= */

:root {
  --ink: #1f2421;
  --ink-soft: #262b27;
  --ink-softer: #2c322d;
  --felt: #2e4034;
  --wood-light: #d9b873;
  --wood-dark: #7c5b33;
  --parchment: #f1e9d8;
  --muted: #9ca89f;
  --vermilion: #b23a2e;
  --vermilion-lt: #d4574a;
  --line: rgba(241, 233, 216, 0.12);

  --font-display: "Shippori Mincho", serif;
  --font-body: "Zen Kaku Gothic New", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
}

body {
  position: relative;
  padding-bottom: 4rem;
}

/* 盤の格子を思わせる、ごく薄いテクスチャ */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  background-image:
    repeating-linear-gradient(0deg, var(--wood-light) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, var(--wood-light) 0 1px, transparent 1px 64px);
}

a { color: var(--wood-light); }

button { font-family: var(--font-body); cursor: pointer; }
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--wood-light);
  outline-offset: 2px;
}

/* ---------- ヘッダー ---------- */
.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.75rem 1.5rem 2rem;
}

.site-header__mark {
  flex: none;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 50%;
  background: var(--vermilion);
  color: var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  box-shadow: 0 0 0 3px rgba(241, 233, 216, 0.18);
}

.site-header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.9rem;
  margin: 0;
  letter-spacing: 0.04em;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.site-header__en {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.site-header p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- レイアウト基本 ---------- */
main#app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.view { display: none; }
.view--active { display: block; animation: fade-up 0.45s ease both; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
  letter-spacing: 0.03em;
}

.field-hint {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.text-input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--parchment);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font-body);
}

.text-input--mono {
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.join-row { display: flex; gap: 0.6rem; }
.join-row .text-input { flex: 1; }

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--parchment);
  border-radius: 6px;
  padding: 0.62rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--wood-light); color: var(--wood-light); }
.btn--small { padding: 0.45rem 0.85rem; font-size: 0.82rem; }
.btn--ghost { background: transparent; }
.btn--vermilion {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: var(--parchment);
}
.btn--vermilion:hover { background: var(--vermilion-lt); border-color: var(--vermilion-lt); color: var(--parchment); }
.btn--full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- ロビー ---------- */
.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1rem;
  margin-bottom: 2.2rem;
}

.lobby-grid__heading {
  grid-column: 1 / -1;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  margin: 1rem 0 0.2rem;
  color: var(--wood-light);
}

.game-cards {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.game-card {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.game-card--soon { opacity: 0.55; }

.game-card__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-card__badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--wood-light);
  border-radius: 4px;
  padding: 0.12rem 0.4rem;
  text-transform: uppercase;
}

.game-card__badge--soon { background: var(--felt); color: var(--muted); }

.game-card__desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

/* ---------- 部屋(対局)ビュー ---------- */
.room-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.6rem;
  align-items: start;
}

.room-side {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* 印(はんこ)風の部屋コードバッジ — このページの署名要素 */
.stamp {
  align-self: flex-start;
  border: 2.5px solid var(--vermilion);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  transform: rotate(-1.4deg);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stamp__label {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--vermilion-lt);
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.stamp__code {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--parchment);
}

.players { display: flex; flex-direction: column; gap: 0.5rem; }

.player {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.85rem;
}

.player__dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  flex: none;
}
.player--white .player__dot { background: var(--parchment); }
.player--black .player__dot { background: #14171a; border: 1px solid var(--line); }

.player--active { border-color: var(--wood-light); }

.status-banner {
  background: var(--felt);
  border-radius: 7px;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  text-align: center;
}

.status-banner--alert { background: var(--vermilion); }

.history-panel h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin: 0 0 0.4rem;
  color: var(--wood-light);
}

.move-history {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.5rem;
}

.room-actions { display: flex; gap: 0.5rem; margin-top: 0.3rem; }

.board-wrap {
  display: flex;
  justify-content: center;
}

.board {
  --sq: min(64px, (100vw - 340px) / 8);
  width: calc(var(--sq) * 8);
  height: calc(var(--sq) * 8);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 6px solid var(--wood-dark);
  border-radius: 4px;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,0.6);
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--sq) * 0.62);
  line-height: 1;
  user-select: none;
}

.sq--light { background: var(--wood-light); }
.sq--dark { background: var(--wood-dark); }

.sq--selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(178, 58, 46, 0.45);
}

.sq--move::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(178, 58, 46, 0.65);
}

.sq--capture::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 4px solid rgba(178, 58, 46, 0.75);
  background: transparent;
}

.sq--check { box-shadow: inset 0 0 0 4px var(--vermilion); }

.piece { position: relative; z-index: 2; filter: drop-shadow(0 2px 1px rgba(0,0,0,0.35)); cursor: pointer; }
.piece--white { color: #fbf6ea; }
.piece--black { color: #14171a; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 10px);
  background: var(--vermilion);
  color: var(--parchment);
  padding: 0.6rem 1.1rem;
  border-radius: 7px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- レスポンシブ ---------- */
@media (max-width: 760px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .room-layout { grid-template-columns: 1fr; }
  .room-side { order: 2; }
  .board-wrap { order: 1; }
  .board { --sq: min(52px, (100vw - 48px) / 8); }
}

@media (prefers-reduced-motion: reduce) {
  .view--active { animation: none; }
}
