/* Google Fonts import */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700&display=swap');

:root {
  --bg-color: #1a1025;
  /* ダークパープル背景 */
  --accent-color: #f5d98b;
  /* パスタ色 */
  --primary-color: #d946ef;
  /* マゼンタ系（アクション） */
  --text-color: #fff;
  --hud-bg: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* オープニング画面 */
.title-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #2e1a42 0%, #1a1025 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 100;
}

.title-screen.hidden {
  display: none;
}

.title-screen h1 {
  font-size: 4rem;
  line-height: 1.1;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #f5d98b, #d946ef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(217, 70, 239, 0.3);
}

.subtitle {
  font-size: 1.2rem;
  opacity: 0.8;
  margin-bottom: 2rem;
}

.rule-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  display: inline-block;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rule-box h3 {
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}

.rule-box ul {
  list-style-position: inside;
}

.rule-box li {
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.btn-primary-large {
  background: linear-gradient(135deg, #d946ef, #a855f7);
  color: white;
  border: none;
  padding: 1rem 3rem;
  font-size: 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(217, 70, 239, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(217, 70, 239, 0.6);
}

/* ゲーム画面コンテナ */
#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
}

/* キャンバス */
#canvas-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#canvas-wrap.hidden {
  display: none;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* ウィンドウサイズに合わせる */
  pointer-events: none;
}

#gameCanvas {
  pointer-events: auto;
  z-index: 10;
}

#drawCanvas {
  pointer-events: none;
  z-index: 20;
}

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 30;
  background: linear-gradient(to bottom, rgba(26, 16, 37, 0.8), transparent);
}

.hud.hidden {
  display: none;
}

.hud button,
.hud .btn-icon {
  pointer-events: auto;
}

.stats {
  display: flex;
  gap: 2rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-item .value {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent-color);
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-action {
  background: white;
  color: #1a1025;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-action:hover {
  background: #f3f4f6;
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* オーバーレイ */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 16, 37, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  text-align: center;
}

.overlay-title {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.overlay-title.success {
  color: #4ade80;
}

/* Green */
.overlay-title.fail {
  color: #fca5a5;
}

/* Red */

.overlay-sub {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  opacity: 0.8;
}

.btn-primary {
  background: linear-gradient(135deg, #ae68e6, #d946ef);
  color: white;
  border: none;
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

/* モーダル */
.modal {
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: #2e1a42;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.close {
  position: absolute;
  top: 10px;
  right: 20px;
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: white;
}

.help-body h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.2rem;
}

.help-body p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}