* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    padding-bottom: 5rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin: 0;
}

.progress {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

.comparison-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    min-height: 500px;
}

.book-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    width: 300px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.book-card.selected {
    background-color: #e3f2fd;
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.book-cover {
    position: relative;
    width: 100%;
    height: 340px;
    margin: 1rem 0 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.book-cover img {
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
}

.reload-cover {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
}

.book-cover:hover .reload-cover {
    display: flex;
}

.reload-cover:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.reload-cover:active {
    transform: scale(0.9);
}

.book-info {
    text-align: center;
    padding: 0.5rem 0.5rem;
}

.book-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    line-height: 1.3;
}

.book-author {
    color: #666;
    font-size: 1.125rem;
}

.vs-badge {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    border-radius: 50%;
    font-weight: bold;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ranking-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ranking-container h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.button {
    background: #2c3e50;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.button:hover {
    background: #34495e;
}

.hidden {
    display: none;
}

#ranking-list {
    margin-bottom: 1.5rem;
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    gap: 1rem;
}

.rank-item:last-child {
    border-bottom: none;
}

.rank-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    min-width: 2rem;
}

.rank-cover {
    width: 60px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.rank-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-info {
    flex-grow: 1;
}

/* Add desktop styles for rank-info h3 and p */
.rank-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.15rem;
    line-height: 1.1;
}

.rank-info p {
    font-size: 0.95rem;
    margin-top: 0;
    line-height: 1.2;
    font-style: normal;
    color: #666;
}

.error-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
    max-width: 800px;
}

.error-container h2 {
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error-content {
    color: #2c3e50;
}

.error-help {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.error-help h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.error-help ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.error-help li {
    margin-bottom: 0.5rem;
}

.error-help code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.error-help pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    font-family: monospace;
    white-space: pre-wrap;
}

.stats {
    display: none;
}

.vs-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 0 1rem;
}

.vs-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.skip-button {
    background: transparent;
    border: 1px solid #ccc;
    color: #666;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.skip-button kbd {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
}

.skip-button:hover {
    background-color: #f5f5f5;
    border-color: #999;
    color: #333;
}

.skip-button.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
    color: #0d47a1;
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.message {
    display: none;
}

.message.hidden {
    display: none;
}

.secondary-button {
    background: white;
    color: #2c3e50;
    border: 1px solid #2c3e50;
}

.secondary-button:hover {
    background: #f8f9fa;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.ranking-header h2 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.8rem;
}

#view-list-btn {
    margin-top: 1rem;
}

.book-stats {
    font-size: 0.9em;
    color: #666;
    margin-top: 0.5rem;
}

.keyboard-shortcuts {
    display: none;
}

.keyboard-shortcut-hint {
    margin-top: 0.5rem;
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

.keyboard-shortcut-hint kbd {
    font-size: 0.9em;
}

kbd {
    background-color: #f7f7f7;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
    color: #333;
    display: inline-block;
    font-family: monospace;
    font-size: 0.9em;
    line-height: 1;
    padding: 3px 6px;
    margin: 0 2px;
}

.book-choice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.book-choice-container .keyboard-shortcut-hint {
    margin-top: 0;
}

.shortcut-container {
    display: none;
}

.ranking-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.button kbd {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 6px;
    box-shadow: none;
    border: none;
    padding: 2px 4px;
}

#cover-progress-container,
.progress-bar,
.progress-fill,
.progress-text {
    display: none;
}

.completion-message {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.completion-message h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.completion-message p {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 0;
}

.completion-message .refine-hint {
    margin-top: 1rem;
    font-size: 1rem;
    color: #3498db;
    font-style: italic;
    padding: 0.75rem;
    border-top: 1px solid #eee;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Reset animation */
@keyframes reset-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.7;
        background-color: #f8f9fa;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.reset-animation {
    animation: reset-pulse 0.5s ease-in-out;
}

/* Notification system */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    padding: 12px 20px;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slide-in 0.3s ease-out;
    max-width: 300px;
    background-color: white;
    border: 1px solid #ccc;
}

.notification.info {
    background-color: #e3f2fd;
    border-color: #2196f3;
    color: #0d47a1;
}

.notification.success {
    background-color: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.5);
    color: #1e8449;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.notification.error {
    background-color: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.5);
    color: #a93226;
}

