body {
    margin:0;
    background:#111;
    font-family:Arial;
    color:white;
    overflow:hidden;
}

/* =========================
   GLOBAL UI SCALE
========================= */
:root{
    --ui-scale: 1;
    --modal-scale: 1;
}

@media (max-width: 900px) {
    :root{
        --ui-scale: 1.1;
        --modal-scale: 1.08;
    }
}

@media (max-width: 600px) {
    :root{
        --ui-scale: 1.22;
        --modal-scale: 1.18;
    }
}

/* =========================
   BUTTONS
========================= */
button {
    padding: 10px 14px;
    border-radius: 10px;

    border: 1px solid rgba(255,255,255,0.08);

    cursor: pointer;

    font-size: 14px;
    font-weight: 600;

    min-height: 42px;

    touch-action: manipulation;

    transition: all 0.18s ease;

    background: rgba(25,25,25,0.85);
    color: #eaeaea;

    backdrop-filter: blur(8px);

    box-shadow:
        0 8px 18px rgba(0,0,0,0.25);

    user-select: none;
}

button:hover {
    background: rgba(40,40,40,0.95);
    border-color: rgba(255,255,255,0.18);
    transform: translateY(-1px);
    box-shadow:
        0 12px 25px rgba(0,0,0,0.35);
}

button:active {
    transform: translateY(0px) scale(0.98);
    box-shadow:
        0 6px 12px rgba(0,0,0,0.25);
}

.editBtn {
    background: rgba(52, 152, 219, 0.18);
    color: #7fc7ff;
    border: 1px solid rgba(52, 152, 219, 0.35);
}

.editBtn:hover {
    background: rgba(52, 152, 219, 0.28);
}

.saveBtn {
    background: rgba(46, 204, 113, 0.18);
    color: #7dffb0;
    border: 1px solid rgba(46, 204, 113, 0.35);
}

.saveBtn:hover {
    background: rgba(46, 204, 113, 0.28);
}

/* =========================
   TOOLBAR
========================= */
.toolbar {

    position: fixed;

    top: 12px;
    left: 50%;

    transform:
        translateX(-50%)
        scale(var(--ui-scale));

    transform-origin: top center;

    background: rgba(27,27,27,0.88);

    backdrop-filter: blur(10px);

    display:flex;
    align-items:center;
    justify-content:center;
    flex-wrap:wrap;

    gap:8px;

    padding:10px 12px;

    border-radius:14px;

    z-index:9999999;

    max-width: calc(100vw - 20px);

    box-sizing:border-box;

    border:1px solid rgba(255,255,255,0.08);

    box-shadow:
        0 10px 25px rgba(0,0,0,0.35);
}

/* =========================
   TOOLBOX
========================= */
#toolbox{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    justify-content:center;
}

/* =========================
   GEAR BUTTON
========================= */
#gearBtn {

    position: fixed;

    top: 12px;
    right: 12px;

    width: 48px;
    height: 48px;

    display:flex;
    align-items:center;
    justify-content:center;

    background: rgba(20,20,20,0.88);

    backdrop-filter: blur(10px);

    border:1px solid rgba(255,255,255,0.1);

    border-radius:14px;

    font-size:22px;

    cursor:pointer;

    z-index:9999999;

    transition:0.2s ease;

    transform:
        scale(var(--ui-scale));

    transform-origin: top right;

    box-shadow:
        0 10px 25px rgba(0,0,0,0.35);
}

#gearBtn:hover{
    background: rgba(40,40,40,0.95);

    transform:
        scale(calc(var(--ui-scale) * 1.05));
}

/* =========================
   WRAP + CANVAS
========================= */
#wrap {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

canvas {
    width:100%;
    height:100%;
    display:block;
}

/* =========================
   TOOLTIP
========================= */
#tooltip {

    position:absolute;

    background:rgba(0,0,0,0.85);

    padding:6px 8px;

    font-size:12px;

    border-radius:6px;

    pointer-events:none;

    z-index:9999998;

    backdrop-filter: blur(6px);

    border:1px solid rgba(255,255,255,0.08);
}

/* =========================
   MODALS
========================= */
#loginModal,
#refModal {

    display:none;

    position:fixed;

    inset:0;

    background:rgba(0,0,0,0.78);

    justify-content:center;
    align-items:center;

    z-index:9999999;

    padding:18px;

    box-sizing:border-box;

    backdrop-filter: blur(6px);
}

