/*@font-face {
    font-family: 'runescape_uf';
    font-style: normal;
    font-weight: normal;
    src: url('fonts/runescape_uf.ttf') format('truetype');
}*/

@font-face {
    font-family: 'RuneScape UF Regular';
    font-style: normal;
    font-weight: normal;
    src: local('RuneScape UF Regular'), url('runescape_uf.woff') format('woff');
}

@font-face {
    font-family: 'FunOrb TerraPhoenix B12';
    font-style: normal;
    font-weight: normal;
    src: url('../fonts/FunOrb-TerraPhoenix-B12.otf') format('opentype');
}

:root {
    --bg: #060606;
    --panel: #171615;
    --panel-2: #211f1d;
    --panel-3: #11100f;
    --border: #3c3935;
    --border-bright: #58524b;
    --text: #f2efea;
    --muted: #aaa39b;
    --accent: #a73b32;
    --accent-2: #d46455;
    --danger: #e07166;
    --shadow: 0 18px 48px #0008;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, #3b3835 0, transparent 31rem),
        radial-gradient(circle at bottom left, #3d2522 0, transparent 30rem),
        linear-gradient(135deg, #080807 0%, #050505 100%);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h3,
p {
    margin-top: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
input[type="range"],
input[type="color"],
input[type="checkbox"] {
    cursor: pointer;
}

button,
select,
textarea,
input[type="range"] {
    color: var(--text);
}

button,
select {
    border: 1px solid var(--border-bright);
    border-radius: 8px;
    background: #211f1d;
    transition: border-color .12s ease, background .12s ease, transform .12s ease;
}

button {
    padding: 7px 10px;
}

button:hover,
button:focus,
select:hover,
select:focus {
    border-color: var(--accent);
    background: #2c2825;
    outline: none;
}

button:active {
    transform: translateY(1px);
}

select {
    min-height: 34px;
    padding: 5px 30px 5px 9px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
}

input[type="color"] {
    width: 42px;
    height: 30px;
    padding: 2px;
    border: 1px solid var(--border-bright);
    border-radius: 8px;
    background: #11100f;
}

input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    padding: 10px 14px 14px;
    background:
        radial-gradient(circle at top left, #3b3835 0, transparent 31rem),
        radial-gradient(circle at bottom left, #3d2522 0, transparent 30rem),
        linear-gradient(135deg, #080807 0%, #050505 100%);
}

.site-header {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 58px;
    margin: 0 auto 8px;
}

.site-logo {
    display: block;
    width: min(760px, 54vw);
    max-width: calc(100vw - 32px);
    max-height: clamp(52px, 8vh, 88px);
    object-fit: contain;
    filter: drop-shadow(0 8px 18px #000c);
}

.flex-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.game-area {
    order: 2;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #050505;
    box-shadow: var(--shadow);
}

#tile-board {
    display: block;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: #0b0a09;
}

.example-clips {
    order: 1;
    width: 270px;
    max-height: calc(100vh - 116px);
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, #1b1917, #121110);
    box-shadow: var(--shadow);
}

.example-clips h3 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 18px;
}

.clip-list {
    display: grid;
    gap: 10px;
}

.clip-card {
    display: grid;
    gap: 6px;
}

.clip-title {
    margin: 0;
    color: #f2efea;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.clip-list iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--border-bright);
    border-radius: 10px;
    background: #000;
}

.form-box {
    order: 3;
    width: min(390px, calc(100vw - 28px));
    max-height: calc(100vh - 116px);
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, #1b1917, #121110);
    box-shadow: var(--shadow);
}

.options-header {
    padding: 4px 4px 10px;
}

.options-header h3 {
    margin: 0;
    font-size: 22px;
    letter-spacing: .01em;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--accent-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.options-form {
    display: grid;
    gap: 12px;
}

.option-section {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #11100fcc;
}

.option-section legend {
    padding: 0 7px;
    color: #d8d0c8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.form-line,
.toggle-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 32px;
}

.form-line label,
.toggle-line span {
    color: var(--text);
}

.toggle-line {
    cursor: pointer;
}

.toggle-line > span:first-child,
.toggle-line:not(.color-toggle) {
    justify-content: flex-start;
}

.toggle-line:not(.color-toggle) {
    gap: 9px;
}

.color-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.inline-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.range-line {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) auto 120px;
}

#ping-display,
#volume-display {
    min-width: 54px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-3);
    color: #eadbd5;
    text-align: center;
}

.marker-transfer-buttons {
    justify-content: flex-start;
}

.reset-settings-row {
    justify-content: flex-start;
}

#reset-default-settings {
    width: 100%;
    border-color: #6c332d;
    background: #251312;
    color: #ffd8d0;
}

#reset-default-settings:hover,
#reset-default-settings:focus {
    border-color: var(--danger);
    background: #351b18;
}

.tile-context-menu,
.color-preset-menu {
    position: fixed;
    z-index: 1000;
    display: none;
    border: 1px solid var(--border-bright);
    border-radius: 10px;
    background: #171615;
    box-shadow: 0 14px 36px #000b;
}

.tile-context-menu {
    min-width: 210px;
    padding: 6px;
}

.tile-context-menu.visible,
.color-preset-menu.visible {
    display: block;
}

.tile-context-menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.tile-context-menu button:hover,
.tile-context-menu button:focus {
    background: #2c2825;
}

.tile-context-menu button.danger {
    color: var(--danger);
}

.hidden-color-picker {
    position: fixed;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.color-preset-menu {
    z-index: 1100;
    width: 226px;
    padding: 10px;
}

.color-preset-swatches {
    display: grid;
    grid-template-columns: repeat(5, 34px);
    gap: 7px;
    justify-content: center;
}

.color-swatch {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 2px solid #d0d0d0;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px #0008;
}

.color-swatch:hover,
.color-swatch:focus {
    border-color: #fff;
    outline: 2px solid var(--accent);
}

.color-preset-footer {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-top: 8px;
}

.color-preset-footer .last-color {
    flex: 0 0 52px;
    height: 36px;
    color: #fff;
    font-size: 11px;
    text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.color-preset-footer #open-color-wheel {
    flex: 1;
}

.marker-json-panel {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #000b;
}

.marker-json-panel.visible {
    display: flex;
}

.marker-json-card {
    width: min(680px, calc(100vw - 32px));
    padding: 16px;
    border: 1px solid var(--border-bright);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.marker-json-card h3 {
    margin-top: 0;
}

.reset-settings-card {
    width: min(430px, calc(100vw - 32px));
}

#marker-json-text {
    width: 100%;
    height: min(52vh, 420px);
    resize: vertical;
    border: 1px solid var(--border-bright);
    border-radius: 10px;
    background: #090807;
    color: var(--text);
    font: 13px/1.35 Consolas, monospace;
}

.marker-json-status {
    min-height: 1.2em;
    margin: 6px 0;
    color: #d46455;
}

.marker-json-status.error {
    color: #ff9a8f;
}

.marker-json-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 1700px) {
    .example-clips {
        order: 4;
        width: min(100%, 760px);
        max-height: none;
    }

    .clip-list {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 900px) {
    .canvas-wrapper {
        padding: 8px;
    }

    .site-logo {
        width: min(620px, 88vw);
        max-height: 64px;
    }

    .form-box {
        width: min(100%, 720px);
        max-height: none;
    }

    .example-clips {
        width: min(100%, 720px);
    }
}

@media (max-width: 560px) {
    .clip-list {
        grid-template-columns: 1fr;
    }
}
