/* =====================================================
   爆鯱タイムアタック - メインスタイル
   カラー: 赤(#c4002f) + 金(#c9a44c) + 白ベース
   ===================================================== */

:root {
  --red: #c4002f;
  --red-dark: #900020;
  --red-light: #ff1a4a;
  --gold: #c9a44c;
  --gold-light: #f0c060;
  --gold-dark: #8a6a20;
  --white: #ffffff;
  --off-white: #fff8f0;
  --gray-light: #f5f0ea;
  --gray: #999;
  --black: #1a1a1a;
  --shadow: rgba(0,0,0,0.15);
  --shadow-strong: rgba(0,0,0,0.35);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--off-white);
  color: var(--black);
  user-select: none;
  -webkit-user-select: none;
}

/* ===================== SCREENS ===================== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity 0.3s ease;
}
.screen.hidden {
  display: none;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 50px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.03em;
  text-decoration: none;
  font-family: inherit;
}
.btn:active {
  transform: scale(0.95);
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: var(--white);
  font-size: 22px;
  padding: 20px 40px;
  box-shadow: 0 6px 20px rgba(196, 0, 47, 0.4);
  width: 100%;
  max-width: 340px;
}
.btn-primary:active { background: var(--red-dark); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--white);
  font-size: 18px;
  padding: 16px 32px;
  box-shadow: 0 4px 16px rgba(201, 164, 76, 0.5);
  width: 100%;
  max-width: 340px;
}

.btn-white {
  background: var(--white);
  color: var(--red);
  font-size: 16px;
  padding: 14px 28px;
  border: 2px solid var(--red);
  width: 100%;
  max-width: 340px;
}

.btn-outline {
  background: transparent;
  color: var(--gray);
  font-size: 14px;
  padding: 10px 20px;
  border: 1.5px solid #ddd;
  border-radius: 50px;
}

/* ===================== TITLE SCREEN ===================== */
#screen-title {
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
}

.title-logo {
  text-align: center;
  margin-bottom: 8px;
  animation: floatY 3s ease-in-out infinite;
}
.title-logo .emoji-big {
  font-size: 72px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
.title-main {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  line-height: 1.1;
  margin-top: 8px;
}
.title-sub {
  font-size: 14px;
  opacity: 0.85;
  margin-top: 4px;
  letter-spacing: 0.08em;
}
.store-badge {
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  margin: 12px 0;
  backdrop-filter: blur(4px);
}
.store-label {
  opacity: 0.7;
  font-size: 11px;
}
.store-name {
  font-weight: 700;
  font-size: 15px;
}

.title-cards {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.mini-card {
  background: rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 12px 14px;
  text-align: center;
  flex: 1;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.25);
}
.mini-card .num {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}
.mini-card .label {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.title-disclaimer {
  font-size: 11px;
  opacity: 0.6;
  text-align: center;
  margin-top: 12px;
}

/* ===================== STORE SELECT ===================== */
#screen-store {
  background: var(--off-white);
}
.store-select-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--red);
  margin-bottom: 8px;
  text-align: center;
}
.store-list {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.store-item {
  background: var(--white);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 8px var(--shadow);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}
.store-item:active {
  border-color: var(--red);
  background: #fff0f3;
  transform: scale(0.98);
}

/* ===================== COUNTDOWN ===================== */
#screen-countdown {
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
}
.countdown-num {
  font-size: 160px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: countPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.countdown-text {
  font-size: 24px;
  font-weight: 700;
  opacity: 0.9;
  margin-top: 16px;
  letter-spacing: 0.1em;
}
@keyframes countPop {
  0% { transform: scale(2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===================== GAME SCREEN ===================== */
#screen-game {
  background: var(--off-white);
  padding: 0;
  justify-content: flex-start;
  overflow: hidden;
}

.game-header {
  width: 100%;
  background: var(--white);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  position: relative;
  z-index: 10;
}

.timer-display {
  font-size: 36px;
  font-weight: 900;
  color: var(--red);
  min-width: 64px;
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.timer-display.warning {
  animation: timerPulse 0.5s ease-in-out infinite alternate;
  color: var(--red-light);
}
@keyframes timerPulse {
  to { transform: scale(1.1); }
}

.score-display {
  text-align: right;
}
.score-label {
  font-size: 10px;
  color: var(--gray);
  letter-spacing: 0.06em;
}
.score-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--black);
  line-height: 1;
}

.multiplier-badge {
  background: var(--gold);
  color: var(--white);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  display: none;
}
.multiplier-badge.active { display: block; }

/* GAUGES */
.gauge-area {
  width: 100%;
  padding: 8px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--white);
  border-bottom: 1px solid #eee;
}
.gauge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gauge-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.gauge-bar-bg {
  flex: 1;
  height: 14px;
  background: var(--gray-light);
  border-radius: 7px;
  overflow: hidden;
}
.gauge-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.15s ease;
}
.gauge-spicy .gauge-bar-fill {
  background: linear-gradient(90deg, #ff6b00, #c4002f);
}
.gauge-muse .gauge-bar-fill {
  background: linear-gradient(90deg, #8b5cf6, #4c1d95);
}
.gauge-val {
  font-size: 12px;
  font-weight: 700;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* GAME STAGE */
.game-stage {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* RAMEN BOWL */
.ramen-bowl {
  position: relative;
  width: 200px;
  height: 200px;
  transition: transform 0.1s;
}
.bowl-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.2));
}
.ramen-steam {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}
.steam-puff {
  font-size: 24px;
  animation: steamRise 2s ease-in-out infinite;
  opacity: 0.7;
}
.steam-puff:nth-child(2) { animation-delay: 0.7s; }
.steam-puff:nth-child(3) { animation-delay: 1.4s; }
@keyframes steamRise {
  0% { transform: translateY(0) scale(0.8); opacity: 0.7; }
  100% { transform: translateY(-20px) scale(1.2); opacity: 0; }
}

/* ITEMS */
.item-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.game-item {
  position: absolute;
  font-size: 32px;
  cursor: pointer;
  pointer-events: all;
  transition: transform 0.1s;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
  animation: itemFloat 1s ease-in-out infinite alternate;
}
.game-item:active { transform: scale(0.8) !important; }
@keyframes itemFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

/* SPURT TAP AREA */
.tap-area {
  position: absolute;
  inset: 0;
  cursor: pointer;
  z-index: 5;
}

/* SPURT FX */
.tap-fx {
  position: absolute;
  pointer-events: none;
  font-size: 20px;
  font-weight: 900;
  color: var(--gold);
  animation: tapFxUp 0.6s ease-out forwards;
  z-index: 20;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
@keyframes tapFxUp {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(0.5); opacity: 0; }
}

/* BAKASHARACHI MODE */
.baka-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  display: none;
  border: 6px solid var(--red);
  box-shadow: inset 0 0 60px rgba(196, 0, 47, 0.5);
  animation: bakaBorder 0.3s ease-in-out infinite alternate;
}
.baka-overlay.active { display: block; }
@keyframes bakaBorder {
  to { box-shadow: inset 0 0 100px rgba(255, 50, 50, 0.7); }
}

