@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/nunito-v32-latin_latin-ext-regular.woff2") format("woff2");
}

@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/nunito-v32-latin_latin-ext-italic.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --ink: #222222;
    --muted: #5a6570;
    --paper: #ffffff;
    --card: #ffffff;
    --line: #dee2e6;
    --brand: #003399;
    --brand-dark: #002d73;
    --green: #003399;
    --green-bright: #003399;
    --danger: #cf002c;
    --danger-dark: #b00026;
    --soft: #00339914;
}

* { box-sizing: border-box; }

/* display:flex etc. would otherwise override the hidden attribute */
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Nunito, sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
}

body.is-play {
    background: #000;
    overflow: hidden;
    height: 100%;
}

body.is-logs {
    overflow: hidden;
    height: 100%;
}

h1, h2, h3, .word {
    font-family: Nunito, sans-serif;
    font-weight: 400;
    color: var(--brand);
    line-height: 1.2;
    letter-spacing: 0.02em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.45rem; margin: 1.2rem 0 0.6rem; }
h3 { font-size: 1.15rem; }

button, input, select, textarea {
    font: inherit;
}

button {
    background-color: transparent;
    background-image: linear-gradient(#e00031 0%, #a70725 100%);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 12px 24px;
    min-height: 42px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    text-decoration: none;
}

button:hover,
button:focus {
    filter: none;
    background-image: linear-gradient(#003399 0%, #002d73 100%);
}

button:disabled {
    opacity: 0.55;
    cursor: default;
    background-image: linear-gradient(#e00031 0%, #a70725 100%);
}

button.btn-save:disabled {
    opacity: 1;
    color: #fff;
    background: #9a9a9a;
    background-image: none;
}

button.danger {
    background-image: linear-gradient(#e00031 0%, #a70725 100%);
}
button.danger:hover,
button.danger:focus {
    background-image: linear-gradient(#003399 0%, #002d73 100%);
}
button.block { display: block; width: 100%; margin: 0.6rem 0; }
button.tab {
    background: transparent;
    background-image: none;
    color: var(--brand);
    border-bottom: 3px solid transparent;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.92rem;
    font-weight: 400;
    min-height: 42px;
    padding: 0.55rem 0.75rem;
}
button.tab.is-on { border-color: var(--brand); color: var(--brand); }
button.tab:hover,
button.tab:focus {
    filter: none;
    background: var(--soft);
    background-image: none;
}

.card, .controller {
    max-width: 920px;
    margin: 0 auto;
    padding: 1.2rem;
}

.card {
    background: var(--card);
    margin-top: 8vh;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.6rem 1.5rem;
    box-shadow: 0 8px 28px rgba(0, 51, 153, 0.06);
}

.card h1,
.top strong {
    color: var(--brand);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

label { display: block; margin: 0.8rem 0; }
label.check {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.55rem;
    text-align: left;
    width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.7rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}
input[type="checkbox"],
input[type="radio"] {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--brand);
}
input[type="color"] {
    width: 4.5rem;
    min-height: 2.5rem;
    padding: 0.2rem;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(0, 51, 153, 0.35);
    outline-offset: 1px;
    border-color: var(--brand);
}
textarea { font-family: ui-monospace, monospace; }

.switch { display: flex; gap: 0.5rem; }
.error { color: var(--danger); min-height: 1.2rem; }
.note { color: var(--muted); }
.suggest { color: var(--brand); }
.top, .tabs, .actions, .filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.top { justify-content: space-between; }
.top button {
    background-image: linear-gradient(#e00031 0%, #a70725 100%);
    color: #fff;
    border: 0;
    min-height: 42px;
    padding: 12px 24px;
}
.top button:hover,
.top button:focus {
    background-image: linear-gradient(#003399 0%, #002d73 100%);
    filter: none;
}
.tabs {
    border-bottom: 1px solid var(--line);
    gap: 0.15rem;
}
.panel { margin-top: 1rem; }

.controller.is-logs {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0.6rem;
}
.controller.is-logs .top,
.controller.is-logs .tabs {
    flex: 0 0 auto;
}
.controller.is-logs .panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 0.75rem;
    overflow: hidden;
}
.controller.is-logs .filters {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
}
.log-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.log-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: 0 1px 0 var(--line);
}
.code { font-size: 1.4rem; letter-spacing: 0.08em; color: var(--brand); }
.rotation-box {
    margin: 1rem 0;
    padding: 0.8rem 1rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.rotation-box legend {
    padding: 0 0.3rem;
    font-weight: 400;
    color: var(--brand);
}
.pet-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.4rem 0 0.6rem;
}
.pet-block {
    min-width: 4.5rem;
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--brand);
    background-image: none;
    color: #fff;
    cursor: grab;
    text-transform: none;
    font-weight: 400;
    letter-spacing: normal;
    min-height: 0;
}
.pet-block:hover,
.pet-block:focus {
    background-image: none;
    filter: brightness(1.08);
}
.pet-block.is-inactive {
    background: #eef1f5;
    background-image: none;
    color: var(--muted);
    border-color: var(--line);
}
.pet-block.is-inactive:hover,
.pet-block.is-inactive:focus {
    background-image: none;
}
.pet-block.is-dragging {
    opacity: 0.55;
}
.pet-block.is-tired {
    background: #5a6570;
    background-image: none;
    color: #f2f5f7;
    cursor: default;
}
.pet-block.is-tired:hover,
.pet-block.is-tired:focus {
    background-image: none;
}
.tired-badge,
.pet-playtime,
.tired-remain {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
}
.tired-badge {
    color: var(--brand);
}
.sleep-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    object-fit: contain;
}
.boot-screen {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
}
.boot-anim {
    width: min(40vw, 180px);
    height: auto;
    max-height: 180px;
    object-fit: contain;
    animation: boot-pulse 1.2s ease-in-out infinite;
}
@keyframes boot-pulse {
    0%, 100% { opacity: 0.82; }
    50% { opacity: 1; }
}
.pet-block.is-tired .tired-remain {
    color: #f2f5f7;
}
.pet-list-name {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.image-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.5rem 0;
}
.image-pick {
    flex: 1 1 10rem;
}
.image-preview {
    margin: 0.6rem 0;
    min-height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-preview-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.image-preview canvas,
.image-preview img {
    display: block;
    max-width: min(220px, 70vw);
    max-height: 280px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.crop-frame {
    position: absolute;
    border: 2px solid var(--green);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.crop-handle {
    position: absolute;
    width: 1.1rem;
    height: 1.1rem;
    background: var(--green);
    border: 2px solid #fff;
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    transform: translate(-50%, -50%);
}
.crop-handle[data-edge="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-handle[data-edge="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-handle[data-edge="w"] { left: 0; top: 50%; cursor: ew-resize; }
.crop-handle[data-edge="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.object-heading {
    margin: 0 0 0.5rem;
    font-weight: 700;
}
.object-save-actions {
    margin-top: 0.4rem;
}
.image-edit,
.image-crop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}
.object-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.run-time {
    font-variant-numeric: tabular-nums;
    min-width: 3rem;
    color: var(--brand);
}
.upload-progress {
    margin: 0.8rem 0;
}
.upload-progress-track {
    height: 0.7rem;
    border-radius: 999px;
    background: #eef1f5;
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    width: 0;
    background: var(--green);
    transition: width 0.15s linear;
}
.upload-progress-bar.is-indeterminate {
    width: 35% !important;
    animation: upload-pulse 1s ease-in-out infinite;
}
.upload-progress-label {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.95rem;
}
@keyframes upload-pulse {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}
.coach { margin-bottom: 0.2rem; color: var(--brand); }
.word { font-size: 2rem; margin: 0.2rem 0 0.8rem; }
.list { list-style: none; padding: 0; }
.list li {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
}
.list img { width: 72px; height: 72px; object-fit: contain; background: #fff; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 0.45rem; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
th { color: var(--brand); font-weight: 400; }

.play-stage {
    position: fixed;
    inset: 0;
    background: var(--rest, #000);
    touch-action: none;
    user-select: none;
    --accent: #003399;
    --rest: #000000;
    --flash: #ffffff;
}
.play-stage.phase-black { background: var(--rest, #000); }
.play-stage.phase-white { background: var(--flash, #fff); }
.play-stage.phase-green { background: var(--accent, #003399); }
.play-board, .play-svg, .play-columns {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.play-svg { display: block; }
.play-chrome {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}
.play-wait {
    color: #ddd;
    margin: 0.4rem 1rem 1rem;
    text-align: center;
    font-family: Nunito, sans-serif;
}
.play-brand {
    color: #9aa3ad;
    margin: 1rem 1rem 0;
    text-align: center;
    font-family: Nunito, sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}
.brand-user {
    font-weight: 400;
    font-size: 0.98rem;
    line-height: 1.35;
    max-width: min(100%, 42rem);
}
.sound-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.8rem;
    margin: 0.4rem 0 1rem;
}
.sound-status-text {
    margin: 0;
}
.sound-status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.play-leave {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    background: #2a2a2a;
    color: #eee;
    pointer-events: auto;
    touch-action: manipulation;
    z-index: 6;
    padding: 0.7rem 1rem;
    border-radius: 11px;
}
.play-columns { display: flex; }
.play-col {
    flex: 1;
    position: relative;
    min-width: 0;
}
.play-img-box {
    position: absolute;
    left: 4%;
    right: 4%;
    top: 4%;
    bottom: 4%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.play-columns.has-buttons .play-img-box {
    bottom: 26%;
}
.play-col img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}
.filter-grayscale { filter: grayscale(1); }
.filter-blur { filter: blur(3px); }
.filter-brighter { filter: brightness(1.9); }
.filter-darker { filter: brightness(0.3); }

@media (max-width: 700px) {
    .card {
        margin-top: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    table { font-size: 0.85rem; }
    button.tab {
        font-size: 0.8rem;
        padding: 0.5rem 0.45rem;
    }
}
