@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Nunito:wght@500;700;900&display=swap');

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Nunito", Arial, sans-serif;
    color: #102033;
    background:
        radial-gradient(circle at 15% 18%, rgba(255, 214, 10, 0.32), transparent 24%),
        radial-gradient(circle at 86% 12%, rgba(82, 183, 136, 0.28), transparent 24%),
        linear-gradient(135deg, #f7fbff 0%, #edf8f1 100%);
}

.turtle-shell {
    width: min(1320px, calc(100% - 28px));
    margin: 0 auto;
    padding: 24px 0 42px;
}

.topbar {
    display: grid;
    gap: 20px;
    margin-bottom: 18px;
}

.back-link,
button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: #174ea6;
    color: #fff;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 10px 14px;
    text-decoration: none;
}

.back-link:hover,
button:hover {
    background: #103a7a;
}

.eyebrow {
    margin: 0 0 8px;
    color: #d64550;
    font-size: 15px;
    font-weight: 900;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 8px;
    font-family: "Bungee", Arial, sans-serif;
    font-size: clamp(42px, 7vw, 84px);
    line-height: 1;
}

.topbar p:not(.eyebrow) {
    max-width: 820px;
    margin: 0;
    color: #35465d;
    font-size: 20px;
    line-height: 1.45;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
    gap: 16px;
    align-items: start;
}

.canvas-card,
.control-card {
    border: 2px solid #102033;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 8px 8px 0 rgba(16, 32, 51, 0.16);
}

.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-bottom: 2px solid #102033;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.canvas-toolbar strong {
    display: block;
    font-size: 22px;
}

#statusText {
    display: block;
    color: #526173;
}

.challenge-box {
    padding: 14px 16px;
    border-bottom: 2px solid #102033;
    background: #fff7cc;
}

.challenge-label {
    margin: 0 0 4px;
    color: #9a3412;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

#challengeText {
    margin: 0;
    color: #102033;
    font-size: 18px;
    line-height: 1.4;
}

.canvas-wrap {
    position: relative;
    aspect-ratio: 900 / 560;
    background:
        linear-gradient(90deg, rgba(16, 32, 51, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(16, 32, 51, 0.08) 1px, transparent 1px),
        #fff;
    background-size: 28px 28px;
    overflow: hidden;
}

canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.turtle-toggle {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border: 2px solid #102033;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 32, 51, 0.22);
}

.turtle-toggle:hover {
    background: #e8f8df;
}

.turtle-toggle::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 10px;
    width: 26px;
    height: 15px;
    border: 3px solid #102033;
    border-radius: 50%;
    background: #e8f8df;
}

.turtle-toggle::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 13px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #102033;
    box-shadow: none;
}

.turtle-toggle.is-off::before {
    left: 4px;
    top: 10px;
    width: 26px;
    height: 15px;
    border: 3px solid #102033;
    border-radius: 50%;
    background: #e8f8df;
    transform: none;
}

.cross-line {
    position: absolute;
    left: 6px;
    top: 20px;
    width: 34px;
    height: 4px;
    border-radius: 999px;
    background: #d92d20;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}

.cross-a {
    transform: rotate(45deg);
}

.cross-b {
    transform: rotate(-45deg);
}

.turtle-toggle.is-off .cross-line {
    opacity: 1;
}

.control-card {
    display: grid;
    gap: 0;
}

.panel {
    padding: 16px;
    border-bottom: 2px solid #102033;
}

.panel:last-child {
    border-bottom: 0;
}

.panel h2 {
    margin: 0 0 10px;
    font-size: 23px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.panel-heading h2 {
    margin: 0;
}

.small-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 14px;
}

.clear-button {
    background: #b42318;
}

.clear-button:hover {
    background: #8f1d14;
}

.is-hidden {
    display: none !important;
}

.command-row,
.button-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.button-row {
    grid-template-columns: 1fr 1fr;
    margin-top: 10px;
}

input,
select,
textarea {
    width: 100%;
    border: 2px solid #b8c4d4;
    border-radius: 8px;
    background: #fff;
    color: #102033;
    font: inherit;
    box-sizing: border-box;
}

input,
select {
    min-height: 42px;
    padding: 9px 10px;
}

textarea {
    min-height: 260px;
    padding: 12px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 15px;
    line-height: 1.45;
    resize: vertical;
}

.danger-button {
    width: 100%;
    margin-top: 10px;
    background: #b42318;
}

.danger-button:hover {
    background: #8f1d14;
}

.guide-modal,
.message-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 32, 51, 0.52);
}

.guide-modal[hidden],
.message-modal[hidden] {
    display: none;
}

.guide-window,
.message-window {
    width: min(900px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    border: 2px solid #102033;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 8px 8px 0 #ffd60a;
}

.message-window {
    width: min(520px, 100%);
    padding: 22px;
}

.message-window h2 {
    margin: 0 0 8px;
    font-size: 30px;
}

.message-window p {
    margin: 0 0 16px;
    color: #35465d;
    font-size: 19px;
    line-height: 1.4;
}

.guide-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 2px solid #102033;
}

.guide-header h2 {
    margin: 0;
    font-size: 28px;
}

.guide-tabs {
    display: flex;
    gap: 10px;
    padding: 14px 16px 0;
}

.guide-tab {
    min-height: 36px;
    padding: 7px 14px;
    background: #e2e8f0;
    color: #102033;
}

.guide-tab.is-active {
    background: #174ea6;
    color: #fff;
}

.guide-page {
    display: none;
    padding: 16px;
}

.guide-page.is-active {
    display: block;
}

.guide-page h3 {
    margin: 0 0 10px;
    font-size: 25px;
}

.guide-page h4 {
    margin: 0 0 8px;
    font-size: 20px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.guide-grid article {
    min-width: 0;
}

.guide-grid h3 {
    margin: 0 0 8px;
    font-size: 24px;
}

.guide-grid p {
    margin: 8px 0;
    color: #35465d;
    line-height: 1.45;
}

code,
pre {
    font-family: Consolas, "Courier New", monospace;
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: #edf2f7;
}

pre {
    margin: 0;
    padding: 12px;
    border-radius: 8px;
    background: #102033;
    color: #f8fbff;
    overflow-x: auto;
}

pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

@media (max-width: 1040px) {
    .workspace,
    .guide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .command-row,
    .button-row,
    .canvas-toolbar {
        grid-template-columns: 1fr;
    }

    .canvas-toolbar {
        display: grid;
    }

    .toolbar-actions,
    .guide-header {
        display: grid;
        grid-template-columns: 1fr;
    }
}