.baka-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--red), #ff0040);
  color: var(--white);
  font-size: 28px;
  font-weight: 900;
  padding: 12px 24px;
  border-radius: 16px;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(196,0,47,0.6);
  animation: bakaBannerPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
  z-index: 40;
  letter-spacing: 0.05em;
}
@keyframes bakaBannerPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.flame-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  display: none;
  overflow: hidden;
}
.flame-container.active { display: block; }

.flame-particle {
  position: absolute;
  bottom: 0;
  font-size: 28px;
  animation: flameUp 1.5s ease-in infinite;
  opacity: 0.9;
}
@keyframes flameUp {
  0% { transform: translateY(0) scale(1) rotate(-5deg); opacity: 0.9; }
  100% { transform: translateY(-120px) scale(0.3) rotate(10deg); opacity: 0; }
}

/* MUSE FREEZE */
.muse-overlay {
  position: absolute;
  inset: 0;
  background: rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  z-index: 50;
  pointer-events: none;
  animation: museShake 0.1s ease-in-out infinite alternate;
  display: none;
}
.muse-overlay.active { display: flex; }
@keyframes museShake {
  from { transform: translateX(-3px); }
  to { transform: translateX(3px); }
}

/* LAST SPURT */
.lastspurt-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, var(--red), var(--gold));
  color: var(--white);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  padding: 8px;
  z-index: 45;
  display: none;
  letter-spacing: 0.1em;
  animation: lastSpurtPulse 0.5s ease-in-out infinite alternate;
}
.lastspurt-banner.active { display: block; }
@keyframes lastSpurtPulse {
  to { background: linear-gradient(90deg, var(--gold), var(--red)); }
}

/* DISTANCE DISPLAY */
.distance-display {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: var(--white);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 10;
}

/* SCREEN SHAKE */
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-2px, 4px); }
  80% { transform: translate(2px, -4px); }
}
.shaking {
  animation: screenShake 0.2s ease-in-out;
}

/* ===================== RESULT SCREEN ===================== */
#screen-result {
  background: var(--off-white);
  justify-content: flex-start;
  padding-top: 0;
  overflow-y: auto;
}

