* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 30px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
}

.main-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.hero {
    text-align: center;
    padding: 60px 0;
}

.hero-content h2 {
    font-size: 36px;
    margin-bottom: 15px;
    color: #333;
}

.hero-content p {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.cta-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(220, 53, 69, 0.4);
}

.btn-danger:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 53, 69, 0.1);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.book-card {
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.warning-text {
    color: #dc3545;
    font-size: 14px;
    margin-top: 10px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin: 60px 0;
}

.feature-card {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 15px;
}

.feature-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.feature-card h3 {
    margin-bottom: 10px;
    color: #333;
}

.feature-card p {
    color: #666;
    font-size: 14px;
}

.preset-books h2 {
    margin-bottom: 20px;
    color: #333;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.book-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.book-cover {
    font-size: 60px;
    text-align: center;
    margin-bottom: 15px;
}

.book-info h3 {
    font-size: 16px;
    margin-bottom: 5px;
    color: #333;
}

.book-type {
    font-size: 12px;
    color: #666;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 10px;
}

.auth-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: none;
}

.message.success {
    display: block;
    background: #d4edda;
    color: #155724;
}

.message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.books-section {
    margin-bottom: 40px;
}

.books-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.empty {
    text-align: center;
    color: #666;
    padding: 20px;
}

.loading {
    text-align: center;
    color: #666;
    padding: 20px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.book-detail {
    margin-bottom: 30px;
}

.book-header {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 15px;
}

.book-cover-large {
    font-size: 80px;
}

.book-meta h1 {
    margin-bottom: 10px;
}

.preset-badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    margin-left: 10px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-content {
    padding: 20px 0;
}

.hidden {
    display: none !important;
}

.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chapter-item:hover {
    background: #e9ecef;
}

.chapter-order {
    font-weight: 600;
    color: #667eea;
    margin-right: 15px;
}

.chapter-title {
    flex: 1;
}

.chapter-arrow {
    color: #667eea;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.character-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.char-avatar {
    font-size: 40px;
}

.char-info h4 {
    margin-bottom: 5px;
}

.char-role {
    font-size: 12px;
    color: #666;
}

.protagonist-badge {
    background: #ffc107;
    color: #333;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 5px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.plot-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.card-icon {
    font-size: 30px;
}

.card-info h4 {
    font-size: 14px;
    margin-bottom: 3px;
}

.card-type {
    font-size: 11px;
    color: #666;
}

.reading-view {
    max-width: 800px;
    margin: 0 auto;
}

.chapter-content h1 {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.story-text {
    font-size: 18px;
    line-height: 1.8;
    color: #333;
}

.puzzle-section {
    margin-top: 40px;
}

.puzzle-card {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
}

.puzzle-card h3 {
    margin-bottom: 15px;
}

.puzzle-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.option-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-btn:hover {
    background: #667eea;
    color: white;
}

.puzzle-input {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin: 15px 0;
}

.puzzle-message {
    margin-top: 15px;
    font-weight: 600;
}

.puzzle-message.success {
    color: #155724;
}

.puzzle-message.error {
    color: #721c24;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.footer {
    text-align: center;
    padding: 30px 0;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}

@keyframes flip {
    0% { transform: perspective(400px) rotateY(0); }
    100% { transform: perspective(400px) rotateY(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-15px); }
    60% { transform: translateY(-7px); }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.8), 0 0 30px rgba(102, 126, 234, 0.6);
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes cardDrop {
    0% {
        opacity: 0;
        transform: translateY(-100px) rotateZ(-10deg);
    }
    60% {
        opacity: 1;
        transform: translateY(10px) rotateZ(5deg);
    }
    80% {
        transform: translateY(-5px) rotateZ(-2deg);
    }
    100% {
        transform: translateY(0) rotateZ(0);
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.5s ease-out forwards;
}

.animate-slide-down {
    animation: slideDown 0.5s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-flip {
    animation: flip 0.8s ease-in-out;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-bounce {
    animation: bounce 1s ease-in-out;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-card-drop {
    animation: cardDrop 0.8s ease-out forwards;
}

.animate-shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.card-hover-3d {
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
}

.card-hover-3d:hover {
    transform: perspective(1000px) rotateY(10deg) rotateX(5deg) scale(1.05);
}

.card-selected {
    animation: heartbeat 1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
}

.card-reward {
    animation: cardDrop 0.8s ease-out forwards;
}

.card-reward::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 1.5rem;
    animation: sparkle 1s ease-in-out infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.page-transition {
    animation: fadeIn 0.3s ease-out;
}

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .hero-content h2 {
        font-size: 24px;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .book-header {
        flex-direction: column;
        text-align: center;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
}

.card-reward-modal,
.card-discard-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-reward-modal .modal-backdrop,
.card-discard-modal .modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.card-reward-modal .modal-content,
.card-discard-modal .modal-content {
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid rgba(255, 215, 0, 0.5);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.card-fly-in {
  animation: cardFlyIn 0.8s ease-out;
}

@keyframes cardFlyIn {
  0% { 
    opacity: 0; 
    transform: scale(0.1) translateY(-100vh); 
  }
  50% { 
    opacity: 1; 
    transform: scale(1.2) translateY(0); 
  }
  100% { 
    transform: scale(1) translateY(0); 
  }
}

.reward-card {
  position: relative;
  width: 180px;
  height: 240px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #2a2a4a 0%, #1a1a3a 100%);
  border: 3px solid rgba(255, 215, 0, 0.6);
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.card-glow {
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
  border-radius: 18px;
  animation: glowPulse 1.5s ease-in-out infinite;
  z-index: -1;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.reward-card .card-icon {
  font-size: 64px;
  margin-bottom: 10px;
}

.reward-card .card-name {
  font-size: 24px;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 5px;
}

.reward-card .card-type {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.reward-message {
  font-size: 18px;
  color: #fff;
  margin-bottom: 20px;
}

.btn-receive,
.btn-continue {
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  color: #1a1a2e;
  border: none;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-receive:hover,
.btn-continue:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.card-discard-modal .modal-content {
  max-width: 600px;
}

.card-discard-modal .modal-header h3 {
  color: #ffd700;
  margin-bottom: 10px;
}

.card-discard-modal .modal-header p {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 20px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.cards-grid .card-item {
  background: linear-gradient(135deg, #2a2a4a 0%, #1a1a3a 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.cards-grid .card-item:hover {
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateY(-3px);
}

.cards-grid .card-item.selected {
  border-color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  transform: scale(1.05);
}

.cards-grid .card-item .new-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff6b6b;
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
}

.cards-grid .card-item .card-icon {
  font-size: 32px;
  margin-bottom: 5px;
}

.cards-grid .card-item .card-name {
  font-size: 12px;
  color: #fff;
}

.card-discard-modal .modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 30px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-discard {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: white;
  border: none;
  padding: 10px 30px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-discard:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-discard:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 107, 107, 0.5);
}

.preset-notice {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid rgba(255, 215, 0, 0.5);
  border-radius: 15px;
  padding: 20px 30px;
  text-align: center;
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

.preset-notice p {
  color: #fff;
  margin-bottom: 10px;
}

.preset-notice button {
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  color: #1a1a2e;
  border: none;
  padding: 10px 25px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
}
