
:root {
  --bg-dark: #0f141c;
  --bg-panel: #181f2a;
  --bg-card: #222b3a;
  --border-color: #334155;
  --border-light: rgba(255, 255, 255, 0.12);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-yellow: #fef08a;
  --radius-sm: 4px;
  --radius-md: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 26px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.5));
}

.brand-text .title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  display: block;
}

.brand-text .subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}

.stat-badge .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-badge .value {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.stat-badge .sub {
  font-size: 10px;
  color: var(--accent-cyan);
}

.turn-badge {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.08);
}

/* ⑤ 行動力 (AP) ゲージ */
.ap-badge {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
  min-width: 150px;
}

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

.ap-value {
  color: #34d399 !important;
  font-family: monospace;
  font-size: 13px !important;
}

.ap-meter {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}

.ap-cell {
  flex: 1;
  height: 8px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
}

.ap-cell.filled {
  background: #10b981;
  border-color: #34d399;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

/* Controls */
.controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: #1d4ed8;
  border-color: #60a5fa;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #2d3748;
  border-color: #64748b;
}

.btn-sub {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-sub:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

kbd {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: monospace;
}

/* Canvas Area */
.canvas-viewport {
  flex: 1;
  position: relative;
  background: #090d14;
  overflow: hidden;
  cursor: grab;
}

.canvas-viewport:active {
  cursor: grabbing;
}

#hex-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating Bottom Inspector & Guide */
.floating-panel {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 12px;
  z-index: 10;
  pointer-events: none;
}

.inspect-card, .guide-card {
  background: rgba(18, 22, 30, 0.92);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.inspect-card {
  min-width: 280px;
}

.inspect-title, .guide-title, .log-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inspect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 11px;
}

.inspect-span2 {
  grid-column: span 2;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 4px;
  margin-top: 2px;
}

.inspect-grid .label {
  color: var(--text-muted);
}

.inspect-grid .val {
  font-weight: 600;
  color: #fff;
}

.guide-card {
  max-width: 380px;
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.45;
}

.guide-text strong {
  color: var(--accent-yellow);
}

/* Floating Log in Bottom Right */
.log-overlay {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 320px;
  background: rgba(18, 22, 30, 0.92);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  max-height: 160px;
  display: flex;
  flex-direction: column;
}

.log-list {
  flex: 1;
  overflow-y: auto;
  font-family: monospace;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.log-item {
  color: #94a3b8;
  line-height: 1.35;
}
.log-system { color: #64748b; }
.log-info { color: #93c5fd; }
.log-action { color: #34d399; font-weight: 600; }
.log-success { color: #fef08a; font-weight: 700; }
.log-warn { color: #f87171; }

/* Scrollbars */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}


/* Authentication Overlay Gate */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.95);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  background: #18202c;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 16px rgba(251, 191, 36, 0.15);
}

.auth-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.auth-card h2 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.auth-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-input {
  background: #0f141d;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  outline: none;
  text-align: center;
  letter-spacing: 2px;
}

#auth-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.btn-block {
  width: 100%;
  padding: 10px;
}

.auth-error {
  color: #f87171;
  font-size: 11px;
  font-weight: 600;
  margin-top: 10px;
}

.auth-error.hidden {
  display: none;
}

.auth-hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 16px;
}

.auth-hint code {
  color: var(--accent-yellow);
  background: rgba(0,0,0,0.3);
  padding: 2px 5px;
  border-radius: 3px;
}


/* ⑤ 画面中央下の目立つ行動力 (AP) HUD & キング駒 */
.bottom-center-hud {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 30, 0.94);
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 20px rgba(251, 191, 36, 0.2);
  backdrop-filter: blur(14px);
  border-radius: 12px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 50;
  pointer-events: auto;
  user-select: none;
}

/* キング駒カード */
.hud-character-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.hud-piece-pedestal {
  width: 44px;
  height: 48px;
  background: linear-gradient(180deg, #1e3a8a 0%, #0f172a 100%);
  border: 1.5px solid #fbbf24;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.hud-chess-icon {
  font-size: 28px;
  color: #fef08a;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.hud-character-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-char-role {
  font-size: 10px;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.hud-char-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

/* 中央の行動力 (AP) パネル */
.hud-ap-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 260px;
}

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

.hud-ap-title {
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.8px;
}

.hud-ap-counter {
  font-size: 15px;
  font-weight: 800;
  color: #34d399;
  font-family: monospace;
}

.hud-ap-meter {
  display: flex;
  gap: 6px;
  height: 18px;
}

.hud-ap-cell {
  flex: 1;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.hud-ap-cell.filled {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  border-color: #6ee7b7;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.8), inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.hud-ap-cell.empty {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ターンを進めるボタン */
.btn-hud-turn {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: 1.5px solid #60a5fa;
  border-radius: 8px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: all 0.2s ease;
}

.btn-hud-turn:hover {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.6);
}

.btn-hud-turn.pulse-attention {
  animation: hudTurnPulse 1.4s infinite alternate;
  border-color: #fef08a;
}

@keyframes hudTurnPulse {
  0% { box-shadow: 0 0 10px rgba(251, 191, 36, 0.4); transform: scale(1); }
  100% { box-shadow: 0 0 22px rgba(251, 191, 36, 0.9); transform: scale(1.03); }
}

.btn-hud-turn .turn-icon {
  font-size: 18px;
  color: #fef08a;
}

.turn-text-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.turn-main-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.turn-sub-text {
  font-size: 10px;
  color: #bfdbfe;
}

