/*
 * style.css — シェイプアトリエ対戦のスタイル一式。
 * レイアウト (画面切替・2ペイン)・カード・パレット・キャンバス・結果表示の順に定義する。
 */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #2b3245;
  --muted: #7a8199;
  --accent: #4f8cff;
  --accent-dark: #3568d4;
  --danger: #e74c3c;
  --success: #27ae60;
  --gold: #f39c12;
  --border: #dde3f0;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}

/* --- ヘッダー --- */
.header {
  text-align: center;
  padding: 24px 16px 8px;
}

.header h1 {
  margin: 0;
  font-size: 28px;
  color: var(--accent-dark);
}

.subtitle {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 14px;
}

/* --- 画面切替 --- */
.screen {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* --- カード --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

/* --- セットアップ画面 --- */
.setup-layout {
  max-width: 520px;
  margin: 0 auto;
}

.player-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.player-name {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

.field-row {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.field-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

/* --- ラウンド開始画面 --- */
.round-card {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  padding: 28px;
}

.candidates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.candidate {
  padding: 14px 6px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 17px;
  font-weight: bold;
  background: #f7f9ff;
}

.candidate-target {
  border-color: var(--gold);
  background: #fff7e6;
  color: #b3541e;
}

.candidate-target::after {
  content: " ★";
  color: var(--gold);
}

.target-announce {
  font-size: 20px;
  font-weight: bold;
  color: #b3541e;
  margin: 10px 0 2px;
}

.turn-announce {
  font-size: 16px;
  font-weight: bold;
  margin: 14px 0;
}

/* --- お絵かき画面 (2ペイン) --- */
.layout {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pane-editor {
  flex: 0 0 auto;
}

.pane-result {
  flex: 1 1 340px;
  max-width: 460px;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
    align-items: center;
  }
}

.theme-card {
  background: linear-gradient(135deg, #fff7e6, #ffeef2);
  border-color: #f5d9a8;
}

.theme-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.current-player {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.theme-label {
  font-size: 20px;
  font-weight: bold;
  color: #b3541e;
}

.timer {
  font-size: 26px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
}

/* 候補のミニ表示 (描きながら見る用) */
.candidates-mini {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.candidate-mini {
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f7f9ff;
  font-size: 12px;
}

.candidate-mini.target {
  border-color: var(--gold);
  background: #fff7e6;
  color: #b3541e;
  font-weight: bold;
}

.candidate-mini.target::after {
  content: " ★";
}

/* --- パレット --- */
.palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.palette-title {
  font-size: 13px;
  color: var(--muted);
  flex: 0 0 32px;
}

.shape-palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.shape-btn {
  width: 48px;
  height: 48px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9ff;
  cursor: grab;
  touch-action: none; /* ポインタドラッグ中のスクロールを防ぐ */
}

.shape-btn:active {
  cursor: grabbing;
}

.shape-btn:hover {
  border-color: var(--accent);
}

.shape-preview {
  width: 100%;
  height: 100%;
  display: block;
}

/* ドラッグ中にポインタに追従する図形のおばけ */
.drag-ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  opacity: 0.75;
  pointer-events: none;
  z-index: 1000;
}

.color-palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.color-btn.active {
  border-color: #2b3245;
  transform: scale(1.15);
}

/* --- キャンバス --- */
.board {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: block;
  touch-action: none; /* ポインタドラッグ中のスクロールを防ぐ */
}

/* --- プロパティパネル --- */
.prop-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px;
  background: #f7f9ff;
  border-radius: 8px;
}

.prop-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.toolbar.center {
  justify-content: center;
  margin-top: 18px;
}

/* --- モード選択タブとロビー --- */
.tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9ff;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary-inline {
  padding: 10px 16px;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary-inline:hover {
  background: var(--accent-dark);
}

.mono-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  cursor: pointer;
}

.room-code {
  font-size: 44px;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--accent-dark);
  margin: 4px 0 10px;
}

.lobby-players {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.lobby-players li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 15px;
}

#screen-lobby .btn {
  display: block;
  width: 100%;
  margin-top: 10px;
}

/* --- ボタン --- */.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  background: #fff;
}

.btn-ghost:hover {
  background: #eef2fb;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  font-weight: bold;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-next {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  background: var(--success);
  border: none;
  border-radius: var(--radius);
}

.btn-danger {
  color: #fff;
  background: var(--danger);
  border: none;
}

/* --- ターン結果 --- */
.result-card {
  border-color: var(--accent);
}

.turn-verdict {
  font-size: 17px;
  font-weight: bold;
  margin: 0 0 4px;
}

.turn-verdict.correct { color: var(--success); }
.turn-verdict.wrong { color: var(--danger); }

.turn-time {
  font-size: 15px;
  font-weight: bold;
  color: var(--accent-dark);
  margin: 0 0 10px;
}

/* --- 確信度配分 --- */
.probabilities {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prob-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.prob-label {
  flex: 0 0 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar .btn {
  white-space: nowrap; /* 「対戦を終える」などが縦書きにならないようにする */
}

.prob-target {
  font-weight: bold;
}

.prob-bar {
  flex: 1;
  height: 12px;
  background: #e8edf8;
  border-radius: 6px;
  overflow: hidden;
}

.prob-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4f8cff, #2ecc71);
  border-radius: 6px;
}

.prob-pct {
  flex: 0 0 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.raw {
  margin-top: 12px;
  font-size: 12px;
}

.raw pre {
  max-height: 200px;
  overflow: auto;
  background: #f5f6fa;
  padding: 8px;
  border-radius: 6px;
}

/* --- ラウンド結果 (勝者発表) --- */
.round-winner {
  font-size: 22px;
  font-weight: bold;
  color: var(--gold);
  margin: 14px 0;
}

.round-winner.none {
  color: var(--muted);
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px dashed var(--border);
  font-size: 15px;
}

.ranking-row.winner {
  background: #fff7e6;
  border-radius: 8px;
}

.ranking-rank {
  flex: 0 0 36px;
  font-weight: bold;
  color: var(--muted);
}

.ranking-name {
  flex: 1;
  font-weight: bold;
}

.ranking-correct.correct { color: var(--success); font-weight: bold; }
.ranking-correct.wrong { color: var(--danger); }

.ranking-time {
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
  font-weight: bold;
}

/* --- 履歴 --- */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}

.history-guess {
  color: var(--accent-dark);
  font-weight: bold;
  margin-left: auto;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 0;
}
