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

:root {
  --primary-color: #ff9f1c;
  --secondary-color: #2ec4b6;
  --accent-red: #e71d36;
  --accent-purple: #7209b7;
  --bg-dark: #0f172a;
  --text-light: #ffffff;
}

body {
  font-family: 'M PLUS Rounded 1c', 'Outfit', sans-serif;
  background: #0f172a;
  background-image: 
    radial-gradient(circle at 50% 20%, rgba(46, 196, 182, 0.15), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(255, 159, 28, 0.1), transparent 50%);
  color: #ffffff;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  touch-action: manipulation;
}

#game-container {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 8px 12px;
}

/* ヘッダー */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.portal-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.portal-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  border-color: #2ec4b6;
}

.header-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ff9f1c, #ffe66d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 16px rgba(255, 159, 28, 0.3);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 言語切替スイッチ (JP / EN) */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
  padding: 3px 6px;
  gap: 3px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn:hover {
  color: #ffffff;
}

.lang-btn.active {
  background: linear-gradient(135deg, #00f0ff, #0284c7);
  color: #0b0f19;
  box-shadow: 0 2px 8px rgba(0, 240, 255, 0.4);
}

.lang-divider {
  color: #64748b;
  font-size: 11px;
}

/* 遊び方・アイテムボタン */
.guide-btn-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(46, 196, 182, 0.15);
  border: 1px solid rgba(46, 196, 182, 0.4);
  color: #2ec4b6;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 12px;
}

.guide-btn-badge:hover {
  background: rgba(46, 196, 182, 0.28);
  border-color: #2ec4b6;
  box-shadow: 0 0 12px rgba(46, 196, 182, 0.4);
}

.guide-link-btn {
  background: rgba(46, 196, 182, 0.15) !important;
  border-color: rgba(46, 196, 182, 0.4) !important;
  color: #2ec4b6 !important;
}

.guide-link-btn:hover {
  background: rgba(46, 196, 182, 0.3) !important;
  box-shadow: 0 4px 15px rgba(46, 196, 182, 0.4) !important;
}

.ranking-btn-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #ffd700;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 12px;
}

.ranking-btn-badge:hover {
  background: rgba(255, 215, 0, 0.28);
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Canvas ラッパー */
#canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1e293b;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(255, 255, 255, 0.1);
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

/* スマホ用タップエフェクト */
#tap-effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.tap-circle {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.7) 0%, rgba(255, 159, 28, 0) 70%);
  transform: translate(-50%, -50%) scale(0.2);
  animation: tapRipple 0.4s ease-out forwards;
  pointer-events: none;
}

@keyframes tapRipple {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* iPhone クラッシュ演出 */
#iphone-glitch-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 60, 0.25);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
  pointer-events: none;
}

#iphone-glitch-overlay.active {
  display: flex;
  animation: glitchShake 0.15s ease-in-out infinite alternate;
}

.crack-svg-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.crack-line {
  stroke: #ffffff;
  stroke-width: 4;
  fill: none;
  filter: drop-shadow(0 0 6px #00f0ff);
  stroke-linecap: round;
}

.crack-core {
  fill: rgba(255, 255, 255, 0.85);
  filter: drop-shadow(0 0 10px #ffffff);
}

.glitch-text {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 900;
  color: #ff0055;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 24px;
  border-radius: 10px;
  border: 2px solid #ff0055;
  text-shadow: 0 0 20px #ff0055, 2px 2px #fff;
  letter-spacing: 2px;
}

@keyframes glitchShake {
  0% { transform: translate(-3px, 2px) rotate(-0.5deg); }
  100% { transform: translate(3px, -2px) rotate(0.5deg); }
}

/* わたあめ演出 */
#cotton-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 182, 193, 0.3);
  z-index: 39;
  pointer-events: none;
}

#cotton-overlay.active {
  display: flex;
  animation: pulsePink 0.3s alternate infinite ease-in-out;
}

.cotton-bubble {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #ff69b4;
  border-radius: 20px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(255, 105, 180, 0.5);
  transform: translateY(-20px);
  animation: bubbleBounce 0.4s ease-out forwards;
}

.raccoon-bubble-img {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ff69b4;
  background: #fff;
}

