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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Allow body to grow taller than viewport on large screens */
@media (min-width: 769px) {
    body {
        align-items: flex-start;
        padding: 40px 20px;
    }
}

/* Pokedex Container */
.pokedex-container {
    background: linear-gradient(145deg, #dc3545, #bd2130);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.2);
    max-width: 800px;
    width: 100%;
    border: 3px solid #8b1a1a;
}

/* Header */
.pokedex-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #8b1a1a;
}

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

.light {
    border-radius: 50%;
    box-shadow: 
        inset 0 -2px 5px rgba(0, 0, 0, 0.3),
        0 2px 5px rgba(0, 0, 0, 0.3);
}

.light-big {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #6dd5ed, #2193b0);
    border: 3px solid #1a5f7a;
    animation: pulse 2s infinite;
}

.light-small {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.light-small.red {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c92a2a);
}

.light-small.yellow {
    background: radial-gradient(circle at 30% 30%, #ffd93d, #f9ca24);
}

.light-small.green {
    background: radial-gradient(circle at 30% 30%, #6bcf7f, #2ecc71);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.title {
    color: #fff;
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    flex: 1;
}

.header-hinge {
    width: 30px;
    height: 30px;
    background: #333;
    border-radius: 50%;
    border: 3px solid #666;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Main Screen */
.pokedex-screen {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.5),
        0 5px 15px rgba(0, 0, 0, 0.3);
}

.screen-border {
    background: #1a1a1a;
    border-radius: 10px;
    padding: 8px;
    box-shadow: 
        inset 0 2px 5px rgba(0, 0, 0, 0.8),
        0 2px 5px rgba(255, 255, 255, 0.1);
}

.screen-content {
    background: #9fcdcd;
    min-height: 400px;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    color: #1a1a1a;
    overflow-y: auto;
    max-height: 500px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Custom scrollbar for webkit browsers */
.screen-content::-webkit-scrollbar {
    width: 8px;
}

.screen-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Pet Grid */
.pet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

/* Better grid behavior on larger screens */
@media (min-width: 769px) {
    .pokedex-container {
        max-width: 1000px;
    }
    
    .screen-content {
        min-height: 500px;
        max-height: 650px;
    }
    
    .pet-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (min-width: 1024px) {
    .pokedex-container {
        max-width: 1200px;
    }
    
    .screen-content {
        min-height: 600px;
        max-height: 750px;
    }
    
    .pet-grid {
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    }
}

@media (min-width: 1400px) {
    .pokedex-container {
        max-width: 1400px;
    }
    
    .screen-content {
        min-height: 700px;
        max-height: 850px;
    }
    
    .pet-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (min-width: 1600px) {
    .pokedex-container {
        max-width: 1600px;
    }
    
    .screen-content {
        min-height: 750px;
        max-height: 900px;
    }
    
    .pet-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    }
}

.pet-card {
    background: #fff;
    border: 3px solid #333;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pet-card:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.pet-image-container {
    width: 100%;
    height: 150px;
    background: #f0f0f0;
    border: 2px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pet-image-container:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pet-image-container:active {
    transform: scale(0.98);
}

.pet-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast; /* Better image rendering on mobile */
    image-rendering: crisp-edges;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.pet-image:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.pet-image:active {
    transform: scale(0.98);
}

.pet-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    text-align: center;
    text-transform: uppercase;
}

.pet-info {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 50px;
    gap: 2px;
}

.last-fed {
    display: block;
    margin: 0;
    padding: 0;
    font-weight: bold;
    font-size: 0.85rem;
    color: #e74c3c;
    line-height: 1.3;
}

.last-molted {
    display: block;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    color: #9b59b6;
    font-weight: bold;
    line-height: 1.3;
}

.pet-notes {
    display: block;
    margin: 4px 0 0 0;
    padding: 6px 8px;
    font-size: 0.75rem;
    color: #555;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    line-height: 1.3;
    word-wrap: break-word;
    font-style: italic;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.feed-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
    border: 3px solid #1e8449;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #186a3b;
    transition: all 0.1s;
    touch-action: manipulation; /* Prevents double-tap zoom on mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
    margin-top: auto; /* Push to bottom */
}

.feed-btn:hover {
    background: linear-gradient(145deg, #229954, #27ae60);
}

.feed-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #186a3b;
}

.molt-btn {
    width: 100%;
    margin-top: 5px;
    padding: 8px;
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    color: white;
    border: 3px solid #7d3c98;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 3px 0 #6c3483;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.molt-btn:hover {
    background: linear-gradient(145deg, #8e44ad, #9b59b6);
}

.molt-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #6c3483;
}

/* Empty State */
.empty-state {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: #2c3e50;
}

.empty-state.show {
    display: block;
}

.empty-state p {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.empty-state .hint {
    font-size: 1rem;
    color: #555;
}

/* Control Panel */
.control-panel {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-btn {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    border: 3px solid #1f6391;
    border-radius: 10px;
    padding: 15px 30px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 0 #15496b;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.add-btn:hover {
    background: linear-gradient(145deg, #2980b9, #3498db);
}

.add-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #15496b;
}

.reorder-btn {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    color: white;
    border: 3px solid #d68910;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #a86907;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.reorder-btn:hover {
    background: linear-gradient(145deg, #e67e22, #f39c12);
}

.reorder-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #a86907;
}

.table-view-btn {
    background: linear-gradient(145deg, #16a085, #138d75);
    color: white;
    border: 3px solid #117a65;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #0e6655;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.table-view-btn:hover {
    background: linear-gradient(145deg, #138d75, #16a085);
}

.table-view-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #0e6655;
}

.control-lights {
    display: flex;
    gap: 10px;
}

.control-light {
    width: 25px;
    height: 25px;
    background: radial-gradient(circle at 30% 30%, #555, #222);
    border-radius: 50%;
    border: 2px solid #000;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Pet Counter Panel */
.pet-counter-panel {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.pet-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Courier New', monospace;
}

.counter-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.counter-value {
    color: #3498db;
    font-size: 0.95rem;
    font-weight: bold;
}

/* Bottom Controls */
.bottom-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.settings-btn {
    position: absolute;
    right: 10px;
    width: 40px;
    height: 40px;
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    border: 2px solid #5f6c6d;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 3px 0 #5f6c6d;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.settings-btn:hover {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
    transform: scale(1.05);
}

.settings-btn:active {
    transform: translateY(3px) scale(1);
    box-shadow: 0 0 0 #5f6c6d;
}

.speaker-grille {
    display: flex;
    gap: 5px;
    padding: 10px;
}

.speaker-line {
    width: 60px;
    height: 3px;
    background: #8b1a1a;
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
    overflow-y: auto;
    padding: 10px;
    box-sizing: border-box;
}

/* Custom Alert Modal - Highest z-index */
#customAlertModal {
    z-index: 1200;
}

#customAlertModal .modal-content {
    z-index: 1201;
}

/* Record Modal - Higher z-index to appear above other modals */
#recordModal {
    z-index: 1050;
}

#recordModal .modal-content {
    z-index: 1051;
}

/* Edit History Modal - Higher z-index to appear above detail modal */
#editHistoryModal {
    z-index: 1100;
}

#editHistoryModal .modal-content {
    z-index: 1101;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.pokedex-modal {
    background: linear-gradient(145deg, #dc3545, #bd2130);
    border: 3px solid #8b1a1a;
    border-radius: 15px;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.3s ease-out;
    box-sizing: border-box;
    margin: auto;
    max-width: calc(100vw - 20px);
}

.detail-modal {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.reorder-modal {
    max-width: 500px;
}

.alert-modal {
    max-width: 450px;
}

.alert-message {
    font-size: 1.1rem;
    color: #333;
    line-height: 1.6;
    text-align: center;
    padding: 20px 10px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setting-hint {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Reorder List */
.reorder-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
}

.reorder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 3px solid #333;
    border-radius: 8px;
    transition: all 0.2s;
}

.reorder-item-photo {
    width: 50px;
    height: 50px;
    border-radius: 5px;
    object-fit: cover;
    border: 2px solid #333;
}

.reorder-item-name {
    flex: 1;
    font-size: 1rem;
    font-weight: bold;
    color: #333;
}

.reorder-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.arrow-btn {
    width: 35px;
    height: 35px;
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    border: 2px solid #5f6c6d;
    border-radius: 5px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.arrow-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
}

.arrow-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.arrow-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Scrollbar for reorder list */
.reorder-list::-webkit-scrollbar {
    width: 8px;
}

.reorder-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.reorder-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.reorder-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Table View Modal */
.table-view-modal {
    max-width: 900px;
    width: 95%;
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    margin: 20px 0;
    background: white;
    border: 3px solid #333;
    border-radius: 8px;
}

.pets-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
}

.pets-table thead {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pets-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
    border-bottom: 3px solid #333;
    white-space: nowrap;
}

.pets-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.pets-table th.sortable:hover {
    background: linear-gradient(145deg, #415a77, #34495e);
}

.sort-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8rem;
    opacity: 0.5;
}

.pets-table th.sort-asc .sort-indicator {
    opacity: 1;
    transform: rotate(180deg);
    display: inline-block;
}

.pets-table th.sort-desc .sort-indicator {
    opacity: 1;
}

.pets-table tbody tr {
    border-bottom: 2px solid #ddd;
    transition: background 0.2s;
}

.pets-table tbody tr:hover {
    background: #f8f9fa;
}

.pets-table tbody tr:last-child {
    border-bottom: none;
}

.pets-table td {
    padding: 10px;
    font-size: 0.85rem;
    vertical-align: top;
}

.pets-table td:first-child {
    font-weight: bold;
    color: #2c3e50;
}

.table-notes {
    max-width: 250px;
    word-wrap: break-word;
    font-style: italic;
    color: #666;
}

.table-date {
    color: #e74c3c;
    font-weight: bold;
}

.table-molt-date {
    color: #9b59b6;
    font-weight: bold;
}

.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-screen {
    background: #9fcdcd;
    border: 3px solid #333;
    border-radius: 10px;
    padding: 30px;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

.modal-screen h2 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    text-transform: uppercase;
    font-size: 1.5rem;
}

.modal-screen h3 {
    color: #333;
    margin-top: 20px;
    margin-bottom: 10px;
    text-align: center;
    text-transform: uppercase;
    font-size: 1.2rem;
}

/* Pet Detail Modal Styles */
.detail-image-container {
    width: 100%;
    max-height: 250px;
    background: #f0f0f0;
    border: 3px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 250px;
}

/* Feeding History */
.feeding-history {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #333;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid #333;
    border-radius: 5px;
    padding: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-bottom: 5px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.history-item:hover {
    background: #f8f9fa;
    border-color: #3498db;
    transform: translateX(2px);
}

.history-item:active {
    background: #e9ecef;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-date {
    font-weight: bold;
    color: #27ae60;
}

.history-time {
    color: #666;
}

.history-empty {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Scrollbar for history list */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

.form-group {
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    color: #333;
    font-weight: bold;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 0.9rem;
    word-wrap: break-word;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 3px solid #333;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-group input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 3px solid #333;
    border-radius: 8px;
    background: #fff;
    font-family: 'Courier New', monospace;
    cursor: pointer;
}

.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 3px solid #333;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
}

.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.notes-counter {
    text-align: right;
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

.form-group input[type="date"],
.form-group input[type="time"] {
    width: 100%;
    max-width: 100%;
    padding: 10px 8px;
    border: 3px solid #333;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="date"]:focus,
.form-group input[type="time"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.image-preview {
    margin-top: 10px;
    min-height: 150px;
    max-height: 200px;
    background: #f0f0f0;
    border: 3px dashed #999;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

.image-preview.empty::after {
    content: "📷 Preview";
    color: #999;
    font-size: 1.2rem;
}

.modal-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 25px;
    padding: 0 5px;
}

.modal-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: 3px solid #333;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.modal-btn.primary {
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
    border-color: #1e8449;
    box-shadow: 0 4px 0 #186a3b;
}

.modal-btn.primary:hover {
    background: linear-gradient(145deg, #229954, #27ae60);
}

.modal-btn.primary:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #186a3b;
}

.modal-btn.secondary {
    background: #95a5a6;
    color: white;
    border-color: #7f8c8d;
    box-shadow: 0 4px 0 #5f6c6d;
}

.modal-btn.secondary:hover {
    background: #7f8c8d;
}

.modal-btn.secondary:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #5f6c6d;
}

.modal-btn.danger {
    background: #e74c3c;
    color: white;
    border-color: #c0392b;
    box-shadow: 0 4px 0 #a93226;
}

.modal-btn.danger:hover {
    background: #c0392b;
}

.modal-btn.danger:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #a93226;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .pokedex-container {
        padding: 15px;
    }

    .title {
        font-size: 1.2rem;
        letter-spacing: 1px;
    }

    .light-big {
        width: 40px;
        height: 40px;
    }

    .light-small {
        width: 15px;
        height: 15px;
    }

    .pokedex-header {
        gap: 10px;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .pokedex-screen {
        padding: 15px;
    }

    .screen-content {
        padding: 15px;
        min-height: 300px;
    }

    /* 2 columns on tablets/mobile */
    .pet-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .pet-card {
        padding: 10px;
    }

    .pet-image-container {
        height: 120px;
        margin-bottom: 8px;
    }

    .pet-name {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .pet-info {
        font-size: 0.75rem;
        margin-bottom: 8px;
        min-height: 45px;
        gap: 2px;
    }
    
    .last-fed {
        font-size: 0.8rem;
    }

    .feed-btn {
        padding: 8px;
        font-size: 0.9rem;
    }

    .delete-btn {
        padding: 4px;
        font-size: 0.75rem;
        margin-top: 4px;
    }

    .add-btn {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .control-panel {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .add-btn {
        flex: 1 1 auto;
        min-width: 140px;
    }

    .reorder-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .table-view-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .table-view-modal {
        width: 98%;
        max-width: 98%;
    }

    .table-container {
        max-height: 400px;
    }

    .pets-table th,
    .pets-table td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    .table-notes {
        max-width: 150px;
        font-size: 0.7rem;
    }

    .settings-btn {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
        position: static;
        margin-left: auto;
    }

    .bottom-controls {
        justify-content: space-between;
        padding: 0 10px;
    }

    .modal-screen {
        padding: 12px 6px;
    }
    
    .form-group {
        margin-bottom: 15px;
        padding: 0 2px;
    }

    .pokedex-modal {
        padding: 6px;
        width: 94%;
        max-width: calc(100vw - 12px);
        margin: 0 auto;
    }

    .detail-modal {
        max-height: 85vh;
    }

    .detail-image-container {
        max-height: 180px;
    }

    .history-list {
        max-height: 150px;
    }

    .history-item {
        font-size: 0.8rem;
        padding: 6px;
    }
}

/* Very small phones - still 2 columns but more compact */
@media (max-width: 400px) {
    .title {
        font-size: 1rem;
    }

    .pokedex-modal {
        padding: 6px;
        width: 98%;
        margin: 0 2%;
    }

    .modal-screen {
        padding: 10px 6px;
        border-width: 2px;
    }

    .form-group {
        padding: 0 4px;
        margin-bottom: 12px;
    }

    .form-group input[type="date"],
    .form-group input[type="time"] {
        padding: 6px 4px;
        font-size: 16px; /* iOS requirement */
        border-width: 2px;
        width: calc(100% - 12px);
        max-width: 100%;
        margin: 0 auto;
        display: block;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 4px;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 4px;
        padding: 0 2px;
    }

    .pet-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .pet-card {
        padding: 8px;
    }

    .pet-image-container {
        height: 100px;
        margin-bottom: 6px;
    }

    .pet-name {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }

    .pet-info {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }

    .feed-btn {
        padding: 6px;
        font-size: 0.85rem;
    }

    .molt-btn {
        padding: 6px;
        font-size: 0.8rem;
    }
    
    .last-molted {
        font-size: 0.7rem;
    }
    
    .pet-notes {
        font-size: 0.7rem;
        padding: 4px 6px;
        margin-top: 3px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
        padding: 0;
    }

    .modal-btn {
        width: 100%;
        min-width: 0;
        padding: 12px 10px;
        font-size: 0.9rem;
    }
    
    .form-group input[type="date"],
    .form-group input[type="time"] {
        padding: 8px 4px;
        font-size: 16px; /* iOS requirement to prevent zoom */
        border-width: 2px;
        width: calc(100% - 8px);
        max-width: 100%;
        margin: 0 auto;
        display: block;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 6px;
    }
    
    .form-group textarea {
        padding: 8px;
        font-size: 0.9rem;
        min-height: 70px;
    }
    
    .notes-counter {
        font-size: 0.75rem;
    }

    .add-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .header-hinge {
        width: 20px;
        height: 20px;
    }

    .control-lights {
        gap: 6px;
    }

    .control-light {
        width: 20px;
        height: 20px;
    }
}

/* Landscape phones */
@media (max-width: 768px) and (orientation: landscape) {
    .pet-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .screen-content {
        max-height: 300px;
    }
}

