/* ========================================
   カオス配信シミュレーター - style.css
   PC画面向け・大画面レイアウト
   ======================================== */

:root {
  --green: #00ff41;
  --magenta: #ff00ff;
  --bg-dark: #0a0a0a;
  --bg-mid: #1a1a2e;
  --border-color: #333;
  --text-dim: #888;
  --cyan: #00ffff;
  --red: #ff3333;
  --yellow: #ffff00;
}

body {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  background: var(--bg-dark);
  color: #eee;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---- 共通 ---- */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back-to-top-link {
  position: fixed;
  top: 12px;
  left: 12px;
  color: var(--green);
  text-decoration: none;
  font-size: 0.9rem;
  z-index: 1000;
  background: rgba(0,0,0,0.7);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}
.back-to-top-link:hover {
  background: rgba(0,255,65,0.15);
}

/* ---- スキャンライン ---- */
.scanline-overlay {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 4px
  );
  z-index: 999;
}

/* ==============================
   タイトル画面
   ============================== */
#title-screen {
  justify-content: center;
  gap: 28px;
  padding: 60px 40px;
  text-align: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,0,255,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(0,255,65,0.08) 0%, transparent 50%),
    var(--bg-dark);
}

/* グリッチテキスト */
.glitch-container {
  position: relative;
}
.glitch-text {
  font-family: 'Dela Gothic One', cursive;
  font-size: 3.2rem;
  color: #fff;
  position: relative;
  animation: glitch-skew 4s infinite linear alternate-reverse;
}
.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}
.glitch-text::before {
  color: var(--cyan);
  z-index: -1;
  animation: glitch-before 3s infinite linear alternate-reverse;
}
.glitch-text::after {
  color: var(--magenta);
  z-index: -2;
  animation: glitch-after 2s infinite linear alternate-reverse;
}

@keyframes glitch-before {
  0%   { clip-path: inset(40% 0 61% 0); transform: translate(-2px, -1px); }
  20%  { clip-path: inset(92% 0 1% 0);  transform: translate(1px, 2px); }
  40%  { clip-path: inset(43% 0 1% 0);  transform: translate(-1px, 3px); }
  60%  { clip-path: inset(25% 0 58% 0); transform: translate(3px, 1px); }
  80%  { clip-path: inset(54% 0 7% 0);  transform: translate(-3px, -2px); }
  100% { clip-path: inset(58% 0 43% 0); transform: translate(2px, -3px); }
}
@keyframes glitch-after {
  0%   { clip-path: inset(65% 0 13% 0); transform: translate(2px, 1px); }
  20%  { clip-path: inset(15% 0 62% 0); transform: translate(-2px, -1px); }
  40%  { clip-path: inset(78% 0 3% 0);  transform: translate(1px, -2px); }
  60%  { clip-path: inset(2% 0 87% 0);  transform: translate(-1px, 2px); }
  80%  { clip-path: inset(33% 0 55% 0); transform: translate(3px, -1px); }
  100% { clip-path: inset(10% 0 72% 0); transform: translate(-2px, 3px); }
}
@keyframes glitch-skew {
  0%   { transform: skew(0deg); }
  20%  { transform: skew(0deg); }
  21%  { transform: skew(2deg); }
  22%  { transform: skew(0deg); }
  80%  { transform: skew(0deg); }
  81%  { transform: skew(-1deg); }
  82%  { transform: skew(0deg); }
  100% { transform: skew(0deg); }
}

.subtitle {
  font-size: 1.4rem;
  color: var(--green);
  text-shadow: 0 0 10px rgba(0,255,65,0.5);
}

.studio-name {
  font-size: 0.95rem;
  color: var(--text-dim);
  letter-spacing: 0.3em;
}

.cyber-btn {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 16px 56px;
  color: var(--green);
  background: transparent;
  border: 2px solid var(--green);
  cursor: pointer;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.cyber-btn:hover {
  background: var(--green);
  color: var(--bg-dark);
  box-shadow: 0 0 30px rgba(0,255,65,0.4);
}
.cyber-btn:active {
  transform: scale(0.96);
}

/* ==============================
   キャラ選択画面
   ============================== */
#select-screen {
  justify-content: flex-start;
  gap: clamp(24px, 4vw, 40px);
  padding: clamp(88px, 12vh, 132px) clamp(24px, 6vw, 56px) 56px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(0,255,65,0.06) 0%, transparent 50%),
    var(--bg-dark);
}

