:root {
    --navy: #132238;
    --navy-deep: #0a1b2a;
    --camel: #c99d6b;
    --camel-deep: #9d7345;
    --cream: #f5efe6;
    --cream-soft: #e7dcc7;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--cream);
    color: var(--navy);
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 25px;
}

.site-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 auto 24px;
}

.site-nav a {
    color: var(--navy);
    text-decoration: none;
    font-weight: 700;
    padding: 9px 14px;
    border: 1px solid var(--camel);
    border-radius: 8px;
    background: var(--white);
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--cream);
    background: var(--navy);
    border-color: var(--navy);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.badge {
    background: var(--navy);
    color: var(--cream);
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
}

h1 {
    font-size: 2.2rem;
}

h1 span {
    color: var(--camel-deep);
}

.subtitle {
    color: var(--navy);
    margin-top: 5px;
}

.container {
    display: grid;
    grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.5fr);
    gap: 20px;
    width: 100%;
    margin: 0 auto;
}

.panel {
    background: var(--cream-soft);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(19, 34, 56, 0.15);
    border: 1px solid rgba(19, 34, 56, 0.2);
}

h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--navy);
}

h3 {
    font-size: 1rem;
    margin: 15px 0 10px 0;
    color: var(--camel-deep);
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

button {
    background: var(--camel);
    color: var(--navy);
    border: 1px solid var(--camel-deep);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

button:hover {
    background: var(--navy);
    color: var(--cream);
    border-color: var(--navy);
}

button.reset {
    grid-column: span 2;
    background: var(--navy);
    color: var(--cream);
}

.matrix-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 200px;
}

.matrix-grid input {
    background: var(--white);
    border: 1px solid var(--camel);
    color: var(--navy);
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
}

select {
    width: 100%;
    padding: 10px;
    background: var(--white);
    border: 1px solid var(--camel);
    color: var(--navy);
    border-radius: 8px;
    font-size: 1rem;
}

.help-text {
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 8px;
}

textarea {
    width: 100%;
    min-height: 112px;
    padding: 10px;
    resize: vertical;
    border: 1px solid var(--camel);
    border-radius: 8px;
    color: var(--navy);
    background: var(--white);
    font: 0.95rem/1.5 Consolas, monospace;
}

.apply-coordinates {
    margin-top: 8px;
}

.status-message {
    min-height: 1.4em;
    margin-top: 6px;
    font-size: 0.9rem;
    color: #23613c;
}

.status-message.error {
    color: #a12622;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.calc-box {
    background: var(--navy);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid var(--camel);
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--cream);
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--navy);
}

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 4px;
}

.dot.initial { background: var(--camel); }
.dot.transformed { background: var(--navy); }

.canvas-wrapper {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.canvas-panel {
    min-width: 0;
}

.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.zoom-controls button {
    min-width: 42px;
    padding: 8px 12px;
}

.zoom-controls output {
    min-width: 88px;
    text-align: center;
    font-weight: 700;
}

.zoom-controls .zoom-reset {
    min-width: auto;
}

.zoom-hint {
    width: 100%;
    text-align: center;
    font-size: 0.82rem;
    color: var(--navy);
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: 680px;
    background: var(--cream);
    border-radius: 8px;
    border: 1px solid var(--camel);
    touch-action: none;
    cursor: grab;
}

canvas.dragging {
    cursor: grabbing;
}

.code-section {
    max-width: 1200px;
    margin: 30px auto 0 auto;
    background: var(--navy);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--camel);
}

.page-content {
    max-width: 1000px;
    margin: 0 auto;
}

.content-card {
    margin-bottom: 18px;
    padding: 22px;
    background: var(--white);
    border: 1px solid var(--cream-soft);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(19, 34, 56, 0.08);
}

.content-card p,
.content-card li {
    line-height: 1.65;
}

.content-card ul,
.content-card ol {
    padding-left: 22px;
}

.content-card pre {
    white-space: pre;
}

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

.team-card {
    background: var(--cream-soft);
    border: 1px solid rgba(19, 34, 56, 0.2);
    border-radius: 10px;
    padding: 18px;
}

.team-card h3 {
    margin-top: 0;
}

.code-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.code-card {
    background: var(--navy-deep);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--camel);
}

pre {
    background: var(--navy-deep);
    padding: 12px;
    border-radius: 6px;
    color: var(--camel);
    overflow-x: auto;
    margin: 10px 0;
}

@media (max-width: 768px) {
    .container, .code-grid {
        grid-template-columns: 1fr;
    }

    .team-grid {
        grid-template-columns: 1fr;
    }

    .canvas-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .container {
        grid-template-columns: minmax(0, 1fr);
    }
}
