

:root {
    --bg: #0f0d09;
    --bg2: #1a1610;
    --bg3: #231f18;
    --paper: #f5ead5;
    --paper2: #ede0c4;
    --ink: #1a1209;
    --gold: #c9a84c;
    --gold2: #e8c97a;
    --rust: #8b3a1a;
    --rust2: #c05028;
    --copper: #b87333;
    --needle-gold: #ffd700;
    --telegraph-blue: #2c4a7c;
    --telegraph-red: #c0392b;
    --accent: var(--gold);
    --sidebar-w: 160px;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--paper);
    font-family: 'Playfair Display', Georgia, serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── SIDEBAR NAV ── */
#sidebar{
    position: fixed;
    top: 50%;
    left: -20px; /* add some spacing from edge */
    transform: translateY(-50%); /* true vertical centering */
    height: auto; /* optional, makes it shrink to content */
    width: var(--sidebar-w);
    background: var(--bg2);
    border: 1px solid #3a3020;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 100;
    padding: 20px;
    border-radius: 20px;
}



#sidebar .logo {
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
    padding: 0 12px 20px;
    border-bottom: 1px solid #3a3020;
    margin-bottom: 16px;
}

#sidebar nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

#sidebar nav a {
    font-family: 'Special Elite', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a09070;
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    border: 1px solid transparent;
}

#sidebar nav a:hover, #sidebar nav a.active {
    background: #2a2418;
    color: var(--gold);
    border-color: #3a3020;
}

#sidebar .lang-select {
    padding: 12px 12px 0;
    border-top: 1px solid #3a3020;
    margin-top: auto;
}

#sidebar .lang-select select {
    width: 100%;
    background: var(--bg3);
    color: var(--paper);
    border: 1px solid #3a3020;
    border-radius: 4px;
    padding: 6px 8px;
    font-family: 'Special Elite', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    cursor: pointer;
}

/* ── MAIN CONTENT ── */
#main {
    margin-left: var(--sidebar-w);
    max-width: 900px;
    padding: 48px 48px 80px;
}

header {
    margin-bottom: 64px;
    padding-bottom: 32px;
    border-bottom: 1px solid #3a3020;
}

header .eyebrow {
    font-family: 'Special Elite', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 12px;
}

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    font-weight: 700;
    line-height: 1.05;
    color: var(--paper);
    margin-bottom: 14px;
}

header p {
    font-style: italic;
    color: #a09070;
    font-size: 1rem;
}

/* ── SECTIONS ── */
section {
    margin-bottom: 72px;
    scroll-margin-top: 24px;
}

section h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    color: var(--gold2);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3a3020;
}

section h3 {
    font-size: 1.1rem;
    color: var(--paper2);
    margin: 16px 0 8px;
}