.bubble-speech {
  color: #d81b60;
  font-weight: 900;
  font-size: clamp(14px, 3.2vw, 18px);
  line-height: 1.3;
}

.bubble-sub {
  font-size: 12px;
  font-weight: 700;
  color: #880e4f;
}

@keyframes pulsePink {
  0% { background: rgba(255, 182, 193, 0.2); }
  100% { background: rgba(255, 182, 193, 0.45); }
}

@keyframes bubbleBounce {
  0% { transform: translateY(10px) scale(0.8); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* お皿スリップ演出 */
#plate-overlay {
  position: absolute;
  bottom: 25%;
  left: 20%;
  display: none;
  z-index: 39;
  pointer-events: none;
}

#plate-overlay.active {
  display: block;
  animation: slipPop 0.5s ease-out forwards;
}

.slip-text {
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 900;
  color: #ffeb3b;
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid #ffeb3b;
  padding: 6px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(255, 235, 59, 0.5);
  transform: rotate(-8deg);
}

@keyframes slipPop {
  0% { transform: scale(0.6) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.15) rotate(-10deg); opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}

/* オーバーレイスクリーン（スタート/リザルト/モーダル共通） */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px;
  z-index: 50;
  text-align: center;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  box-sizing: border-box;
}

.overlay-screen.active {
  display: flex;
}

/* スクロールバーの共通スタイリング */
.overlay-screen::-webkit-scrollbar {
  width: 5px;
}

.overlay-screen::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.overlay-screen::-webkit-scrollbar-thumb {
  background: rgba(46, 196, 182, 0.5);
  border-radius: 3px;
}

/* スタート画面 */
#start-screen {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 12px 10px 24px;
}

.start-screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: auto 0;
  padding: 4px 0 16px;
  box-sizing: border-box;
}
.title-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 5px 14px;
  background: rgba(46, 196, 182, 0.2);
  color: #2ec4b6;
  border: 1px solid rgba(46, 196, 182, 0.4);
  border-radius: 9999px;
  margin-bottom: 10px;
}

.game-main-title {
  font-size: clamp(22px, 4.5vw, 36px);
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 12px;
  color: #ffffff;
}

.accent-title {
  background: linear-gradient(135deg, #ff9f1c, #ffe66d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(255, 159, 28, 0.5);
}

.hero-character-preview {
  margin: 6px 0 12px;
}

.hero-img,
.hero-canvas {
  width: clamp(140px, 25vw, 190px);
  height: auto;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: heroFloat 2.5s ease-in-out infinite alternate;
}

@keyframes heroFloat {
  0% { transform: translateY(0px) rotate(-1deg); }
  100% { transform: translateY(-8px) rotate(1deg); }
}

.instruction-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 16px;
  max-width: 480px;
  width: 90%;
  margin-bottom: 14px;
  font-size: clamp(11px, 2.3vw, 13px);
  text-align: left;
}

.inst-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inst-badge {
  background: #ff9f1c;
  color: #000;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.badge-raccoon {
  background: #2ec4b6;
  color: #000;
}

.action-btn {
  background: linear-gradient(135deg, #ff9f1c, #ff6b35);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: clamp(16px, 3.5vw, 22px);
  font-weight: 900;
  padding: 12px 36px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.action-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(255, 107, 53, 0.6);
}

.action-btn:active {
  transform: translateY(1px) scale(0.98);
}

.start-pulse {
  animation: startPulseAnim 1.6s infinite;
}

@keyframes startPulseAnim {
  0% { box-shadow: 0 0 0 0 rgba(255, 159, 28, 0.7); }
  70% { box-shadow: 0 0 0 16px rgba(255, 159, 28, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 159, 28, 0); }
}

.key-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 10px;
}

/* リザルト画面 */
#result-screen {
  padding: 8px 10px;
  overflow-y: auto;
  box-sizing: border-box;
}

