:root {
  --rarity-n: #aaaaaa;
  --rarity-r: #00ccff;
  --rarity-sr: #bc00ff;
  --rarity-ur: #ffd700;
  --rarity-ssr: #ff0055;
  
  --bg-dark: #0a0510;
  --glass: rgba(10, 5, 16, 0.85);
  --glass-border: rgba(0, 255, 255, 0.2);
}

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

body {
  font-family: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
  background-color: var(--bg-dark);
  color: #fff;
  overflow: hidden; height: 100vh; width: 100vw;
}

#app {
  width: 100%; height: 100%;
  background: radial-gradient(circle at center, #1a103c 0%, var(--bg-dark) 100%);
  position: relative; display: flex; flex-direction: column;
  overflow-y: auto;
}

.back-link {
  position: absolute; top: 15px; left: 15px; z-index: 100;
  background: rgba(0,0,0,0.6); color: #00ffff;
  padding: 8px 16px; border-radius: 20px; font-weight: 800; font-size: 0.85rem;
  text-decoration: none; border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px); box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.game-container {
  flex: 1; display: flex; flex-direction: column;
  max-width: 600px; width: 100%; margin: 0 auto;
  padding: 60px 15px 20px 15px;
}

/* Header Panel */
.header-panel {
  display: flex; justify-content: space-between; align-items: stretch;
  background: var(--glass); padding: 15px 20px; border-radius: 20px;
  border: 1px solid var(--glass-border); backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 255, 255, 0.1);
  margin-bottom: 30px;
}

.balance-box { display: flex; flex-direction: column; }
.balance-box .label { font-size: 0.7rem; font-weight: 800; color: #00ffff; letter-spacing: 1px; }
.balance-box .value { font-size: 1.5rem; font-weight: 900; color: #fff; }

.collection-btn {
  background: rgba(0, 255, 255, 0.1); border: 1px solid #00ffff; color: #00ffff;
  font-weight: 800; font-size: 0.8rem; padding: 0 15px; border-radius: 12px;
  cursor: pointer; transition: all 0.2s;
}
.collection-btn:active { background: #00ffff; color: #000; }

.progress-panel {
  display: grid; grid-template-columns: 1fr 1fr 140px; gap: 10px;
  margin: -16px 0 18px;
}

.progress-item,
.daily-ticket-btn {
  min-height: 50px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.42); display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff;
}

.progress-item span {
  color: #aaa; font-size: 0.64rem; font-weight: 900; letter-spacing: 1px;
}

.progress-item b {
  color: #ffd700; font-size: 1rem; font-weight: 900;
}

.daily-ticket-btn {
  cursor: pointer; color: #071015; background: linear-gradient(135deg, #ffd700, #00ffff);
  font-weight: 900; font-size: 0.78rem; box-shadow: 0 8px 20px rgba(0,255,255,0.18);
}

.daily-ticket-btn:disabled {
  cursor: not-allowed; opacity: 0.55; filter: grayscale(1);
}

/* Machine Display */
.machine-wrapper {
  flex: 1; position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}

.machine-glow {
  position: absolute; width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(0, 255, 255, 0.3) 0%, transparent 70%);
  border-radius: 50%; z-index: 0; filter: blur(20px);
  animation: pulse-machine 3s infinite alternate;
}

@keyframes pulse-machine {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.1); opacity: 1; }
}

.capsule-container {
  position: relative; z-index: 10;
  width: 150px; height: 150px; background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(0,0,0,0.5));
  border-radius: 50%; border: 3px solid rgba(0, 255, 255, 0.5);
  display: flex; justify-content: center; align-items: center;
  box-shadow: inset 0 0 30px rgba(0, 255, 255, 0.3), 0 15px 30px rgba(0,0,0,0.6);
  transition: all 0.1s;
}

.capsule-container.shaking {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both infinite;
  border-color: #fff; box-shadow: inset 0 0 50px #fff;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0) rotate(-5deg); }
  20%, 80% { transform: translate3d(4px, 0, 0) rotate(5deg); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0) rotate(-10deg); }
  40%, 60% { transform: translate3d(8px, 0, 0) rotate(10deg); }
}

.capsule {
  font-size: 5rem; font-weight: 900; color: rgba(255,255,255,0.8);
  text-shadow: 0 0 20px rgba(0,255,255,0.5);
}

.rates-info {
  margin-top: 30px; font-size: 0.75rem; font-weight: 800; color: #aaa;
  background: rgba(0,0,0,0.4); padding: 8px 15px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1); z-index: 10;
}

.boost-info {
  margin-top: 8px;
  color: #ffd700;
  font-size: 0.85rem;
  font-weight: 900;
  z-index: 10;
}

.gacha-message {
  margin-top: 10px; color: rgba(255,255,255,0.78); font-size: 0.78rem;
  font-weight: 700; text-align: center; min-height: 20px; z-index: 10;
}

/* Action Area */
.action-area {
  display: flex; gap: 15px; margin-top: 20px;
}

.pull-btn {
  flex: 1; padding: 20px 10px; border-radius: 20px; border: none;
  cursor: pointer; transition: all 0.15s; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
}
.pull-btn:active:not(:disabled) { transform: scale(0.95); }
.pull-btn:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; }