.result-scroll {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

.result-header {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  color: var(--white);
  box-shadow: 0 8px 32px rgba(196,0,47,0.3);
}
.result-title-badge {
  font-size: 13px;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 14px;
  display: inline-block;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.result-score {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.result-score-label {
  font-size: 14px;
  opacity: 0.8;
  letter-spacing: 0.1em;
}
.result-title-text {
  font-size: 22px;
  font-weight: 900;
  margin: 8px 0 4px;
  letter-spacing: 0.04em;
}
.result-stats-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.85;
}

/* CARD BUTTONS */
.card-btns {
  display: flex;
  gap: 10px;
}
.card-btn {
  flex: 1;
  background: var(--white);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  border: 2px solid #eee;
  font-size: 13px;
  font-weight: 700;
  color: var(--black);
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px var(--shadow);
}
.card-btn:active {
  border-color: var(--gold);
  background: #fffbf0;
  transform: scale(0.97);
}
.card-btn .icon { font-size: 24px; }

/* SHARE SECTION */
.share-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* NICKNAME */
.nickname-section {
  background: var(--white);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}
.nickname-label {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 8px;
  letter-spacing: 0.06em;
}
.nickname-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.nickname-display {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--black);
}
.nickname-input {
  flex: 1;
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  display: none;
}
.nickname-edit-btn {
  background: var(--gray-light);
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--black);
  font-family: inherit;
}
.nickname-save-btn {
  background: var(--red);
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--white);
  font-family: inherit;
  display: none;
}

/* RANKING */
.ranking-section {
  background: var(--white);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}
.ranking-tabs {
  display: flex;
  border-bottom: 2px solid #eee;
}
.ranking-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--gray);
  transition: all 0.15s;
  border: none;
  background: transparent;
  font-family: inherit;
}
.ranking-tab.active {
  color: var(--red);
  border-bottom: 3px solid var(--red);
  margin-bottom: -2px;
}
.ranking-list {
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
}
.ranking-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  transition: background 0.1s;
}
.ranking-item.me {
  background: rgba(196,0,47,0.07);
}
.ranking-rank {
  font-size: 18px;
  font-weight: 900;
  min-width: 32px;
  text-align: center;
}
.ranking-rank.top1 { color: #ffd700; }
.ranking-rank.top2 { color: #c0c0c0; }
.ranking-rank.top3 { color: #cd7f32; }
.ranking-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-score {
  font-size: 17px;
  font-weight: 900;
  color: var(--red);
}
.ranking-diff {
  font-size: 11px;
  color: var(--gray);
  text-align: right;
}
.my-rank-banner {
  background: rgba(196,0,47,0.08);
  border-top: 1px solid rgba(196,0,47,0.15);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  text-align: center;
}

.ranking-empty {
  padding: 24px;
  text-align: center;
  color: var(--gray);
  font-size: 14px;
}

/* PLAY LIMIT */
.play-limit-notice {
  background: rgba(201,164,76,0.15);
  border: 1.5px solid var(--gold);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--gold-dark);
  text-align: center;
  display: none;
}
.play-limit-notice.show { display: block; }

/* CANVAS RESULT */
#result-canvas {
  display: none;
}

/* ===================== LOADING ===================== */
#screen-loading {
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
}
.loading-emoji {
  font-size: 64px;
  animation: loadingSpin 1s linear infinite;
}
@keyframes loadingSpin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-size: 18px;
  font-weight: 700;
  margin-top: 16px;
  opacity: 0.9;
}

/* ===================== ERROR ===================== */
#screen-error {
  background: var(--off-white);
}
.error-emoji { font-size: 64px; }
.error-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--red);
  margin: 16px 0 8px;
}
.error-msg {
  font-size: 14px;
  color: var(--gray);
  text-align: center;
  line-height: 1.6;
  max-width: 300px;
}

/* ===================== UTILITIES ===================== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: var(--white);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
}

/* ITEM POPUP */
.item-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: var(--white);
  border-radius: 20px;
  padding: 20px 32px;
  text-align: center;
  z-index: 100;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}
.item-popup.show {
  transform: translate(-50%, -50%) scale(1);
}
.item-popup .item-emoji { font-size: 48px; }
.item-popup .item-name {
  font-size: 16px;
  font-weight: 700;
  margin-top: 6px;
}
.item-popup .item-effect {
  font-size: 13px;
  color: var(--gray);
  margin-top: 4px;
}

/* SCROLL styles for result */
.result-scroll::-webkit-scrollbar { width: 4px; }
.result-scroll::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

@media (max-height: 680px) {
  .countdown-num { font-size: 120px; }
  .result-score { font-size: 54px; }
  .ramen-bowl { width: 160px; height: 160px; }
}