section p {
    line-height: 1.75;
    color: #c8b898;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

section img {
    max-width: 100%;
    border-radius: 4px;
    border: 1px solid #3a3020;
    margin: 12px 0;
    opacity: 0.85;
}

/* ── INFO BOXES ── */
.info-box {
    background: #1a1610;
    border: 1px solid #3a3020;
    border-left: 3px solid var(--gold);
    border-radius: 4px;
    padding: 14px 18px;
    margin: 16px 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.info-box .icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.info-box p { margin: 0; font-size: 0.88rem; }

.warn-box {
    border-left-color: var(--rust2);
}

/* ── STATISTICS ── */
textarea {
    width: 100%;
    height: 90px;
    padding: 12px;
    background: #1a1610;
    border: 1px solid #3a3020;
    border-radius: 6px;
    color: var(--gold);
    font-family: 'Courier Prime', monospace;
    font-size: 0.9rem;
    resize: vertical;
}

textarea::placeholder { color: #5a5040; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    margin-top: 14px;
}

.stat-item {
    background: #1a1610;
    border: 1px solid #3a3020;
    border-radius: 4px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-letter {
    font-family: 'Special Elite', monospace;
    font-weight: bold;
    color: #d4a853;
    width: 18px;
    font-size: 1rem;
}

.stat-item > div {
    font-family: 'Courier Prime', monospace;
    font-size: 0.75rem;
    color: #a09070;
}

/* ── TELEGRAPH ── */
.telegraph-wrapper {
    background: #2a2620;
    border: 1px solid #4a4035;
    border-radius: 2px;
    padding: 28px;
    text-align: center;
}

.telegraph-ui {
    display: flex; justify-content: center; padding: 30px;
    position: relative;
}

.diamond-frame {
    position: relative;
    display: grid;
    grid-template-columns: repeat(9, 38px);
    grid-template-rows: repeat(9, 38px);
    gap: 2px;
    font-weight: 700;
    font-size: 1.3rem;
    font-family: 'Playfair Display', serif;
    color: #9a8f7a;
}

.d-a { grid-column:5; grid-row:1; }
.d-b { grid-column:4; grid-row:2; } .d-d { grid-column:6; grid-row:2; }
.d-e { grid-column:3; grid-row:3; } .d-f { grid-column:5; grid-row:3; } .d-g { grid-column:7; grid-row:3; }
.d-h { grid-column:2; grid-row:4; } .d-i { grid-column:4; grid-row:4; } .d-k { grid-column:6; grid-row:4; } .d-l { grid-column:8; grid-row:4; }
.d-m { grid-column:2; grid-row:6; } .d-n { grid-column:4; grid-row:6; } .d-o { grid-column:6; grid-row:6; } .d-p { grid-column:8; grid-row:6; }
.d-r { grid-column:3; grid-row:7; } .d-s { grid-column:5; grid-row:7; } .d-t { grid-column:7; grid-row:7; }
.d-v { grid-column:4; grid-row:8; } .d-w { grid-column:6; grid-row:8; }
.d-y { grid-column:5; grid-row:9; }

[class^="d-"] {
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    cursor: default;
}

.d-select {
    color: #d4a853 !important;
    transform: scale(1.3);
    text-shadow: 0 0 12px rgba(212,168,83,0.8);
}

.needles-layer {
    position: absolute;
    top: 50%; left: 0; width: 100%;
    display: flex; justify-content: space-evenly;
    transform: translateY(-50%);
    z-index: 10; gap: 50px;
}

.needle {
    width: 10px; height: 110px;
    background: #9a8f7a;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
    transform-origin: center;
    cursor: pointer;
    opacity: 0.5;
}
.needle.active {
    background: var(--copper);
    box-shadow: 0 0 20px var(--glow);
    opacity: 1;
}
.needle.left { transform: rotate(-30deg); }
.needle.right { transform: rotate(30deg); }

/* ── COOKE DRAWER ── */
.cooke-drawer-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: #1a1610;
    border: 1px solid #3a3020;
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 16px;
    color: var(--gold);
    font-family: 'Special Elite', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    user-select: none;
    transition: background 0.2s;
}

.cooke-drawer-toggle:hover { background: #231f18; }

.cooke-drawer-toggle .arrow {
    margin-left: auto;
    transition: transform 0.3s;
    font-style: normal;
}

.cooke-drawer-toggle.open .arrow { transform: rotate(180deg); }

.cooke-drawer-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.cooke-drawer-content.open {
    max-height: 600px;
}

.cooke-drawer-inner {
    background: #131008;
    border: 1px solid #3a3020;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 20px;
}

/* ── TRANSLATOR ── */
.morse-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.btn {
    font-family: 'Special Elite', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: #2a2418;
    color: var(--gold);
    border: 1px solid #4a3a28;
    border-radius: 4px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn:hover { background: #3a3020; border-color: var(--gold); }
.btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold2); }
.btn.primary:hover { background: var(--gold2); }

#morseResult {
    margin-top: 14px;
    font-family: 'Courier Prime', monospace;
    font-size: 1.6rem;
    color: var(--gold);
    min-height: 36px;
    text-align: center;
    letter-spacing: 0.08em;
}

/* ── GAME ── */
.game-section {
    background: #131008;
    border: 1px solid #3a3020;
    border-radius: 8px;
    padding: 24px;
}

.game-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.game-controls-row label {
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a09070;
    margin-right: 4px;
}

.game-controls-row select {
    background: #1a1610;
    color: var(--paper);
    border: 1px solid #3a3020;
    border-radius: 4px;
    padding: 5px 10px;
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
}

.target-display {
    text-align: center;
    margin-bottom: 20px;
}

.target-display h3 {
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6a5a40;
    margin-bottom: 8px;
}

#word-display {
    font-family: 'Courier Prime', monospace;
    font-size: clamp(2rem, 6vw, 3.5rem);
    letter-spacing: 0.3em;
    color: var(--paper);
    min-height: 1.2em;
}

#word-display .letter { transition: color 0.2s; }
#word-display .letter.correct { color: #4caf50; }
#word-display .letter.wrong { color: var(--rust2); }
#word-display .letter.current { color: var(--gold2); text-decoration: underline; }

.morse-hint {
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    color: #6a5a40;
    text-align: center;
    min-height: 1.4em;
    margin-bottom: 12px;
    letter-spacing: 0.15em;
}

.stats-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-badge {
    background: #1a1610;
    border: 1px solid #3a3020;
    border-radius: 4px;
    padding: 8px 16px;
    text-align: center;
}

.stat-badge .label {
    font-family: 'Special Elite', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6a5a40;
    display: block;
}

.stat-badge .value {
    font-family: 'Courier Prime', monospace;
    font-size: 1.2rem;
    color: var(--gold);
    display: block;
}

/* ── KEY BUTTON ── */
.key-button-wrap {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#keyBtn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #3a2e1a, #1a1208);
    border: 3px solid var(--copper);
    box-shadow: 0 4px 20px #0008, inset 0 2px 4px #ffffff18;
    cursor: pointer;
    transition: transform 0.05s, box-shadow 0.05s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Special Elite', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #a09070;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    outline: none;
}

#keyBtn.pressed {
    transform: scale(0.94);
    box-shadow: 0 1px 8px #0008, inset 0 3px 6px #00000060;
    border-color: var(--gold);
    color: var(--gold);
}