.pull-btn.single {
  background: linear-gradient(135deg, #2a5298, #1e3c72);
  box-shadow: 0 8px 25px rgba(30, 60, 114, 0.5);
}
.pull-btn.multi {
  background: linear-gradient(135deg, #bc00ff, #00ccff);
  box-shadow: 0 8px 25px rgba(188, 0, 255, 0.5);
}

.pull-title { font-size: 1.2rem; font-weight: 900; color: #fff; letter-spacing: 1px; }
.pull-cost { font-size: 0.9rem; font-weight: 800; color: rgba(255,255,255,0.8); }

.history-panel {
  margin-top: 14px; padding: 12px; border-radius: 16px; background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.09);
}

.history-title {
  font-size: 0.68rem; font-weight: 900; letter-spacing: 1px; color: #00ffff;
  margin-bottom: 8px;
}

.pull-history {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; min-height: 48px;
}

.history-chip {
  min-width: 0; padding: 7px 6px; border-radius: 10px; background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.12); display: grid; grid-template-columns: auto 1fr;
  column-gap: 5px; row-gap: 1px; align-items: center;
}

.history-chip span { font-size: 1.1rem; }
.history-chip b { font-size: 0.68rem; font-weight: 900; }
.history-chip small {
  grid-column: 1 / -1; color: #aaa; font-size: 0.58rem; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.empty-history {
  grid-column: 1 / -1; color: #777; font-size: 0.78rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.rarity-border-N { border-color: rgba(170,170,170,0.35); }
.rarity-border-R { border-color: rgba(0,204,255,0.5); }
.rarity-border-SR { border-color: rgba(188,0,255,0.5); }
.rarity-border-UR { border-color: rgba(255,215,0,0.6); }
.rarity-border-SSR { border-color: rgba(255,0,85,0.75); }

/* Overlays */
.overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.9); backdrop-filter: blur(15px);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000; transition: opacity 0.3s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.reveal-content {
  text-align: center; width: 90%; max-width: 400px;
  transform: scale(0.8); transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.overlay:not(.hidden) .reveal-content { transform: scale(1); }

.rarity-text { font-size: 3rem; font-weight: 900; margin-bottom: -10px; font-style: italic; }
.reveal-emoji { font-size: 8rem; margin: 20px 0; animation: float-reveal 3s infinite ease-in-out; }

@keyframes float-reveal {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.cat-name { font-size: 1.8rem; font-weight: 900; color: #fff; margin-bottom: 10px; }
.cat-desc { font-size: 0.9rem; color: #aaa; margin-bottom: 30px; line-height: 1.4; }

.close-btn {
  width: 100%; padding: 15px; border-radius: 15px; border: none;
  background: #fff; color: #000; font-weight: 900; font-size: 1.1rem;
  cursor: pointer;
}
.close-btn:active { background: #ccc; }

/* Rarity Styles */
.rarity-N { color: var(--rarity-n); text-shadow: 0 0 15px var(--rarity-n); }
.rarity-R { color: var(--rarity-r); text-shadow: 0 0 20px var(--rarity-r); }
.rarity-SR { color: var(--rarity-sr); text-shadow: 0 0 30px var(--rarity-sr); }
.rarity-UR { color: var(--rarity-ur); text-shadow: 0 0 40px var(--rarity-ur); }
.rarity-SSR { 
  color: #fff; text-shadow: 0 0 50px var(--rarity-ssr); 
  animation: ssr-flash 0.5s infinite alternate;
}

@keyframes ssr-flash {
  0% { text-shadow: 0 0 30px #ff0055, 0 0 50px #bc00ff; }
  100% { text-shadow: 0 0 50px #ff0055, 0 0 80px #ffd700; }
}

/* Multi Pull Grid */
.multi-pull-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 25px;
}
.multi-item {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border-radius: 10px; border: 1px solid rgba(255,255,255,0.1);
}
.multi-item .e { font-size: 2rem; }
.multi-item .r { font-size: 0.6rem; font-weight: 900; margin-top: 5px; }
.multi-item small { color: #aaa; font-size: 0.54rem; font-weight: 900; }
.multi-item.new-item { background: rgba(255, 215, 0, 0.12); }

/* Collection Modal */
.collection-modal {
  width: 95%; max-width: 500px; max-height: 85vh; background: var(--glass);
  border-radius: 25px; border: 1px solid var(--glass-border);
  display: flex; flex-direction: column; overflow: hidden;
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.modal-header h2 { font-size: 1.2rem; font-weight: 900; color: #00ffff; }
.icon-btn { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }

.collection-stats { padding: 15px 20px; font-weight: 800; color: #aaa; font-size: 0.9rem; text-align: center; background: rgba(0,0,0,0.3); }
.collection-boost-line { display: block; margin-top: 6px; color: #ffd700; }

.collection-grid {
  flex: 1; overflow-y: auto; padding: 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 15px;
}

.col-item {
  aspect-ratio: 1; background: rgba(0,0,0,0.5); border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.1); transition: transform 0.2s;
}
.col-item:hover { transform: scale(1.05); }
.col-item.locked { filter: grayscale(1); opacity: 0.3; }
.col-item .c-emoji { font-size: 2.5rem; }
.col-item .c-rarity { font-size: 0.6rem; font-weight: 900; margin-top: 5px; }
.col-item .c-name {
  width: 100%; padding: 0 4px; color: #ddd; font-size: 0.56rem; font-weight: 800;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 520px) {
  .game-container { padding: 56px 12px 12px; }
  .header-panel { margin-bottom: 22px; padding: 12px 14px; }
  .progress-panel { grid-template-columns: 1fr 1fr; }
  .daily-ticket-btn { grid-column: 1 / -1; min-height: 44px; }
  .machine-wrapper { justify-content: flex-start; padding-top: 8px; }
  .capsule-container { width: 124px; height: 124px; }
  .capsule { font-size: 4rem; }
  .rates-info { margin-top: 20px; }
  .pull-history { grid-template-columns: repeat(2, 1fr); }
  .action-area { margin-top: 14px; }
  .pull-btn { padding: 16px 8px; border-radius: 16px; }
}
