/**
 * @file style.css
 * アプリケーション全体のレイアウト、テーマ、ヘッダー、ツールバー、モーダル
 */

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-subtle: #1f2937;
  --border-color: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

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

body {
  background: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* アプリヘッダー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f43f5e, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* アイコンボタン */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-subtle);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(0);
}

.btn-icon.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* メインコンテンツ */
.main-content {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 対戦ステータスパネル */
.status-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: transparent;
}

.player-card.active-turn {
  background: var(--bg-subtle);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.12);
}

.player-card:last-child {
  flex-direction: row-reverse;
  text-align: right;
}

.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
  transition: all 0.2s ease;
}

.player-card.active-turn .turn-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.player-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.turn-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.player-card.active-turn .turn-status {
  color: var(--accent);
}

.status-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.turn-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 20px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* 選択中座標バー */
.hover-coord-bar {
  min-height: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-top: -8px;
}

/* ツールバー */
.controls-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.btn-action:hover:not(:disabled) {
  background: var(--bg-subtle);
  transform: translateY(-1px);
}

.btn-action:active:not(:disabled) {
  transform: translateY(0);
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-action.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* モーダル & オーバーレイ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.result-shape-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-main);
  text-align: center;
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

/* 設定フォーム */
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-select, .form-input {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.form-select:focus, .form-input:focus {
  border-color: var(--accent);
}

.preset-p-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.btn-preset-p {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset-p:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-preset-p.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.input-with-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.validation-msg {
  font-size: 11px;
  color: var(--p1-color);
  min-height: 16px;
}

.form-input.is-invalid {
  border-color: var(--p1-color);
}
