/**
 * The 3D maze — /3dmatrix/
 * Location: assets/css/maze.css   (after workbench.css and puzzles.css)
 * Full-viewport page. No inline styles anywhere: state is classes and [hidden].
 */

html, body.maze-page { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; overscroll-behavior: none; }
body.maze-page { padding: 0 !important; }
body.maze-page #matrix { display: none; }
body.maze-page .site-main { margin: 0; padding: 0; max-width: none; }
.maze-root [hidden] { display: none !important; }

.maze-root {
    position: fixed; inset: 0; background: #000; overflow: hidden;
    font-family: 'Courier New', monospace; color: #c9ffd9;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.maze-canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.maze-canvas canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.maze-crosshair {
    position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
    background: rgba(140, 255, 170, 0.85); box-shadow: 0 0 4px rgba(80, 255, 140, 0.8); pointer-events: none; z-index: 4;
}
.maze-root.is-paused .maze-crosshair, .maze-root.is-touch .maze-crosshair { opacity: 0.45; }

/* ---------------------------------------------------------------- HUD */
.maze-hud {
    position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 0 calc(10px + env(safe-area-inset-left, 0px));
    pointer-events: none;
}
.maze-hud-left, .maze-hud-right { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: auto; }
.maze-hud-right { justify-content: flex-end; }
.maze-chip {
    display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 5px; font: inherit; font-size: 13px; font-weight: 700;
    color: #a8ffc4; background: rgba(0, 12, 5, 0.72); border: 1px solid rgba(90, 255, 140, 0.4); white-space: nowrap; text-decoration: none; letter-spacing: 0.02em;
}
.maze-btn { cursor: pointer; }
.maze-btn:hover, .maze-chip-link:hover { background: rgba(90, 255, 140, 0.18); }
.maze-btn[aria-pressed="false"] { color: #7a9a85; border-color: rgba(120, 150, 130, 0.4); }
#maze-mute-btn[aria-pressed="true"] { color: #a8ffc4; }

.maze-map {
    position: absolute; z-index: 5; right: calc(10px + env(safe-area-inset-right, 0px)); top: calc(54px + env(safe-area-inset-top, 0px));
    width: 168px; height: 168px; border: 1px solid rgba(90, 255, 140, 0.4); border-radius: 6px; background: rgba(0, 10, 4, 0.72); cursor: pointer; touch-action: none;
}

.maze-prompt {
    position: absolute; z-index: 6; left: 50%; bottom: 22%; transform: translateX(-50%); max-width: min(92vw, 520px); text-align: center;
    padding: 10px 16px; border-radius: 6px; font-size: 15px; font-weight: 700; color: #001a08; background: rgba(140, 255, 170, 0.94); pointer-events: none;
}
.maze-prompt.is-locked { background: rgba(255, 196, 80, 0.95); }
.maze-toast {
    position: absolute; z-index: 9; left: 50%; top: 18%; transform: translateX(-50%); max-width: min(92vw, 560px); text-align: center;
    padding: 12px 18px; border-radius: 6px; font-size: 15px; font-weight: 700; color: #d7ffe4; background: rgba(0, 24, 10, 0.92); border: 1px solid #3cff8c;
    pointer-events: none;
}

/* ---------------------------------------------------------------- touch controls */
.maze-stick {
    position: absolute; z-index: 5; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
    left: calc(84px + env(safe-area-inset-left, 0px)); top: calc(100% - 96px - env(safe-area-inset-bottom, 0px));
    border: 2px solid rgba(140, 255, 170, 0.5); background: rgba(0, 30, 12, 0.35); pointer-events: none;
}
.maze-stick.is-active { border-color: rgba(140, 255, 170, 0.9); }
.maze-stick-knob {
    position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
    background: rgba(140, 255, 170, 0.55); border: 1px solid rgba(200, 255, 220, 0.9);
}
.maze-touch-hint {
    position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(170px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-around;
    font-size: 13px; color: rgba(190, 255, 210, 0.85); pointer-events: none; text-shadow: 0 0 6px #000;
}
.maze-use {
    position: absolute; z-index: 6; right: calc(22px + env(safe-area-inset-right, 0px)); bottom: calc(46px + env(safe-area-inset-bottom, 0px));
    width: 92px; height: 92px; border-radius: 50%; font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
    color: #001a08; background: rgba(140, 255, 170, 0.94); border: 2px solid #eafff0; box-shadow: 0 0 18px rgba(80, 255, 140, 0.7);
    touch-action: manipulation;
}
.maze-use.is-locked { background: rgba(255, 196, 80, 0.95); box-shadow: 0 0 18px rgba(255, 196, 80, 0.6); }

/* ---------------------------------------------------------------- overlays */
.maze-overlay {
    position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; overflow-y: auto;
    padding: 16px; background: rgba(0, 6, 2, 0.86); -webkit-user-select: text; user-select: text;
}
.maze-card {
    width: min(100%, 640px); max-height: 100%; overflow-y: auto; padding: 22px 24px; border-radius: 8px;
    background: rgba(0, 16, 7, 0.96); border: 1px solid #3cff8c; box-shadow: 0 0 30px rgba(0, 255, 100, 0.2); line-height: 1.6;
}
.maze-card-small { width: min(100%, 460px); }
.maze-card h1 { margin: 0 0 8px; font-size: clamp(1.5em, 6vw, 2.2em); color: #0f0; text-align: center; }
.maze-card h2 { margin: 0 0 6px; font-size: 1em; color: #0f0; }
.maze-lead { margin: 0 0 12px; text-align: center; }
.maze-how { margin: 0 0 14px; padding-left: 20px; }
.maze-controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 14px; }
.maze-controls-col { padding: 10px 12px; border: 1px solid rgba(90, 255, 140, 0.3); border-radius: 6px; font-size: 0.9em; }
.maze-controls-col p { margin: 0; }
.maze-root.is-touch #maze-help-desktop, .maze-root:not(.is-touch).is-mouse #maze-help-touch,
.maze-root.is-touch #maze-quick-desktop, .maze-root:not(.is-touch).is-mouse #maze-quick-touch { display: none; }
.maze-root.is-touch .maze-controls-grid, .maze-root.is-mouse .maze-controls-grid { grid-template-columns: 1fr; }
.maze-card kbd {
    display: inline-block; min-width: 1.5em; padding: 1px 6px; margin: 0 2px; text-align: center; border: 1px solid #3cff8c; border-radius: 4px;
    background: rgba(0, 40, 16, 0.8); color: #c9ffd9; font: inherit; font-size: 0.9em;
}
.maze-note { margin: 0 0 12px; font-size: 0.92em; }
.maze-note a, .maze-secondary { color: #0ff; }
.maze-error { color: #ffc450; }
.maze-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: center; margin: 0 0 10px; }
.maze-actions .btn-primary {
    min-height: 48px; padding: 0 28px; border: 0; border-radius: 6px; font: inherit; font-size: 1.05em; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; text-decoration: none;
}
.maze-actions .btn-primary:disabled { opacity: 0.55; cursor: default; }
.maze-linkbtn { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.maze-settings { display: grid; gap: 8px; margin: 6px 0 14px; }
.maze-settings input[type="range"] { width: 100%; accent-color: #3cff8c; }
.maze-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.maze-check input { width: 18px; height: 18px; accent-color: #3cff8c; }
.maze-keys { font-size: 0.85em; margin: 0 0 12px; }

/* ---------------------------------------------------------------- puzzle panel */
.maze-panel {
    position: absolute; inset: 0; z-index: 12; display: flex; justify-content: center; align-items: stretch;
    padding: 18px; background: rgba(0, 6, 2, 0.8); -webkit-user-select: text; user-select: text;
}
.maze-panel-inner {
    display: flex; flex-direction: column; width: min(100%, 860px); max-height: 100%; border-radius: 8px; overflow: hidden;
    background: rgba(0, 14, 6, 0.97); border: 1px solid #3cff8c; box-shadow: 0 0 34px rgba(0, 255, 100, 0.25);
}
.maze-panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid rgba(90, 255, 140, 0.35);
}
.maze-panel-head h2 { margin: 0; font-size: 1.05em; color: #0f0; }
.maze-panel-close {
    flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 5px; font: inherit; font-weight: 700; cursor: pointer;
    color: #a8ffc4; background: rgba(0, 30, 12, 0.9); border: 1px solid rgba(90, 255, 140, 0.6);
}
.maze-panel-close:hover { background: rgba(90, 255, 140, 0.18); }
.maze-panel-body { padding: 14px 16px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; line-height: 1.6; }
.maze-panel-body h3 { margin: 18px 0 6px; font-size: 1em; color: #0f0; }
.maze-panel-body .pz-answer-row input { min-height: 44px; font-size: 16px; }   /* 16px: no zoom-on-focus on iOS */
.maze-panel-body .pz-submit { min-height: 44px; }
.maze-panel-body .wb-textarea, .maze-panel-body .wb select, .maze-panel-body .wb input { font-size: 16px; }
.maze-panel-done { margin: 14px 0 0; padding: 14px; border: 1px solid #0f0; border-radius: 6px; background: rgba(0, 40, 14, 0.7); }
.maze-panel-done p { margin: 0 0 10px; }
.maze-offer { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.maze-offer-plan { flex: 1 1 140px; padding: 12px; border: 1px solid #ffd700; border-radius: 6px; color: #ffd700; text-align: center; }
.maze-offer-plan strong { display: block; font-size: 1.3em; }
.maze-gold { color: #ffd700; }

@media (max-width: 700px) {
    .maze-panel { padding: 0; }
    .maze-panel-inner { width: 100%; border-radius: 0; border-width: 0; }
    .maze-panel-body { padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
    .maze-controls-grid { grid-template-columns: 1fr; }
    .maze-card { padding: 16px; }
    .maze-chip { font-size: 12px; padding: 0 9px; }
    .maze-map { width: 112px; height: 112px; top: calc(92px + env(safe-area-inset-top, 0px)); }
    .maze-prompt { bottom: 34%; font-size: 14px; }
    .maze-tip { bottom: 46%; font-size: 14px; }
}
@media (max-height: 460px) {
    .maze-map { width: 96px; height: 96px; top: calc(50px + env(safe-area-inset-top, 0px)); }
    .maze-stick { width: 104px; height: 104px; margin: -52px 0 0 -52px; top: calc(100% - 72px - env(safe-area-inset-bottom, 0px)); }
    .maze-use { width: 76px; height: 76px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
    .maze-touch-hint { bottom: 130px; }
    .maze-card { padding: 12px 16px; }
    #maze-start .maze-lead { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .maze-card h1.glitch::before, .maze-card h1.glitch::after { animation: none; }
}

/* ---------------------------------------------------------------- keys you hold, fragments */
.maze-keys { margin: 0 0 14px; padding: 10px 12px; border: 1px dashed #ffd700; border-radius: 6px; color: #ffd700; background: rgba(40, 32, 0, 0.45); }
.maze-keys-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.maze-keys code { color: #fff3b0; font-size: 1.02em; word-break: break-word; }
.maze-frags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.maze-frag {
    min-width: 3.2em; padding: 6px 8px; text-align: center; border: 1px dashed rgba(180, 140, 255, 0.5); border-radius: 5px;
    color: #6d6285; font-family: 'Courier New', monospace; white-space: pre;
}
.maze-frag.is-held { border-style: solid; border-color: #b48cff; color: #e6d6ff; background: rgba(60, 30, 110, 0.45); }
button.maze-chip { cursor: pointer; }

/* v3.26.0: the Elite offer at the end of a member-built maze */
.maze-elite-offer { margin: 14px 0; padding: 12px 14px; border: 1px solid rgba(255, 215, 0, 0.6); border-radius: 8px; background: rgba(40, 30, 0, 0.45); }
.maze-elite-offer p { margin: 0 0 8px; }

/* The exit panel, while the maze's hidden message is still unread (v3.34.0): the bonus leads, the ways out are plain links. */
.maze-bonus-push { margin: 4px 0 14px; padding: 14px 16px 6px; border: 1px solid #ffd700; border-radius: 8px; background: rgba(60, 48, 0, 0.35); }
.maze-bonus-head { margin: 0 0 6px; font-size: 1.12em; font-weight: 700; }
.maze-bonus-bar { display: block; width: 100%; height: 12px; margin: 10px 0 14px; border: 1px solid #ffd700; border-radius: 6px; background: rgba(0, 0, 0, 0.5); overflow: hidden; appearance: none; -webkit-appearance: none; }
.maze-bonus-bar::-webkit-progress-bar { background: rgba(0, 0, 0, 0.5); }
.maze-bonus-bar::-webkit-progress-value { background: #ffd700; }
.maze-bonus-bar::-moz-progress-bar { background: #ffd700; }
.maze-leave-label { margin: 0 0 6px; text-align: center; font-size: 0.9em; }
.maze-actions-quiet { gap: 18px; font-size: 0.95em; }

/* ---- v3.36.0: one-thumb touch controls, and the map you can tap ---- */
.maze-root.touch-one .maze-stick:not(.is-active) { left: 50%; }                       /* at rest the stick sits in the middle: either thumb reaches it */
.maze-root.touch-one .maze-touch-hint { justify-content: center; }
.maze-map.is-big {
    left: 50%; right: auto; top: 50%; transform: translate(-50%, -50%); z-index: 8;
    width: min(88vw, 62vh, 520px); height: min(88vw, 62vh, 520px); background: rgba(0, 10, 4, 0.9); border-color: rgba(140, 255, 170, 0.9); box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}
.maze-settings select { min-height: 40px; padding: 4px 8px; font: inherit; color: #c9ffd9; background: rgba(0, 30, 12, 0.9); border: 1px solid #3cff8c; border-radius: 4px; }
@media (max-width: 700px) { .maze-map.is-big { width: min(92vw, 60vh); height: min(92vw, 60vh); } }

/* ---- v3.56.0: short start card, the help panel, first-time tips ---- */
.maze-quick { margin: 0 0 10px; text-align: center; font-size: 0.85em; opacity: 0.8; }
.maze-card h3 { margin: 14px 0 4px; font-size: 0.95em; color: #0ff; }
.maze-card h4 { margin: 0 0 4px; font-size: 0.9em; color: #0f0; }
.maze-card .maze-help-h { font-size: 1.3em; text-align: center; }
#maze-help-btn { min-width: 36px; font-weight: 700; }
.maze-tip {
    position: absolute; z-index: 7; left: 50%; bottom: 32%; transform: translateX(-50%); width: max-content; max-width: min(92vw, 520px); text-align: center;
    padding: 10px 16px; border-radius: 6px; font-size: 15px; line-height: 1.45; color: #fff3b0; background: rgba(30, 24, 0, 0.94); border: 1px solid #ffd700;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.25); pointer-events: none;
}