.notification.fade-out {
    animation: fade-out 0.3s ease-in forwards;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    header {
        margin-bottom: 2rem;
        gap: 0.75rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .progress {
        font-size: 0.95rem;
    }
    
    #view-list-btn {
        margin-top: 0;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .comparison-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .book-card {
        width: 100%;
        max-width: 240px;
        padding: 0.5rem;
    }
    
    .book-cover {
        height: auto;
        margin: 0.5rem 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .book-cover img {
        width: 100%;
        height: auto;
        max-height: 240px;
        object-fit: contain;
    }
    
    .book-info {
        display: none;
    }
    
    .book-title {
        font-size: 1.1rem;
    }
    
    .book-author {
        font-size: 1rem;
    }
    
    .vs-container {
        margin: 0.25rem 0;
    }
    
    .action-buttons {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    .keyboard-shortcut-hint {
        display: none;
    }
    
    .book-choice-container {
        gap: 0.5rem;
    }
    
    .skip-button {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .rank-item {
        padding: 0.75rem 0.5rem 0.75rem 0.5rem;
        gap: 0.5rem;
    }
    
    .rank-number {
        font-size: 1.2rem;
        min-width: 1.2rem;
        margin-right: 0.2rem;
        margin-left: 0.1rem;
    }
    
    .rank-info {
        flex-grow: 1;
        overflow: hidden;
        padding-right: 0;
    }
    
    .rank-info h3 {
        font-size: 1rem;
        margin-bottom: 0.1rem;
        padding-top: 0;
        line-height: 1.1;
    }
    
    .rank-info p {
        font-size: 0.9rem;
        margin-top: -0.1rem;
        line-height: 1.2;
    }
    
    .book-stats {
        font-size: 0.75em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .rank-cover {
        width: 50px;
        height: 75px;
    }
    
    .ranking-container {
        padding: 1.25rem 0.75rem;
    }
    
    .ranking-header {
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }
    
    .ranking-header h2 {
        font-size: 1.5rem;
        margin-left: 0.1rem;
    }
    
    .ranking-actions {
        gap: 0.5rem;
        margin: 0;
    }
    
    .button {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    #notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .notification {
        max-width: 100%;
    }
    
    .completion-message {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
    }
    
    .completion-message h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .completion-message p {
        font-size: 1rem;
    }
    
    .completion-message .refine-hint {
        font-size: 0.9rem;
        padding: 0.5rem 0 0 0;
        margin-top: 0.75rem;
    }
    
    .main-nav {
        gap: 0.5rem;
    }
    
    .skip-button kbd {
        display: none;
    }
    
    .container {
        padding: 1rem 1rem;
        padding-bottom: 3rem;
    }
    
    .books-container {
        padding: 0.5rem 0.25rem;
    }
}

/* Print styles for ranking view */
@media print {
    /* Hide elements not needed for printing */
    .progress, 
    #comparison-view,
    .ranking-actions,
    #view-list-btn,
    .action-buttons,
    #notification-container,
    .skip-button,
    .button,
    h2 {
        display: none !important;
    }
    
    /* Reset page margins and background */
    @page {
        margin: 1.5cm;
        size: portrait;
    }
    
    body {
        background-color: white;
        color: black;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Ensure the ranking container takes full width and has no shadows */
    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .ranking-container {
        background: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
        width: 100%;
    }
    
    /* Style the ranking header for print */
    .ranking-header {
        border-bottom: 2px solid #000;
        margin-bottom: 1cm;
        padding-bottom: 0.3cm;
    }
    
    .ranking-header h2 {
        font-size: 24pt;
        text-align: center;
        color: #2c3e50;
        font-weight: bold;
        width: 100%; /* Ensure full width */
    }
    
    /* Create a two-column layout for the ranking list */
    #ranking-list {
        margin-bottom: 0;
        column-count: 2;
        column-gap: 1cm;
        column-fill: balance;
        overflow: visible;
    }
    
    /* Keep each rank item together on the same page and in the same column */
    .rank-item {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        -webkit-column-break-inside: avoid !important;
        display: inline-block; /* Safari fix */
        width: 100%;
        padding: 0.4cm 0;
        border-bottom: 1px solid #ccc;
        margin-bottom: 0.2cm;
        overflow: visible;
    }
    
    /* Ensure rank item content is properly laid out */
    .rank-item-content {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    /* Make sure the last item in each column doesn't have a border */
    .rank-item:nth-child(5),
    .rank-item:last-child {
        border-bottom: none;
    }
    
    /* Adjust rank item elements for print */
    .rank-number {
        font-size: 18pt;
        font-weight: bold;
        min-width: 1cm;
        text-align: right;
        color: #2c3e50;
        margin-right: 0.3cm;
    }
    
    .rank-cover {
        width: 1.5cm;
        height: 2.2cm;
        margin-right: 0.3cm;
        box-shadow: none;
        border: 1px solid black;
        border-radius: 3px;
        overflow: hidden;
        flex-shrink: 0;
    }
    
    .rank-info {
        flex-grow: 1;
        overflow: hidden;
    }
    
    .rank-info h3 {
        font-size: 12pt;
        margin-bottom: 0.05cm;
        color: #2c3e50;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-top: 0;
        line-height: 1.1;
    }
    
    .rank-info p {
        font-size: 10pt;
        font-style: italic;
        color: #555;
        margin-bottom: 0.1cm;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: -0.05cm;
        line-height: 1.2;
    }
    
    .book-stats {
        font-size: 8pt;
        color: #666;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Show completion message if present */
    .completion-message {
        background: none;
        box-shadow: none;
        text-align: center;
        margin-bottom: 1cm;
        padding: 0;
        column-span: all; /* Make sure it spans across both columns */
        page-break-before: always;
    }
    
    .completion-message h2 {
        font-size: 18pt;
        color: #2c3e50;
    }
    
    .completion-message p {
        font-size: 12pt;
        color: #555;
    }
    
    /* Hide refine hint in completion message */
    .completion-message .refine-hint {
        display: none;
    }
    
    /* Force page breaks every 10 items */
    .rank-item:nth-child(10n) {
        page-break-after: always;
    }
}

/* Landscape orientation for mobile devices */
@media (max-width: 926px) and (orientation: landscape) {
    .container {
        padding: 1rem;
    }
    
    .comparison-container {
        flex-direction: row;
        justify-content: space-around;
        align-items: stretch;
        gap: 0.5rem;
        min-height: 0;
        padding: 0;
        margin-bottom: 1rem;
    }
    
    .book-card {
        width: 31%;
        max-width: none;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        height: auto;
    }
    
    .book-cover {
        height: 0;
        padding-bottom: 140%; /* Aspect ratio for book covers */
        position: relative;
        margin: 0 0 0.5rem 0;
    }
    
    .book-cover img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    .vs-container {
        margin: 0;
        padding: 0;
        flex-shrink: 0;
        width: auto;
        gap: 0.5rem;
    }
    
    .vs-badge {
        width: 32px;
        height: 32px;
        padding: 0;
        font-size: 0.8rem;
    }
    
    /* Show minimal book info */
    .book-info {
        display: block;
        padding: 0;
        flex-grow: 1;
    }
    
    .book-title {
        font-size: 0.8rem;
        margin-bottom: 0.2rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }
    
    .book-author {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0;
}

.nav-button {
    background: white;
    color: #2c3e50;
    border: 1px solid #2c3e50;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.nav-button:hover {
    background: #f8f9fa;
}

.nav-button.active {
    background: #2c3e50;
    color: white;
}

.books-container {
    padding: 2rem 1rem;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2rem;
    padding: 1rem;
}

.grid-book-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.grid-book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.grid-book-cover {
    position: relative;
    width: 100%;
    height: 340px;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-book-cover img {
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
}

.grid-book-info {
    text-align: center;
    padding: 0.5rem;
}

.grid-book-title {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: #2c3e50;
    line-height: 1.3;
}

.grid-book-author {
    color: #666;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .main-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .nav-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .books-container {
        padding: 0.5rem 0.25rem;
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem;
    }
    
    .grid-book-card {
        padding: 0.5rem;
    }
    
    .grid-book-cover {
        height: 180px;
        margin: 0.25rem 0;
    }
    
    .grid-book-title {
        font-size: 0.9rem;
        margin-bottom: 0.15rem;
    }
    
    .grid-book-author {
        font-size: 0.8rem;
    }
}

@media print {
    .main-nav {
        display: none;
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1cm;
    }
    
    .grid-book-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .grid-book-cover {
        height: 2.2cm;
    }
    
    .grid-book-title {
        font-size: 12pt;
    }
    
    .grid-book-author {
        font-size: 10pt;
    }
}

.error-highlight {
    animation: error-pulse 0.3s ease-in-out;
    background-color: rgba(231, 76, 60, 0.15) !important;
    border-color: rgba(231, 76, 60, 0.5) !important;
    color: #a93226 !important;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.3) !important;
}

@keyframes error-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(231, 76, 60, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(231, 76, 60, 0.3);
    }
} 