* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    color: #eaeaea;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.screen {
    width: 100vw;
    height: 100vh;
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

/* Waiting state */
.waiting-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2rem;
    color: #666;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Panel styles */
.panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #16213e;
    border-radius: 1rem;
    padding: 2rem;
    overflow: hidden;
}

/* Cover mode panels - edge-to-edge media */
.panel.panel-cover {
    padding: 0;
    border-radius: 0;
}

.panel.panel-cover .panel-content {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.panel-content {
    position: absolute;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text content */
.content-text {
    text-align: center;
}

/* Image content */
.content-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
}

/* Image display modes */
.content-image.mode-contain {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

.content-image.mode-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.content-image.mode-cover-width {
    width: 100%;
    height: auto;
    max-height: none;
}

.content-image.mode-cover-height {
    width: auto;
    height: 100%;
    max-width: none;
}

/* Video content */
.content-video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
}

/* Video display modes (same as image) */
.content-video.mode-contain {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

.content-video.mode-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.content-video.mode-cover-width {
    width: 100%;
    height: auto;
    max-height: none;
}

.content-video.mode-cover-height {
    width: auto;
    height: 100%;
    max-width: none;
}

/* Markdown content */
.content-markdown {
    text-align: center;
    transform-origin: center center;
}

.content-markdown.auto-scale-markdown {
    overflow: visible;
}

.content-markdown h1 {
    font-size: 3em;
    margin-bottom: 0.5em;
    color: #fff;
}

.content-markdown h2 {
    font-size: 2.5em;
    margin-bottom: 0.4em;
    color: #f0f0f0;
}

.content-markdown h3 {
    font-size: 2em;
    margin-bottom: 0.3em;
    color: #e0e0e0;
}

.content-markdown p {
    font-size: 1.5em;
    line-height: 1.6;
    margin-bottom: 0.5em;
}

.content-markdown code {
    background: #0d1b2a;
    padding: 0.2em 0.4em;
    border-radius: 0.25em;
    font-family: 'Fira Code', 'Consolas', monospace;
}

.content-markdown pre {
    background: #0d1b2a;
    padding: 1em;
    border-radius: 0.5em;
    overflow-x: auto;
    margin: 0.5em 0;
}

.content-markdown pre code {
    background: none;
    padding: 0;
}

.content-markdown ul, .content-markdown ol {
    margin-left: 1.5em;
    font-size: 1.5em;
}

.content-markdown blockquote {
    border-left: 4px solid #4a69bd;
    padding-left: 1em;
    margin: 0.5em 0;
    color: #aaa;
    font-style: italic;
}

/* Layout variations based on panel count */
.screen.panels-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.screen.panels-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.screen.panels-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.screen.panels-3 .panel:first-child {
    grid-column: span 2;
}

.screen.panels-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.screen.panels-5 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
}

.screen.panels-5 .panel:nth-child(4) {
    grid-column: span 1;
}

.screen.panels-5 .panel:nth-child(5) {
    grid-column: span 1;
}

.screen.panels-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
}

/* Custom layout support - for flexible grid configurations */
.screen.layout-custom {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* Spanning utility classes for panels */
.panel.span-full-width {
    grid-column: 1 / -1;
}

.panel.span-2-cols {
    grid-column: span 2;
}

.panel.span-3-cols {
    grid-column: span 3;
}

.panel.span-2-rows {
    grid-row: span 2;
}

.panel.span-3-rows {
    grid-row: span 3;
}

/* Connection status indicator */
.connection-status {
    position: fixed;
    /* Fluid sizing so the toast shrinks on small/embedded viewports.
       Upper bounds equal the original full-screen sizes. */
    bottom: clamp(0.5rem, 3vmin, 2rem);
    right: clamp(0.5rem, 3vmin, 2rem);
    padding: clamp(0.4rem, 1.6vmin, 1.25rem) clamp(0.8rem, 3.2vmin, 2.5rem);
    border-radius: clamp(1rem, 4vmin, 3rem);
    font-size: clamp(0.75rem, 2.6vmin, 1.5rem);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.connection-status.visible {
    opacity: 1;
}

.connection-status.connected {
    background: #27ae60;
    color: white;
}

.connection-status.disconnected {
    background: #e74c3c;
    color: white;
}

.connection-status.reconnecting {
    background: #f39c12;
    color: white;
}

/* ============== Page Transition Animations ============== */

/* Container for transitions */
.screen--transitioning {
    position: relative;
    overflow: hidden;
}

/* Old content wrapper during transition */
.screen__old-content {
    position: absolute;
    inset: 0;
    display: grid;
    gap: inherit;
    padding: inherit;
    z-index: 1;
}

/* New content wrapper during transition */
.screen__new-content {
    position: absolute;
    inset: 0;
    display: grid;
    gap: inherit;
    padding: inherit;
    z-index: 2;
}

/* Fade transition keyframes */
@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Slide-left transition keyframes */
@keyframes slide-out-left {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

@keyframes slide-in-right {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Transition animation classes */
.transition-fade-out {
    animation: fade-out var(--transition-duration, 500ms) ease-out forwards;
}

.transition-fade-in {
    animation: fade-in var(--transition-duration, 500ms) ease-out forwards;
}

.transition-slide-out-left {
    animation: slide-out-left var(--transition-duration, 500ms) ease-out forwards;
}

.transition-slide-in-right {
    animation: slide-in-right var(--transition-duration, 500ms) ease-out forwards;
}
