* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 40px 20px;
    background: #f4f2ee;
    
    transform: scale(0.9);
    transform-origin: top left;
    width: 111.11%;
}

#app-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch; /* left panel stretches to match the tree's height */
    gap: 100px;
}

#left-panel {
    display: flex;
    flex-direction: column;
    width: 420px;
    flex-shrink: 0;
}

#sentence-display {
    background: #1c1c1e;
    border: 1px solid #444;
    border-radius: 10px;
    min-height: 100px;
    padding: 16px;
    color: #eae4d8;
    font-size: 22px;
    line-height: 1.5;
    word-break: break-word;
    overflow-y: auto;
}

/* pushes the key + buttons all the way down, so they line up with the
   bottom of the tree on the right */
#left-panel-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
}

#right-panel {
    flex: 1;
    min-width: 0;
}

#tree-area {
    position: relative;
    width: 900px;
    max-width: 100%;
    overflow: hidden; /* height is set in JS to exactly fit the tree, so this never needs to scroll */
    background: #1c1c1e;
}

.tree-node {
    position: absolute;
    width: 34px;
    height: 34px;
    margin-left: -17px;
    margin-top: -17px;
    background: radial-gradient(circle at 35% 30%, #4a4a4a, #1a1a1a 70%);
    border: 1px solid #555;
    border-radius: 50%;
    color: #eae4d8;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.15);
    z-index: 3;
}

.tree-root-marker {
    position: absolute;
    width: 11px;
    height: 11px;
    margin-left: -5.5px;
    margin-top: -5.5px;
    background: #f2c14e;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(242, 193, 78, 0.7);
    z-index: 3;
}

.tree-line {
    position: absolute;
    height: 3px;
    margin-top: -1.5px;
    background: #4a4a4a;
    transform-origin: 0 50%;
    z-index: 1;
}

/* the metal peg sitting in the middle of each connection, marking
   whether that step was a dot (short, round) or a dash (long, rectangular) */
.tree-peg {
    position: absolute;
    background: linear-gradient(180deg, #6a6a6a, #2a2a2a 60%, #1a1a1a);
    border: 1px solid #555;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    z-index: 2;
}

.tree-peg-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
}

.tree-peg-dash {
    width: 32px;
    height: 13px;
    border-radius: 4px;
}

#morse-key {
    width: 100%;
    background: #1c1c1e;
    border: 1px solid #444;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.08s ease;
}

/* while pressed (mouse held or spacebar held) */
#morse-key.active {
    background: #34343a;
}

#key-code-display {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    letter-spacing: 8px;
    color: #6be08a;
    border-bottom: 1px solid #333;
}

#key-letter-display {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: #f2c14e;
}

#keyboard {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

#keyboard button {
    flex: 1;
    padding: 12px 0;
    background: #2a2a2e;
    color: #eae4d8;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.1s ease;
}

#keyboard button:hover {
    background: #3a3a40;
}

#keyboard button:active {
    background: #4a4a52;
}

.tree-line.active {
    background: #f2c14e;
}

.tree-peg.active {
    background: #f2c14e;
    border-color: #f2c14e;
}

.tree-node.active {
    border-color: #f2c14e;
    box-shadow: 0 0 8px rgba(242, 193, 78, 0.7);
}

