/* ========================================
   Custom Font
======================================== */
@font-face {
  font-family: 'MihoyoZenZero';
  src: url('../font/mihoyo-zenzero.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ========================================
   Reset & Base
======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #f4f4f9;
  --surface:     #ffffff;
  --surface2:    #eeeeee;
  --accent:      #ffcc00;
  --accent2:     #4a90e2;
  --text:        #333333;
  --text-muted:  #888888;
  --correct:     #4caf50;
  --wrong:       #f44336;
  --border:      #dddddd;
  --font:        'MihoyoZenZero', 'Hiragino Kaku Gothic ProN', 'Meiryo', 'Yu Gothic', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

/* ========================================
   Screens
======================================== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* ========================================
   Loading
======================================== */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-muted);
  font-size: 14px;
}

/* ========================================
   Quiz Screen
======================================== */
.quiz-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px 110px;
  overflow-y: auto;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 12px;
  padding-left: 48px; /* ハンバーガーボタン分のオフセット */
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.title-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 20px;
  font-weight: bold;
  color: #333;
  letter-spacing: 0.05em;
}

.timer {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-muted);
  transition: color 0.3s;
  min-width: 80px;
  text-align: right;
  margin-left: auto;
}

.timer.urgent {
  color: var(--wrong);
  animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: 0.4; }
}

/* ========================================
   Zoom Container
======================================== */
.zoom-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  max-height: min(360px, calc(100vh - 360px));
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface);
  flex-shrink: 0;
  margin: 8px auto 12px;
}

#zoomCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.step-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--accent);
  font-size: 13px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* ========================================
   Answer Form
======================================== */
.answer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.input-field::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.input-field:focus {
  border-color: var(--accent2);
}

.input-field:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.submit-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent2);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  -webkit-appearance: none;
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.submit-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}

/* ========================================
   Feedback
======================================== */
.correct-message {
  text-align: center;
  font-size: 32px;
  font-weight: bold;
  color: var(--correct);
  padding: 14px 0 4px;
  animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
}

@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.correct-count {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding-top: 10px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

/* ========================================
   Result Screen
======================================== */
.result-container {
  width: 100%;
  max-width: 480px;
  padding: 40px 24px 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.result-title {
  font-size: 30px;
  font-weight: bold;
  color: var(--wrong);
  text-align: center;
  letter-spacing: 0.1em;
}

.top3-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top3-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  animation: slideIn 0.3s ease-out both;
}

.top3-item:nth-child(1) { animation-delay: 0.05s; }
.top3-item:nth-child(2) { animation-delay: 0.12s; }
.top3-item:nth-child(3) { animation-delay: 0.19s; }

@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

.top3-rank {
  font-size: 24px;
  min-width: 36px;
  text-align: center;
}

.top3-name {
  font-size: 18px;
  font-weight: bold;
  word-break: break-all;
}

.top3-score {
  font-size: 14px;
  color: var(--accent);
  font-weight: normal;
  margin-left: 4px;
}

.top3-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 20px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.answer-reveal {
  font-size: 22px;
  font-weight: bold;
  color: var(--text);
  text-align: center;
  background: var(--surface2);
  border-radius: 10px;
  padding: 16px 24px;
  width: 100%;
}

.answer-reveal .label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.answer-image-container {
  width: 100%;
  height: 40vh;
  max-height: 300px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface);
}

.answer-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.next-countdown {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

/* ========================================
   フッター
======================================== */
.site-footer {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.site-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.8;
  transition: opacity 0.2s;
  text-decoration: none;
}

.site-footer a:hover {
  opacity: 1;
}

.site-footer img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
}

.footer-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.footer-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========================================
   コメントオーバーレイ
======================================== */
.comment-overlay {
  position: fixed;
  top: 65px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 40vh;
  max-height: 300px;
  min-height: 180px;
  pointer-events: none;
  overflow: hidden;
  z-index: 500;
}

@keyframes flyComment {
  from { left: 105%; }
  to   { left: -105%; }
}

.fly-comment {
  position: absolute;
  white-space: nowrap;
  font-size: 20px;
  font-weight: bold;
  animation: flyComment 8s linear forwards;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0 0 6px #000;
  pointer-events: none;
}

.fly-comment--admin {
  text-decoration: underline;
}

/* ========================================
   チャット入力
======================================== */
.chat-section {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 800;
  background: var(--bg);
  padding: 6px 0;
}

.chat-color-wrap {
  position: relative;
  flex-shrink: 0;
}

.color-toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.color-palette {
  position: absolute;
  bottom: 36px;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 130px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.color-palette.hidden {
  display: none;
}

.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(128, 128, 128, 0.3);
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.color-btn:hover {
  transform: scale(1.2);
}

.color-btn.selected {
  border-color: var(--accent2);
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #333;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, opacity 0.2s;
}

.chat-send-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}