.result-card {
  background: rgba(30, 41, 59, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 10px 18px;
  max-width: 460px;
  width: 94%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rank-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #000;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
  letter-spacing: 0.5px;
}

.rank-badge.rank-s {
  background: linear-gradient(135deg, #ffd700, #ff6b35);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 107, 53, 0.4);
}

.rank-badge.rank-a {
  background: linear-gradient(135deg, #2ec4b6, #0e8388);
  color: #fff;
  box-shadow: 0 0 12px rgba(46, 196, 182, 0.6);
}

.rank-badge.rank-b {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.rank-badge.rank-c {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
  box-shadow: 0 0 8px rgba(148, 163, 184, 0.5);
}

.result-title {
  font-size: clamp(17px, 3.5vw, 22px);
  font-weight: 900;
  background: linear-gradient(135deg, #ffe66d, #ff9f1c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.clear-time-container {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 10px;
  margin-bottom: 6px;
}

.time-label {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 1.5px;
}

.time-value {
  font-family: 'Outfit', monospace;
  font-size: clamp(22px, 4.5vw, 30px);
  font-weight: 900;
  color: #00f0ff;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
  letter-spacing: 1.5px;
  line-height: 1.1;
}

.item-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.summary-col {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.item-emoji {
  font-size: 15px;
  margin-bottom: 0px;
}

.item-name {
  font-size: 9px;
  color: #cbd5e1;
}

.item-count {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #ff9f1c;
}

.result-evaluation {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.3;
  margin-bottom: 8px;
  min-height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.result-buttons .action-btn {
  font-size: 13px;
  padding: 7px 16px;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.result-buttons .ranking-link-btn {
  font-size: 12px;
  padding: 7px 14px;
}

.portal-return-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 9999px;
  transition: all 0.2s;
}

.portal-return-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #2ec4b6;
}

/* スマホ用コントロールバー（下部） */
#mobile-control-bar {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-jump-btn {
  position: relative;
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, #2ec4b6, #0e8388);
  border: none;
  border-radius: 16px;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(46, 196, 182, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 0.08s ease, filter 0.08s ease;
}

.mobile-jump-btn:active {
  transform: scale(0.97);
  filter: brightness(1.15);
}

.jump-btn-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.jump-btn-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.jump-btn-text {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.jump-btn-sub {
  font-size: 12px;
  font-weight: 700;
  color: #c7f9cc;
}

.mobile-item-guide {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.guide-chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #cbd5e1;
}

.chip-icon {
  font-size: 13px;
}

.chip-gold {
  border-color: rgba(255, 215, 0, 0.4);
  color: #ffe66d;
}

.chip-warn {
  border-color: rgba(255, 75, 75, 0.4);
  color: #ff9999;
}

/* レスポンシブ調整 */
@media (min-width: 768px) {
  #mobile-control-bar {
    display: none; /* PC環境では画面内またはスペースキーで操作するため非表示、またはコンパクト化 */
  }
  
  #game-container {
    padding: 16px;
  }
}

/* 難易度セレクター */
.difficulty-select-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.diff-label {
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
}

.diff-buttons {
  display: flex;
  gap: 8px;
}

.diff-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-btn .diff-icon {
  font-size: 14px;
}

.diff-btn .diff-text {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
}

.diff-btn .diff-desc {
  font-size: 10px;
  opacity: 0.8;
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.diff-btn.active[data-diff="NORMAL"] {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border-color: #34d399;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.5);
}

.diff-btn.active[data-diff="HARD"] {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #ffffff;
  border-color: #f87171;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
}

/* スタート画面ボタングループ */
.start-btn-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.ranking-link-btn {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #ffd700;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  padding: 12px 20px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ranking-link-btn:hover {
  background: rgba(255, 215, 0, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

/* リザルト画面難易度タグ */
.result-diff-tag {
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.result-diff-tag.diff-hard {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

/* ランクイン時の名前入力フォーム */
.rankin-box {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 107, 53, 0.15));
  border: 2px dashed rgba(255, 215, 0, 0.6);
  border-radius: 10px;
  padding: 5px 10px;
  margin-bottom: 6px;
  animation: rankinPulse 2s infinite ease-in-out;
}

@keyframes rankinPulse {
  0%, 100% { border-color: rgba(255, 215, 0, 0.6); }
  50% { border-color: rgba(255, 107, 53, 0.9); }
}

.rankin-badge {
  font-size: 11px;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  margin-bottom: 1px;
}

.rankin-prompt {
  font-size: 10px;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.rankin-input-group {
  display: flex;
  gap: 6px;
  justify-content: center;
}

#player-name-input {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 6px;
  padding: 3px 8px;
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  width: 130px;
  height: 28px;
  box-sizing: border-box;
  text-align: center;
  outline: none;
}

#player-name-input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rankin-submit-btn {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  border: none;
  border-radius: 6px;
  padding: 3px 12px;
  color: #000;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  height: 28px;
  box-sizing: border-box;
  transition: transform 0.15s;
}

.rankin-submit-btn:hover {
  transform: scale(1.05);
}

/* ランキング閲覧モーダル */
.ranking-modal-screen {
  background: rgba(15, 23, 42, 0.94);
  z-index: 60;
  padding: 8px 10px;
  overflow-y: auto;
  box-sizing: border-box;
}

.ranking-card {
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 16px;
  padding: 10px 16px;
  max-width: 500px;
  width: 95%;
  max-height: 94%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.15);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-title {
  font-size: clamp(15px, 3.2vw, 19px);
  font-weight: 900;
  background: linear-gradient(135deg, #ffd700, #ff9f1c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.ranking-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.ranking-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.ranking-tab.active[data-tab="NORMAL"] {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border-color: #34d399;
}

.ranking-tab.active[data-tab="HARD"] {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  border-color: #f87171;
}

.ranking-list-container {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 6px;
  flex: 1;
  min-height: 0;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 215, 0, 0.5) rgba(255, 255, 255, 0.05);
}

.ranking-list-container::-webkit-scrollbar {
  width: 5px;
}

.ranking-list-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.ranking-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.5);
  border-radius: 3px;
}

.ranking-table-header {
  display: flex;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ranking-row {
  display: flex;
  align-items: center;
  padding: 6px 6px;
  border-radius: 6px;
  margin-bottom: 3px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s;
}

.ranking-row.highlight {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.5);
}

.col-rank { width: 55px; display: flex; align-items: center; gap: 4px; }
.col-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-time { width: 90px; text-align: right; font-family: 'Outfit', monospace; font-weight: 900; color: #00f0ff; }
.col-score { width: 45px; text-align: right; font-weight: 900; color: #ffd700; }

.rank-medal-1 { color: #ffd700; font-size: 14px; }
.rank-medal-2 { color: #c0c0c0; font-size: 14px; }
.rank-medal-3 { color: #cd7f32; font-size: 14px; }

.ranking-close-action {
  font-size: 13px;
  padding: 7px 24px;
}

/* 遊び方＆アイテム図鑑モーダル */
.guide-modal-screen {
  background: rgba(15, 23, 42, 0.94);
  z-index: 65;
  padding: 8px 10px;
  overflow-y: auto;
  box-sizing: border-box;
}

.guide-card {
  background: rgba(30, 41, 59, 0.97);
  border: 1px solid rgba(46, 196, 182, 0.4);
  border-radius: 16px;
  padding: 10px 16px;
  max-width: 540px;
  width: 95%;
  max-height: 94%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(46, 196, 182, 0.15);
  box-sizing: border-box;
}

.guide-content-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 196, 182, 0.5) rgba(255, 255, 255, 0.05);
}

.guide-content-scroll::-webkit-scrollbar {
  width: 5px;
}

.guide-content-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.guide-content-scroll::-webkit-scrollbar-thumb {
  background: rgba(46, 196, 182, 0.5);
  border-radius: 3px;
}

.guide-section {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}

.guide-sec-title {
  font-size: 12px;
  font-weight: 900;
  color: #2ec4b6;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sec-title-danger {
  color: #f87171 !important;
}

.guide-text {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
  margin: 0;
}

.guide-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 159, 28, 0.3);
  border-radius: 8px;
  padding: 6px 8px;
}

.action-card-raccoon {
  border-color: rgba(46, 196, 182, 0.3);
}

.action-card .action-badge {
  font-size: 10px;
  font-weight: 900;
  color: #ff9f1c;
  margin-bottom: 2px;
}

.action-card-raccoon .action-badge {
  color: #2ec4b6;
}

.action-card .action-key {
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 2px;
}

.action-card .action-desc {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.35;
  margin: 0;
}

.guide-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-info-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 5px 8px;
}

.item-card-gold {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.03));
}

.item-card-danger {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.08), rgba(255, 255, 255, 0.03));
}

.item-badge-visual {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.badge-apple {
  background: radial-gradient(circle, #ef4444, #991b1b);
  border: 2px solid #ffffff;
}

.badge-grape {
  background: radial-gradient(circle, #a855f7, #581c87);
  border: 2px solid #ffffff;
}

.badge-fries {
  background: radial-gradient(circle, #fbbf24, #92400e);
  border: 2px solid #fef08a;
  border-radius: 8px;
}

.badge-muscat {
  background: radial-gradient(circle, #34d399, #064e3b);
  border: 2px solid #6ee7b7;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.badge-cotton {
  background: radial-gradient(circle, #f472b6, #9d174d);
  border: 2px solid #fbcfe8;
}

.badge-plate {
  background: #f8fafc;
  border: 2px solid #1e3a8a;
}

.badge-phone {
  background: #0f172a;
  border: 2px solid #94a3b8;
  border-radius: 6px;
}

.item-info-body {
  flex: 1;
}

.item-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 1px;
}

.item-info-name {
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
}

.item-tag {
  font-size: 9px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.tag-score {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.tag-boost {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.tag-maxboost {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.5);
}

.tag-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.item-info-desc {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.35;
  margin: 0;
}

.guide-card .modal-footer {
  margin-top: 4px;
}

@media (max-width: 600px) {
  .portal-link span,
  .ranking-btn-text,
  .guide-btn-text {
    display: none;
  }
  .guide-action-grid {
    grid-template-columns: 1fr;
  }

  /* スマホ縦画面でのスタート画面最適化 */
  .title-badge {
    font-size: 10px;
    padding: 3px 10px;
    margin-bottom: 4px;
    letter-spacing: 1px;
  }

  .game-main-title {
    font-size: 18px;
    margin-bottom: 4px;
    line-height: 1.25;
  }

  .hero-character-preview {
    margin: 2px 0 6px;
  }

  .hero-img,
  .hero-canvas {
    width: 130px;
    height: auto;
  }

  .difficulty-select-container {
    padding: 4px 10px;
    margin-bottom: 6px;
    gap: 6px;
  }

  .diff-label {
    font-size: 11px;
  }

  .diff-btn {
    padding: 4px 10px;
  }

  .diff-btn .diff-text {
    font-size: 11px;
  }

  .instruction-box {
    padding: 6px 10px;
    margin-bottom: 6px;
    gap: 4px;
    font-size: 10px;
  }

  .inst-item {
    gap: 6px;
  }

  .inst-badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .start-btn-group {
    gap: 6px;
  }

  .start-btn-group .action-btn {
    font-size: 14px;
    padding: 8px 22px;
  }

  .start-btn-group .ranking-link-btn {
    font-size: 11px;
    padding: 7px 12px;
  }

  .key-hint {
    font-size: 10px;
    margin-top: 6px;
  }
}

@media (max-width: 480px) {
  #game-container {
    padding: 4px;
  }

  .game-header {
    margin-bottom: 4px;
    padding: 4px 8px;
  }

  .header-title {
    font-size: 12px;
  }

  .guide-btn-badge,
  .ranking-btn-badge {
    padding: 6px 8px;
  }

  .mobile-jump-btn {
    padding: 14px 16px;
  }

  .jump-btn-text {
    font-size: 18px;
  }

  .jump-btn-icon {
    font-size: 22px;
  }

  .guide-chip {
    font-size: 10px;
    padding: 4px 6px;
  }

  .diff-desc {
    display: none;
  }
}

/* ========================================================
   広告コンテナ (AdMax: PC / スマホ対応)
   ======================================================== */
.ad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  width: 100%;
  max-width: 960px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 6px 10px;
  min-height: 60px;
  box-sizing: border-box;
}

.ad-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #94a3b8;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  overflow: hidden;
}

.ad-slot iframe {
  max-width: 100% !important;
}

.ad-pc-only {
  display: flex;
}

.ad-sp-only {
  display: none !important;
}

@media (max-width: 768px) {
  .ad-pc-only {
    display: none !important;
  }
  .ad-sp-only {
    display: flex !important;
  }
  .ad-container {
    margin-top: 8px;
    padding: 6px 4px 8px;
    min-height: 55px;
  }
}

