/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --school-blue: #4F73D4;
    --school-blue-dark: #203664;
    --school-blue-light: #D4E9FA;
    --school-blue-pale: #F1F7FF;
    --school-white: #fff;
    --school-ui-border: #B1CBEA;
    /* Subject colors */
    --color-math: #2e5f8a;
    --color-physics: #5E60CE;
    --color-chemistry: #CCD5FF;
    --color-biology: #60a66e;
    --color-language: #4C5270;
    --color-art: #ffb4a2;
    --color-history: #b1a7a6;
    --color-computer: #0096C7;
    --color-music: #e0aaff;
}

body {
    font-family: 'Arial', sans-serif;
    background: var(--school-blue-light);
    min-height: 100vh;
    color: var(--school-blue-dark);
}

/* Password Screen */
.password-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--school-blue-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    overflow: hidden;
}

.owl-bg {
    position: absolute;
    width: 70px;
    height: auto;
    pointer-events: none;
    filter: invert(1) brightness(1.4);
    mix-blend-mode: screen;
    opacity: 0.95;
}

.password-container {
    background: var(--school-white);
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 300px;
}

.password-header {
    color: var(--school-blue-dark);
    margin-bottom: 1rem;
    font-size: 1.75rem;
    font-weight: bold;
}

.password-container h2 {
    color: var(--school-blue-dark);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.password-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--school-ui-border);
    border-radius: 8px;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.password-input:focus {
    border-color: var(--school-blue);
}

.password-submit {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--school-blue);
    color: var(--school-white);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.password-submit:hover {
    background: var(--school-blue-dark);
}