.select-title {
  font-family: 'Dela Gothic One', cursive;
  font-size: 1.8rem;
  color: var(--green);
  text-shadow: 0 0 15px rgba(0,255,65,0.4);
}

.char-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: clamp(16px, 3vw, 28px);
  width: min(100%, 980px);
  margin: 0 auto;
  align-items: stretch;
}

.char-card {
  background: var(--bg-mid);
  border: 2px solid var(--border-color);
  border-radius: 14px;
  padding: clamp(20px, 2.5vw, 26px) clamp(16px, 2vw, 22px);
  width: auto;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 100%;
  font-family: 'M PLUS Rounded 1c', sans-serif;
  color: #eee;
}
.char-card:hover {
  border-color: var(--green);
  box-shadow: 0 0 24px rgba(0,255,65,0.25);
  transform: translateY(-6px);
}
.char-card:active {
  transform: scale(0.97);
}

.char-img-wrap {
  width: min(180px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border-color);
}
.char-card:hover .char-img-wrap {
  border-color: var(--green);
}
.char-img-wrap img {
  width: 130%;
  height: 130%;
  object-fit: cover;
}

.char-name {
  font-family: 'Dela Gothic One', cursive;
  font-size: 1.3rem;
  color: #fff;
  margin: 0;
}

.char-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.char-difficulty {
  font-size: 0.85rem;
  color: var(--cyan);
  background: rgba(0,255,255,0.1);
  padding: 4px 14px;
  border-radius: 12px;
}
.char-difficulty.difficulty-hard {
  color: var(--red);
  background: rgba(255,50,50,0.15);
  animation: pulse-hard 2s infinite;
}
@keyframes pulse-hard {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 14px rgba(255,50,50,0.5); }
}

/* ==============================
   ゲーム画面（PC大画面向け）
   ============================== */
#game-screen {
  padding: 50px 20px 20px;
}
#game-screen.active {
  display: flex;
}

.stream-layout {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 70px);
  height: calc(100dvh - 70px);
  border: 2px solid var(--green);
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 20px rgba(0,255,65,0.2),
    inset 0 0 100px rgba(0,255,65,0.03);
  background:
    radial-gradient(ellipse at center, rgba(0,255,65,0.02) 0%, transparent 70%),
    var(--bg-dark);
}

/* 配信メイン */
.stream-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stream-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  flex-shrink: 0;
}
.day-badge {
  color: var(--bg-dark);
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--cyan);
  padding: 2px 10px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.05em;
}
.live-badge {
  color: var(--red);
  font-weight: 700;
  font-size: 1rem;
  animation: pulse-live 1.5s infinite;
  white-space: nowrap;
}
.live-badge.off-air {
  color: var(--text-dim);
  animation: none;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.stream-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ccc;
  font-size: 1rem;
}
.viewer-count {
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 1rem;
}

/* 配信コンテンツ */
.stream-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  padding: 20px;
  gap: 20px;
  overflow-y: auto;
  min-height: 0;
  position: relative;
  align-items: flex-start;
}

.character-area {
  flex-shrink: 0;
  position: sticky;
  top: 0;
}
.character-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--green);
  background: rgba(255,255,255,0.05);
  transition: transform 0.3s;
  object-fit: cover;
}
.character-img.shake {
  animation: img-shake 0.5s ease-in-out;
}
@keyframes img-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-8px) rotate(-5deg); }
  50% { transform: translateX(8px) rotate(5deg); }
  75% { transform: translateX(-4px) rotate(-2deg); }
}
.character-img.spin {
  animation: img-spin 0.8s ease-in-out;
}
@keyframes img-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.3); }
  100% { transform: rotate(360deg) scale(1); }
}
.character-img.happy {
  animation: img-happy 0.6s ease-in-out;
}
@keyframes img-happy {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-10px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-6px); }
}

