:root {
  /* 和紙・白木・墨・古金・朱・松葉・藍鉄（落ち着いた和の昼調パレット） */
  --bg-washi-top: #f5efe2;
  --bg-washi-mid: #ece2cf;
  --bg-washi-bot: #dfd2bb;
  --panel-bg: rgba(252, 248, 240, 0.91);
  --panel-bg-soft: rgba(243, 235, 220, 0.88);
  --panel-border: rgba(133, 102, 60, 0.28);
  --panel-border-strong: rgba(122, 88, 43, 0.56);

  --gold: #8c6525;
  --gold-bright: #6a4712;
  --vermilion: #a61c1c;
  --vermilion-bright: #b91c1c;
  --emerald: #276749;
  --sky: #255777;

  /* 盤・駒の基準トーン */
  --wood-light: #ebca8b;
  --wood-mid: #d7a656;
  --wood-dark: #be8634;

  /* 墨・茶系テキスト */
  --text-main: #231a11;
  --text-sub: #4c3e2e;
  --text-muted: #766753;

  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "MS PMincho", Georgia, serif;
  --font-sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", -apple-system, BlinkMacSystemFont, sans-serif;
  --board-size: min(86vw, 486px);
}

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

html, body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 252, 244, 0.72), transparent 55%),
    linear-gradient(170deg, var(--bg-washi-top) 0%, var(--bg-washi-mid) 55%, var(--bg-washi-bot) 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
}

/* 全画面和風水墨画＆朝霧ビジュアル */
.bg-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-artwork {
  position: absolute;
  inset: 0;
  background: url("../assets/bg-sumie-fog.jpg") center center / cover no-repeat;
  opacity: 0.65;
  filter: saturate(0.95) contrast(0.99);
}
.bg-mist {
  position: absolute;
  inset: -12%;
  will-change: transform;
}
.bg-mist-a {
  background:
    radial-gradient(ellipse 52% 38% at 22% 28%, rgba(252, 248, 240, 0.56), transparent 72%),
    radial-gradient(ellipse 46% 34% at 76% 68%, rgba(247, 240, 226, 0.52), transparent 70%);
  animation: mistDriftA 42s ease-in-out infinite alternate;
}
.bg-mist-b {
  background:
    radial-gradient(ellipse 58% 36% at 68% 24%, rgba(255, 252, 244, 0.44), transparent 72%),
    radial-gradient(ellipse 50% 40% at 26% 78%, rgba(240, 230, 210, 0.48), transparent 74%);
  animation: mistDriftB 54s ease-in-out infinite alternate;
}
.bg-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(250, 245, 234, 0.22) 0%, rgba(235, 223, 200, 0.32) 72%, rgba(215, 198, 168, 0.46) 100%);
}
@keyframes mistDriftA {
  0% { transform: translate3d(-2.5%, -1%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.04); }
}
@keyframes mistDriftB {
  0% { transform: translate3d(2.5%, 1.5%, 0) scale(1.03); }
  100% { transform: translate3d(-3%, -1.5%, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .bg-mist { animation: none; }
}

/* 繊細な越前和紙の繊維テクスチャ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.45 0 0 0 0 0.35 0 0 0 0 0.22 0 0 0 0.055 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.serif { font-family: var(--font-serif); }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(215, 200, 174, 0.35); }
::-webkit-scrollbar-thumb { background: rgba(133, 102, 60, 0.4); border-radius: 999px; }

.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(4px);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 10px 26px -14px rgba(56, 39, 18, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.btn-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  background: linear-gradient(180deg, #fcf9f2, #efe6d5);
  border: 1px solid rgba(133, 102, 60, 0.38);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(60, 40, 15, 0.1);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-wa:hover:not(:disabled) {
  background: linear-gradient(180deg, #fffdf9, #e7dac3);
  border-color: var(--gold);
}
.btn-wa:active:not(:disabled) { transform: translateY(1px); }
.btn-wa:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-wa.sm { padding: 5px 10px; font-size: 11.5px; }
.btn-wa.lg { padding: 11px 20px; font-size: 14px; border-radius: 9px; }

.btn-wa.gold {
  background: linear-gradient(160deg, #8b5a22, #5f3a11);
  color: #fcf7eb;
  border-color: #4d2e0c;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(77, 46, 12, 0.24);
}
.btn-wa.gold:hover:not(:disabled) {
  background: linear-gradient(160deg, #9b672b, #6d4315);
  border-color: #3f2408;
}

.btn-wa.danger {
  background: linear-gradient(180deg, #fdf3f2, #f7dfdd);
  border-color: rgba(166, 28, 28, 0.4);
  color: var(--vermilion);
}
.btn-wa.danger:hover:not(:disabled) {
  background: #f5d2cf;
  border-color: var(--vermilion);
}

.btn-wa.sky {
  background: linear-gradient(160deg, #2d6285, #1e455f);
  border-color: #16364b;
  color: #f6f9fb;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(30, 69, 95, 0.24);
}
.btn-wa.sky:hover:not(:disabled) {
  background: linear-gradient(160deg, #357097, #23506e);
}

.input-wa {
  width: 100%;
  padding: 8px 11px;
  border-radius: 7px;
  background: #fffdf8;
  border: 1px solid rgba(133, 102, 60, 0.36);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wa::placeholder { color: #9c8f7e; }
.input-wa:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(140, 101, 37, 0.16);
}

/* Overlays & Toasts */
.toast-container {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(92vw, 480px);
}
.toast {
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 26px rgba(42, 28, 12, 0.26);
  backdrop-filter: blur(8px);
  animation: toastIn 0.22s ease-out;
}
.toast.collision {
  background: rgba(254, 247, 226, 0.97);
  border: 1.5px solid #b47b1e;
  color: #6b4308;
}
.toast.trap {
  background: rgba(254, 240, 240, 0.97);
  border: 1.5px solid var(--vermilion);
  color: #841212;
}
.toast.info {
  background: rgba(240, 247, 251, 0.97);
  border: 1.5px solid var(--sky);
  color: #193e57;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(29, 22, 14, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  background: #fbf7ef;
  border: 1.5px solid rgba(133, 102, 60, 0.65);
  border-radius: 12px;
  box-shadow: 0 22px 52px rgba(32, 20, 8, 0.38);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
.modal-close {
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 6px;
}
.modal-close:hover { color: var(--vermilion); }

/* Custom Wafu Image Icons */
.wa-icon {
  width: 1.25em;
  height: 1.25em;
  object-fit: contain;
  vertical-align: -0.24em;
  display: inline-block;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}
.wa-icon.sm { width: 15px; height: 15px; vertical-align: -0.18em; }
.wa-icon.md { width: 22px; height: 22px; }
.wa-icon.lg { width: 28px; height: 28px; }
.wa-icon.xl { width: 42px; height: 42px; vertical-align: middle; }

.inline-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-wa.gold .wa-icon,
.btn-wa.sky .wa-icon {
  filter: drop-shadow(0 0 1.5px rgba(255, 250, 236, 0.8));
}