/* =========================
   MODAL BOX
========================= */
#loginModal > div,
.modalBox {

    position:relative;

    width:350px;

    background: rgba(34,34,34,0.96);

    border:1px solid rgba(255,255,255,0.08);

    border-radius:18px;

    padding:22px;

    box-sizing:border-box;

    text-align:center;

    transform: scale(var(--modal-scale));

    backdrop-filter: blur(10px);

    box-shadow:
        0 18px 40px rgba(0,0,0,0.45);
}

/* =========================
   MODAL HEADER
========================= */
.modalHeader {
    position: relative;
    margin-bottom: 16px;
    text-align: center;
}

.modalHeader h3 {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
}

/* =========================
   CLOSE BUTTON
========================= */
.modalClose {

    position:absolute;

    top:-14px;
    right:-14px;

    width:34px;
    height:34px;

    display:flex;
    align-items:center;
    justify-content:center;

    font-size:18px;
    line-height:1;

    color:#aaa;

    background:#181818;

    border:1px solid rgba(255,255,255,0.08);

    border-radius:10px;

    cursor:pointer;

    user-select:none;

    transition:0.15s ease;
}

.modalClose:hover {
    background:#333;
    color:#fff;
}

/* =========================
   INPUTS
========================= */
#loginModal input,
.modalBox input {

    width:100%;

    box-sizing:border-box;

    padding:12px 14px;

    margin-top:10px;

    border:none;

    border-radius:10px;

    outline:none;

    display:block;

    background:#111;

    color:white;

    font-size:16px !important;

    border:1px solid rgba(255,255,255,0.08);
}

input,
textarea,
select {
    font-size:16px !important;
}

/* =========================
   MODAL BUTTONS
========================= */
.modalBox button,
#loginModal button {

    width:100%;

    margin-top:14px;

    padding:12px;

    border:none;

    border-radius:10px;

    cursor:pointer;

    font-size:14px;
    font-weight:bold;
}

/* =========================
   MODAL COLORS
========================= */
.btnSave {
    background:#2ecc71;
    color:white;
}

.btnCancel {
    background:#e74c3c;
    color:white;
}

/* =========================
   ERRORS
========================= */
#refError,
#error {
    color:#ff6b6b;
    min-height:20px;
    margin-top:8px;
    font-size:14px;
}

/* =========================
   PLAYER LIST
========================= */
#playerList {

    margin-top:10px;

    max-height:350px;

    overflow-y:auto;

    text-align:left;

    border:1px solid #333;

    border-radius:12px;

    background:#181818;
}

/* =========================
   MOBILE
========================= */
@media (max-width: 600px) {

    .toolbar {

        top: 8px;

        width: fit-content;
        max-width: calc(100vw - 20px);

        padding: 10px;

        gap: 6px;
    }

    button {

        flex: 1 1 auto;

        min-width: 70px;

        font-size: 13px;

        padding: 10px 8px;
    }

    #toolbox {
        width:100%;
    }

    #gearBtn {
        top:8px;
        right:8px;
    }

    .modalHeader h3 {
        font-size:18px;
    }

    #loginModal > div,
    .modalBox {

        width:min(94vw, 360px);

        padding:20px;
    }
}

#playerFinder {
    width: 200px;
    max-width: 60vw;   /* important for mobile */
    flex: 0 0 auto;    /* don't grow */

    padding: 4px 10px;
    border: none;
    border-radius: 10px;
    outline: none;

    background: #111;
    color: white;
    font-size: 14px;

    cursor: pointer;
    box-sizing: border-box;

    appearance: none;
}

#anchorModal {
    display: none;

    position: fixed;
    inset: 0;

    background: rgba(0,0,0,0.78);

    justify-content: center;
    align-items: center;

    z-index: 9999999;

    padding: 18px;
    box-sizing: border-box;

    backdrop-filter: blur(6px);
}

#anchorModal > div {
    width: 200px;

    background: rgba(34,34,34,0.96);

    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;

    padding: 22px;

    text-align: center;

    box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}

#anchorModal input {
    width: 90px;
    padding: 6px 8px;
    font-size: 13px;
    text-align: center;
    border-radius: 8px;
}