.narration-area {
  flex: 1;
  background: rgba(0,255,65,0.05);
  border: 1px solid rgba(0,255,65,0.15);
  border-radius: 8px;
  padding: 20px 24px;
  min-height: 120px;
}
#narration-text {
  font-size: 1.15rem;
  line-height: 2;
  white-space: pre-wrap;
}

/* ステータスバー */
.stats-bar {
  display: flex;
  gap: 20px;
  padding: 10px 18px;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}
.stat {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.stat-label {
  white-space: nowrap;
  color: var(--text-dim);
}
.stat-gauge {
  flex: 1;
  height: 10px;
  background: #222;
  border-radius: 5px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
  width: 0%;
}
.popularity-fill {
  background: linear-gradient(90deg, var(--cyan), var(--green));
}
.subscribers-fill {
  background: linear-gradient(90deg, var(--magenta), #ff8844);
}
.stat-value {
  min-width: 40px;
  text-align: right;
  font-weight: 700;
  font-size: 0.95rem;
}

/* 選択肢 */
.choices-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  flex-shrink: 0;
}
.choice-btn {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 1.05rem;
  padding: 14px 20px;
  background: rgba(0,255,65,0.05);
  color: var(--green);
  border: 1px solid rgba(0,255,65,0.3);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  line-height: 1.5;
}
.choice-btn::before {
  content: '▶';
  margin-right: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.choice-btn:hover {
  background: rgba(0,255,65,0.15);
  border-color: var(--green);
  padding-left: 30px;
}
.choice-btn:hover::before {
  opacity: 1;
}
.choice-btn:active {
  transform: scale(0.98);
}
/* 危険な選択肢 */
.choice-btn.danger {
  color: var(--red);
  border-color: rgba(255,50,50,0.3);
  background: rgba(255,50,50,0.05);
}
.choice-btn.danger:hover {
  background: rgba(255,50,50,0.15);
  border-color: var(--red);
}

/* チャット */
.chat-sidebar {
  width: 300px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  background: rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.chat-header {
  padding: 10px 16px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}
.chat-msg {
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 4px 8px;
  border-radius: 4px;
  animation: chat-slide-in 0.3s ease-out;
  word-break: break-all;
}
.chat-msg .chat-name {
  font-weight: 700;
  margin-right: 6px;
}
@keyframes chat-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* チャットの色バリエーション */
.chat-msg.color-0 .chat-name { color: var(--green); }
.chat-msg.color-1 .chat-name { color: var(--cyan); }
.chat-msg.color-2 .chat-name { color: var(--magenta); }
.chat-msg.color-3 .chat-name { color: var(--yellow); }
.chat-msg.color-4 .chat-name { color: #ff8844; }
.chat-msg.color-5 .chat-name { color: #88ff88; }

/* アンチコメント */
.chat-msg.anti {
  background: rgba(255,50,50,0.1);
}
.chat-msg.anti .chat-name {
  color: var(--red) !important;
}

/* スパチャ（チャット欄内） */
.chat-msg.superchat-chat {
  background: rgba(255,170,0,0.15);
  border: 1px solid rgba(255,170,0,0.3);
  font-weight: 700;
}

/* ==============================
   投げ銭（スーパーチャット）演出
   ============================== */
.superchat-popup {
  position: absolute;
  top: 10px;
  right: 20px;
  left: auto;
  transform: none;
  width: 320px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6), 0 0 20px rgba(255,170,0,0.3);
  z-index: 100;
  animation: superchat-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.superchat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  color: #fff;
  font-weight: 700;
}
.superchat-name {
  font-size: 0.9rem;
}
.superchat-amount {
  font-size: 1.1rem;
  font-family: 'Press Start 2P', monospace;
  text-shadow: 0 0 6px rgba(255,255,255,0.5);
}
.superchat-body {
  padding: 10px 16px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.5;
}

@keyframes superchat-slide-in {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.superchat-popup.superchat-fade-out {
  animation: superchat-fade 0.5s ease-out forwards;
}
@keyframes superchat-fade {
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* 病みシーン（配信後） */
.stream-layout.yami-mode {
  border-color: #333;
  box-shadow: 0 0 20px rgba(100,50,150,0.2), inset 0 0 100px rgba(50,0,80,0.1);
}
.stream-layout.yami-mode .narration-area {
  background: rgba(100,50,150,0.08);
  border-color: rgba(100,50,150,0.2);
}
.stream-layout.yami-mode .character-img {
  border-color: #666;
  filter: saturate(0.4) brightness(0.8);
}

/* Day切り替え演出 */
.day-transition {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: day-fade 2s ease-in-out forwards;
}
.day-transition h2 {
  font-family: 'Dela Gothic One', cursive;
  font-size: 3rem;
  color: var(--green);
  text-shadow: 0 0 30px rgba(0,255,65,0.5);
}
@keyframes day-fade {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* グリッチ演出（ゲーム中） */
.stream-content.glitch-effect {
  animation: content-glitch 0.6s ease-in-out;
}
@keyframes content-glitch {
  0%   { filter: none; transform: none; }
  10%  { filter: hue-rotate(90deg); transform: translateX(-3px); }
  20%  { filter: hue-rotate(0deg) saturate(2); transform: skewX(2deg); }
  30%  { filter: invert(1); transform: translateX(5px); }
  40%  { filter: none; transform: none; }
  50%  { filter: hue-rotate(180deg); transform: translateY(-2px); }
  60%  { filter: none; transform: skewX(-1deg); }
  100% { filter: none; transform: none; }
}

/* ==============================
   リザルト画面
   ============================== */
#result-screen {
  justify-content: center;
  gap: 24px;
  padding: 60px 40px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,0,255,0.08) 0%, transparent 50%),
    var(--bg-dark);
}
.result-title {
  font-family: 'Dela Gothic One', cursive;
  font-size: 2.2rem;
  color: var(--green);
  text-shadow: 0 0 20px rgba(0,255,65,0.4);
}
.result-card {
  background: var(--bg-mid);
  border: 2px solid var(--green);
  border-radius: 14px;
  padding: 36px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 30px rgba(0,255,65,0.1);
}
.result-emoji {
  font-size: 5rem;
  margin-bottom: 14px;
}
.result-rank {
  font-family: 'Dela Gothic One', cursive;
  font-size: 1.8rem;
  margin-bottom: 12px;
}
.result-description {
  font-size: 1rem;
  color: #bbb;
  line-height: 1.8;
  margin-bottom: 24px;
}
.result-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-stat {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  padding: 8px 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
}
.result-stat span:last-child {
  font-weight: 700;
  color: var(--green);
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* ===== レスポンシブ（スマホ） ===== */
@media (max-width: 700px) {
  #title-screen {
    padding: 40px 20px;
  }

  .glitch-text {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .cyber-btn {
    font-size: 1rem;
    padding: 12px 36px;
  }

  /* キャラ選択 */
  #select-screen {
    padding: 30px 16px;
  }

  .char-select-grid {
    width: min(100%, 320px);
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .char-card {
    width: 100%;
    padding: 16px;
  }

  .char-img-wrap {
    width: 100px;
  }

  .char-name {
    font-size: 1.1rem;
  }

  /* ゲーム画面 */
  #game-screen {
    padding: 40px 8px 8px;
  }

  .stream-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - 50px);
  }

  .chat-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: 200px;
  }

  .stream-header {
    padding: 8px 12px;
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 8px;
  }

  .stream-content {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .character-area {
    position: static;
    display: flex;
    justify-content: center;
  }

  .character-img {
    width: 70px;
    height: 70px;
  }

  #narration-text {
    font-size: 1rem;
    line-height: 1.8;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .stat {
    min-width: calc(50% - 4px);
    font-size: 0.8rem;
  }

  .choice-btn {
    font-size: 0.95rem;
    padding: 12px 14px;
  }

  /* スパチャ */
  .superchat-popup {
    width: 80%;
    max-width: 280px;
    right: 10px;
  }

  /* リザルト */
  #result-screen {
    padding: 40px 20px;
  }

  .result-title {
    font-size: 1.6rem;
  }

  .result-card {
    padding: 24px 16px;
  }

  .result-emoji {
    font-size: 3.5rem;
  }

  .day-transition h2 {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .glitch-text {
    font-size: 1.6rem;
  }

  .select-title {
    font-size: 1.3rem;
  }

  .stat {
    min-width: 100%;
  }
}