.password-error {
    color: #f44336;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

.map,
.floor {
    background: var(--school-blue-pale) !important;
}

.floor-label {
    background: var(--school-blue-dark);
    color: var(--school-white);
    font-weight: bold;
    letter-spacing: 1px;
    text-align: center;
    border-bottom: 2px solid var(--school-blue);
}

.container {
    min-height: 100vh;
    background: var(--school-blue-dark);
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--school-blue-dark);
    color: var(--school-white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(32,54,100,0.12);
    z-index: 1000;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--school-white);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* Map container - viewport for pan/zoom (like a 2D map app) */
.map-container {
    flex: 1;
    background: var(--school-blue-light);
    border-radius: 0 0 24px 24px;
    box-shadow: 0 2px 12px rgba(32,54,100,.1);
    position: relative;
    overflow: hidden;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
    contain: layout style paint;
}

.map {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    height: auto;
    padding: 0 2vw 50px 2vw;
    box-sizing: border-box;
    will-change: transform;
    transform-origin: 0 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Floor absolute canvas for exact positioning */
.floor-canvas {
    position: relative;
}

.floor-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.35; /* tracing aid */
    pointer-events: none;
}

/* Floor layout */
.floor {
    background: var(--school-white) !important;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 24px #b1cbea60;
    overflow: hidden;
    position: relative;
}

.floor-label {
    background: var(--school-blue-dark);
    color: var(--school-white);
    padding: 1rem;
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Floor plan structure */
.floor-plan {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1vw;
}

/* Hide wings - rooms will be inline in rows */
.wing {
    display: none;
}

/* Central hallway */
.central-hallway {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

/* Entrance area */
.entrance-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
    border-bottom: 3px solid #ff6b6b;
    min-height: 80px;
}

/* Room rows - full horizontal lines */
.room-row {
    display:flex;
    flex-direction:row;
    gap:14px;
    min-height:110px;
    width:100%;
    padding: 12px 0 12px 0;
    justify-content:flex-start;
    align-items:stretch;
    background: var(--school-blue-pale);
    border-radius: 14px;
    margin: 22px 0 4px 0;
    overflow-x:auto;
    box-shadow: 0 2px 16px #20366410;
}

/* Hall bubble */
/* Full-width hallway strip */
.hall-strip {
    background: linear-gradient(90deg, #7a9ae8, #5a7bc4);
    color: #fff;
    border-radius: 22px;
    font-size: 1.16rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
    padding: 1.4vw 24px 1.4vw 24px!important;
    margin: 2px 0 2px 0;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 18px #20366418 inset;
    display:flex;align-items:center;justify-content:center;
}

/* Reduce spacing for room rows that come after hall strip */
.hall-strip + .room-row {
    margin-top: 4px;
}

.hall-strip .hall-name {
    font-weight: 700;
    font-size: 1rem;
}

/* Stairs */
.room.stairs {
    background: linear-gradient(135deg, #a5b5f5 0%, #b599d0 100%);
    color: var(--school-white);
    border-color: #a5b5f5;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.3rem;
    opacity: 1;
    min-height: 60px;
}

.room.stairs .stairs-icon {
    width: 100%;
    height: 100%;
    max-width: 70px;
    max-height: 70px;
    object-fit: contain;
    filter: brightness(0.6) saturate(0.7);
    opacity: 0.75;
}

/* Room base styles */
.room {
    background: var(--school-white);
    border: 2px solid var(--school-ui-border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin: 1px;
    color: var(--school-blue-dark);
    -webkit-tap-highlight-color: rgba(79, 172, 254, 0.2);
    touch-action: manipulation;
}

/* Absolute layout mode */
.layout-mode .floor-canvas .room {
    position: absolute;
    user-select: none;
}

.layout-mode .floor-canvas {
    min-height: 700px; /* workspace */
}

.room.dragging {
    outline: 2px dashed #4facfe;
    cursor: grabbing;
    opacity: 0.9;
}

/* Schedule link icon */
.schedule-link {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(79, 172, 254, 0.9);
    color: var(--school-white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: auto;
    user-select: none;
    -webkit-tap-highlight-color: rgba(79, 172, 254, 0.3);
    touch-action: manipulation;
}

.schedule-link:hover {
    background: rgba(79, 172, 254, 1);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.4);
}

.room:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-color: #4facfe;
}

.room:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.room:active {
    transform: translateY(0);
}

.room-number {
    font-weight: bold;
    color: #666;
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
}

.room-name {
    color: #333;
    font-size: 0.75rem;
    line-height: 1.2;
    word-break: break-word;
}

.room.stairs {
    font-size: 1.2rem;
}

.room-detail {
    font-size: 0.6rem;
    color: #888;
    margin-top: 0.2rem;
}

/* Room type specific colors */
.room.classroom,
.room.classroom.study {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-color: #4facfe;
}

.room.classroom:hover,
.room.classroom.study:hover {
    background: linear-gradient(135deg, #9de7e4 0%, #fcc5d3 100%);
}

.room.lab {
    background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
    border-color: #d299c2;
}

.room.office {
    background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
    border-color: #66a6ff;
}

.room.storage {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.toilet {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.library {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-color: #ff9a9e;
}

.room.dining {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border-color: #fcb69f;
}

.room.kitchen {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    border-color: #ff9a9e;
}

.room.buffet {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-color: #4facfe;
}

.room.hall {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--school-white);
    border-color: #667eea;
}

.room.main-entrance {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: var(--school-white);
    border-color: #f093fb;
    font-weight: bold;
}

.room.staff-room {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: var(--school-white);
    border-color: #4facfe;
}


.room.workshop {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    border-color: #43e97b;
}

.room.server {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    border-color: #fa709a;
}

.room.cleaning {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.janitor {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.archive {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.special {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-color: #ff9a9e;
}

.room.cloakroom {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

.room.shower {
    background: #f0f0f0;
    border: 2px solid #d0d0d0;
    color: #666;
}

/* Special room sizing for better layout */
.room[data-room="dining"] {
    flex: 2;
    min-height: 120px;
}

.room[data-room="newHall"] {
    flex: 1;
    min-height: 100px;
}

.room[data-room="312"] {
    flex: 2;
    min-height: 100px;
}

.room[data-room="entrance"] {
    flex: 2;
    min-height: 60px;
}

.room.jidelna,
.room.large[data-type="dining"] {
    min-width:350px;width:430px;max-width:520px;font-size:1.25em;
}
.room[data-room="310"] {
    background: linear-gradient(135deg, #69db7c 0%, #2b8a3e 100%);
    border-color: #2b8a3e;
    color: #0b2e13;
}

.room.toilet,.room.cleaning,.room.storage,.room.cloakroom,.room.shower{
  flex: 0 0 58px !important;
  width: 58px !important;
  max-width: 65px !important;
  min-width: 40px !important;
  font-size:0.96em;
  padding-left:0;padding-right:0;
}


.room-row .room {
    flex-shrink: 0;
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    margin: 0 2px;
}

.entrance-area .room {
    flex: 1;
    margin: 0 5px;
}

/* Special room sizing for better layout */
.room[data-room="dining"] {
    flex: 2;
    min-height: 120px;
    max-width: 300px;
}

.room[data-room="newHall"] {
    flex: 1;
    min-height: 100px;
    max-width: 200px;
}

.room[data-room="312"] {
    flex: 2;
    min-height: 100px;
    max-width: 200px;
}

.room[data-room="entrance"] {
    flex: 2;
    min-height: 60px;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

.modal-content {
    background: var(--school-white);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    animation: modalSlideIn 0.3s ease;
    color: var(--school-blue-dark);
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
}

.close:hover {
    color: #000;
}

/* Modal content styles */
.room-details {
    margin-top: 1rem;
}

.room-details h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.room-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.room-info p {
    margin: 0.5rem 0;
    color: #666;
}

.students-list, .teachers-list {
    margin-top: 1rem;
}

.students-list h4, .teachers-list h4 {
    color: #4facfe;
    margin-bottom: 0.5rem;
}

.students-list ul, .teachers-list ul {
    list-style: none;
    padding: 0;
}

.students-list li, .teachers-list li {
    background: white;
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 5px;
    border-left: 3px solid #4facfe;
    cursor: pointer;
    transition: all 0.3s ease;
}

.students-list li:hover, .teachers-list li:hover {
    background: #f0f8ff;
    transform: translateX(5px);
}

.schedule {
    margin-top: 1rem;
}

.schedule h4 {
    color: #4facfe;
    margin-bottom: 0.5rem;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
}

.schedule-table th {
    background-color: #4facfe;
    color: white;
}

.schedule-table tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Fixed canvas width so pan/zoom scale the same layout as desktop (2D map app style) */
    .map {
        width: 960px;
        min-width: 960px;
        max-width: none;
        padding: 1rem 1rem 30px 1rem;
    }
    
    .floor-plan {
        flex-direction: column;
        min-height: auto;
    }
    
    .wing {
        min-width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .central-hallway {
        order: -1;
        min-height: 200px;
    }
    
    /* Keep room rows horizontal on mobile so the map feels like one plan,
       only scrolling sideways when needed */
    .room-row {
        flex-direction: row;
        align-items: stretch;
    }
    
    .room-row .room {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
        margin-bottom: 0;
    }
    
    .hall-bubble {
        margin: 1rem 0;
    }
    
    .hall-bubble .room {
        min-width: 150px;
        padding: 0.8rem 1.5rem;
    }
    
    .room {
        min-height: 40px;
        padding: 0.25rem;
        font-size: 0.7rem;
    }
    
    .room-name {
        font-size: 0.65rem;
    }
    
    .stairs {
        position: static;
        transform: none;
        margin: 10px auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .map {
        width: 960px;
        min-width: 960px;
        max-width: none;
    }
    
    .floor-plan {
        min-height: auto;
    }
    
    .wing {
        flex-direction: column;
    }
    
    .room {
        min-height: 35px;
        font-size: 0.6rem;
    }
    
    .room-name {
        font-size: 0.55rem;
    }
    
    .schedule-link {
        width: 16px;
        height: 16px;
        font-size: 0.6rem;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Zoom and pan indicators */
.zoom-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 1000;
}

/* Drag cursor for panning */
.map.panning {
    cursor: grabbing;
}

.map-container.panning {
    cursor: grabbing;
}

/* ============================================
   RESPONSIVE DESIGN - Mobile, Tablet, Desktop
   ============================================ */

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .room {
        min-height: 70px;
        padding: 0.75rem;
    }
    
    .schedule-link {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
        top: 4px;
        right: 4px;
    }
    
    .control-btn {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
        min-height: 44px;
    }
    
    .room:hover {
        transform: none;
    }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .modal-content {
        width: 85%;
        max-width: 550px;
        padding: 1.5rem;
        margin: 3% auto;
    }
    
    .room-row {
        gap: 10px;
        padding: 14px 0;
    }
    
    .room {
        min-width: 120px;
        font-size: 0.75rem;
    }
    
    .room-name {
        font-size: 0.7rem;
    }
}

/* Mobile Landscape (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .header {
        padding: 0.75rem;
        flex-wrap: wrap;
    }
    
    .header h1 {
        font-size: 1.2rem;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .controls {
        width: 100%;
        justify-content: center;
    }
    
    .map-container {
        border-radius: 0;
    }
    
    .map {
        padding: 0 1vw 30px 1vw;
    }
    
    .floor {
        margin-bottom: 1.5rem;
    }
    
    .floor-label {
        padding: 0.75rem;
        font-size: 1rem;
    }
    
    .room-row {
        gap: 8px;
        padding: 12px 0;
        min-height: 90px;
    }
    
    .room {
        min-width: 100px;
        max-width: 120px;
        min-height: 60px;
        padding: 0.5rem;
        font-size: 0.7rem;
    }
    
    .room-name {
        font-size: 0.65rem;
        line-height: 1.3;
    }
    
    .room-number {
        font-size: 0.65rem;
    }
    
    .schedule-link {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }
    
    .modal-content {
        width: 90%;
        max-width: 500px;
        padding: 1.25rem;
        margin: 5% auto;
        max-height: 85vh;
    }
    
    .room-details h3 {
        font-size: 1.3rem;
    }
    
    .close {
        font-size: 32px;
        top: 0.75rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .hall-strip {
        padding: 1.5vw 16px;
        font-size: 0.95rem;
    }
    
    .photo-map {
        max-width: 95vw;
        width: 100%;
    }
}

/* Mobile Portrait (up to 480px) */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem;
    }
    
    .header h1 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }
    
    .control-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    .map-container {
        border-radius: 0;
    }
    
    .map {
        padding: 0 0.5vw 20px 0.5vw;
        width: 960px;
        min-width: 960px;
    }
    
    .floor {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .floor-label {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .floor-plan {
        padding: 0 0.5vw;
    }
    
    .room-row {
        gap: 6px;
        padding: 10px 0;
        min-height: 80px;
        margin: 12px 0 4px 0;
    }
    
    .room {
        min-width: 85px;
        max-width: 100px;
        min-height: 55px;
        padding: 0.4rem;
        font-size: 0.65rem;
        margin: 0 1px;
    }
    
    .room-name {
        font-size: 0.6rem;
        line-height: 1.2;
    }
    
    .room-number {
        font-size: 0.6rem;
        margin-bottom: 0.15rem;
    }
    
    .schedule-link {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
        top: 3px;
        right: 3px;
    }
    
    .hall-strip {
        padding: 1.2vw 12px;
        font-size: 0.85rem;
        margin: 2px 0 2px 0;
    }
    
    .hall-strip + .room-row {
        margin-top: 4px;
    }
    
    .hall-strip .hall-name {
        font-size: 0.8rem;
    }
    
    .modal-content {
        width: 95%;
        max-width: none;
        padding: 1rem;
        margin: 2% auto;
        max-height: 90vh;
        border-radius: 12px;
    }
    
    .room-details h3 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }
    
    .room-info {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .room-info p {
        font-size: 0.9rem;
        margin: 0.4rem 0;
    }
    
    .students-list h4, .teachers-list h4 {
        font-size: 1rem;
    }
    
    .students-list li, .teachers-list li {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .schedule-table {
        font-size: 0.8rem;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 0.4rem 0.3rem;
    }
    
    .close {
        font-size: 36px;
        top: 0.5rem;
        right: 0.75rem;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
    
    .teacher-link-button {
        padding: 0.9em 1.2em !important;
        font-size: 0.95rem !important;
        min-height: 48px;
    }
    
    .photo-map {
        max-width: 98vw;
        width: 100%;
        border-radius: 12px;
    }
    
    .zoom-indicator {
        bottom: 10px;
        right: 10px;
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    /* Make buttons more touch-friendly */
    button, .control-btn, .teacher-link-button {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        touch-action: manipulation;
    }
}

/* Very small phones (up to 360px) */
@media (max-width: 360px) {
    .header h1 {
        font-size: 0.9rem;
    }
    
    .control-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .room {
        min-width: 75px;
        max-width: 90px;
        min-height: 50px;
        font-size: 0.6rem;
    }
    
    .room-name {
        font-size: 0.55rem;
    }
    
    .modal-content {
        padding: 0.75rem;
    }
    
    .room-details h3 {
        font-size: 1.1rem;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
        margin: 1% auto;
        padding: 1rem;
    }
    
    .header {
        padding: 0.5rem;
    }
    
    .header h1 {
        font-size: 1rem;
    }
}

/* Prevent text selection on touch devices during panning */
@media (hover: none) and (pointer: coarse) {
    .map-container.is-panning * {
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
}