.morse-buffer-display {
    text-align: center;
    font-family: 'Courier Prime', monospace;
    font-size: 2rem;
    letter-spacing: 0.25em;
    color: #4a3a28;
    min-height: 2.4rem;
    margin-bottom: 8px;
    transition: color 0.1s;
}

.morse-buffer-display.active { color: var(--gold2); }

#liveChart {
    width: 100% !important;
    height: 50px !important;
    opacity: 0.6;
}

#output {
    font-family: 'Courier Prime', monospace;
    font-size: 1.5rem;
    text-align: center;
    color: var(--paper);
    min-height: 2rem;
    margin-top: 12px;
    letter-spacing: 0.15em;
}

.game-feedback {
    text-align: center;
    min-height: 1.8rem;
    margin-top: 8px;
    font-family: 'Special Elite', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.game-feedback.correct { color: #4caf50; }
.game-feedback.wrong { color: var(--rust2); }

.hint-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-family: 'Special Elite', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6a5a40;
}

.hint-toggle input[type=checkbox] { accent-color: var(--gold); cursor: pointer; }

/* ── BINARY TREE ── */
.binary-tree {
    width: fit-content;
    overflow-x: auto;
    max-width: 100%;
}

.binary-tree div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    gap: 0.5rem;
    margin-top: 1rem;
    position: relative;
}

.binary-tree span {
    grid-column: 1 / 3;
    border: 1px solid #4a3a28;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: auto;
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    background: #1a1610;
    color: var(--paper);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.binary-tree span::before {
    content: "";
    position: absolute;
    width: 50%;
    height: 1.5rem;
    left: 50%;
    top: 0;
    transform: translateY(-100%);
    background: linear-gradient(to bottom right, #0000 49%, #4a3a28 0 51%, #0000 0);
}

.binary-tree :nth-child(3) > span::before {
    left: auto;
    right: 50%;
    background: linear-gradient(to bottom left, #0000 49%, #4a3a28 0 51%, #0000 0);
}

.binary-tree > div > span::before { content: none; }

.activeTree {
    background: var(--gold) !important;
    color: var(--ink) !important;
    border-color: var(--gold2) !important;
    box-shadow: 0 0 10px var(--gold);
}

.tree-legend {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    font-family: 'Courier Prime', monospace;
    font-size: 0.82rem;
    color: #a09070;
}

/* ── MOBILE SIDEBAR ── */
#mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #0f0d09ee;
    backdrop-filter: blur(8px);
    border-top: 1px solid #3a3020;
    z-index: 100;
    padding: 8px 12px;
    overflow-x: auto;
    gap: 4px;
    white-space: nowrap;
}

#mobile-nav a {
    display: inline-block;
    font-family: 'Special Elite', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #a09070;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
}

#mobile-nav a:hover { color: var(--gold); border-color: #3a3020; }

@media (max-width: 700px) {
    #sidebar { display: none; }
    #mobile-nav { display: flex; }
    #main { margin-left: 0; padding: 24px 18px 80px; }
    /* .needles-layer { gap: 50px; padding: 0 10px; } */
    .diamond-frame { grid-template-columns: repeat(9, 28px); grid-template-rows: repeat(9, 28px); font-size: 0.85rem; }
    .needle { height: 80px; }
}
.l{
    display: inline-block;
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    color: #a09070;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
}
.l:hover{
    color: var(--gold);
}

