* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #1b2a1a;
  --bg-accent: #27401f;
  --accent: #8bc34a;
  --accent-dark: #5a8f2f;
  --text: #f3f7ec;
  --card-bg: #fbfdf6;
  --card-text: #27401f;
  --ok: #4caf50;
  --ng: #e53935;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    sans-serif;
  background: radial-gradient(circle at 50% 20%, var(--bg-accent), var(--bg));
  color: var(--text);
  user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 画面共通 */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* タイトル・説明 */
.title {
  font-size: clamp(32px, 9vw, 64px);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.desc {
  font-size: clamp(16px, 4.5vw, 22px);
  line-height: 1.8;
}

.hint {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--accent);
  animation: blink 1.3s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 8px 18px;
  min-width: 84px;
}

.hud-label {
  font-size: 13px;
  opacity: 0.8;
}

.hud-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
}

#time.warning {
  color: var(--ng);
  animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* カウントダウン */
.countdown-number {
  font-size: clamp(100px, 40vw, 240px);
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  animation: countPop 0.6s ease-out;
}

@keyframes countPop {
  0% { transform: scale(0.2); opacity: 0; }
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* カード */
.cards {
  display: flex;
  gap: clamp(12px, 4vw, 32px);
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 760px;
}

.card {
  flex: 1 1 0;
  max-width: 220px;
  aspect-ratio: 3 / 4;
  background: var(--card-bg);
  color: var(--card-text);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 800;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 4px;
}

.card:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

/* 次に押すべきカードを控えめに示す */
.card.next {
  outline: 4px solid var(--accent);
  outline-offset: -4px;
}

.card.cleared {
  background: var(--accent);
  color: #fff;
  opacity: 0.6;
}

/* フィードバック（○×） */
.feedback {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(140px, 55vw, 360px);
  font-weight: 900;
  pointer-events: none;
}

.feedback.ok {
  color: var(--ok);
  animation: popSymbol 0.5s ease-out;
}

.feedback.ng {
  color: var(--ng);
  animation: shakeSymbol 0.5s ease-out;
}

@keyframes popSymbol {
  0% { transform: scale(0.3); opacity: 0; }
  40% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shakeSymbol {
  0% { transform: scale(0.5) rotate(0); opacity: 0; }
  30% { transform: scale(1.2) rotate(-8deg); opacity: 1; }
  50% { transform: scale(1.1) rotate(8deg); }
  70% { transform: scale(1.1) rotate(-6deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* フリーズ中のオーバーレイ */
.game-screen.frozen .cards {
  pointer-events: none;
  filter: grayscale(0.6) brightness(0.8);
}

/* 結果 */
.result-title {
  font-size: clamp(36px, 10vw, 72px);
  font-weight: 900;
  color: var(--ng);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.result-score {
  font-size: clamp(18px, 5vw, 26px);
  line-height: 1.8;
}

.final-score {
  font-size: clamp(48px, 16vw, 96px);
  font-weight: 900;
  color: var(--accent);
}
