body {
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
    color: #fff;
    font-family: Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    transition: background 0.5s cubic-bezier(.4,0,.2,1), color 0.5s cubic-bezier(.4,0,.2,1);
}

body.light-mode {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #232526;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 1rem;
    transition: background 0.5s cubic-bezier(.4,0,.2,1), color 0.5s cubic-bezier(.4,0,.2,1);
}

.title {
    font-size: 2.5rem;
    font-weight: bold;
    font-style: oblique;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    letter-spacing: 2px;
    text-shadow: 1px 1px 8px #000a;
    text-align: center;
    color: inherit;
}

section {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    transition: gap 0.3s, flex-direction 0.3s, background 0.5s cubic-bezier(.4,0,.2,1), color 0.5s cubic-bezier(.4,0,.2,1);
}

.buttonx, .reset-score {
    background: linear-gradient(135deg, #2d2d2d 0%, #444 100%);
    color: inherit;
    border: none;
    border-radius: 40px / 32px;
    box-shadow: 0 6px 20px #0003, 0 2px 6px #fff1 inset;
    transition: background 0.2s, box-shadow 0.2s, transform 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    position: relative;
    min-width: 130px;
    min-height: 130px;
    aspect-ratio: 1 / 1;
    font-size: 1.3rem;
    will-change: transform;
    margin: 0 0.5rem;
}
.buttonx:active, .reset-score:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px #0005;
    transition: transform 0.08s cubic-bezier(.4,2,.6,1), box-shadow 0.08s;
}
.buttonx:hover, .buttonx:focus {
    background: linear-gradient(135deg, #444 0%, #2d2d2d 100%);
    box-shadow: 0 10px 28px #0005, 0 3px 10px #fff2 inset;
    transform: scale(1.09);
    cursor: pointer;
}
body.light-mode .buttonx {
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    box-shadow: 0 4px 16px #0001, 0 1.5px 4px #23252611 inset;
    border: 1.5px solid #bbb;
}
body.light-mode .buttonx:hover, body.light-mode .buttonx:focus {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    box-shadow: 0 8px 24px #0002, 0 2px 8px #23252611 inset;
}
body.light-mode .buttonx:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px #23252622;
}

.iconx, .iconxyz {
    height: 100px;
    width: 100px;
    margin: 0;
    vertical-align: middle;
    pointer-events: none;
    transition: height 0.2s, width 0.2s;
}

.js-result {
    color: gold;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
    text-align: center;
}
body.light-mode .js-result {
    color: #e6b800;
}

.js-moves {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.js-score {
    font-style: oblique;
    margin-bottom: 1.5rem;
    text-align: center;
}

.reset-score {
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
    color: gold;
    font-size: 1rem;
    border: none;
    border-radius: 24px / 18px;
    padding: 0.35rem 1.2rem;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.12s;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 8px #0002, 0 1px 2px #fff1 inset;
    will-change: transform;
    letter-spacing: 1px;
}
.reset-score:hover, .reset-score:focus {
    background: linear-gradient(135deg, #444 0%, #2d2d2d 100%);
    color: #fffbe6;
    box-shadow: 0 4px 12px #0003, 0 1.5px 4px #fff2 inset;
    cursor: pointer;
}
.reset-score:active {
    transform: scale(0.93);
    box-shadow: 0 1px 4px #0003;
}
body.light-mode .reset-score {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #e6b800;
    box-shadow: 0 2px 8px #23252611, 0 1px 2px #23252611 inset;
}
body.light-mode .reset-score:hover, body.light-mode .reset-score:focus {
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    color: #fff;
    box-shadow: 0 4px 12px #23252622, 0 1.5px 4px #23252611 inset;
}
body.light-mode .reset-score:active {
    transform: scale(0.93);
    box-shadow: 0 1px 4px #23252622;
}

footer {
    text-align: center;
    color: #aaa;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    margin-top: 2rem;
}
body.light-mode footer {
    color: #555;
}

.toggle-theme {
    background: none;
    border: 1.5px solid #fff;
    color: #fff;
    font-size: 1rem;
    border-radius: 22px;
    padding: 0.25rem 0.8rem;
    margin-bottom: 1.2rem;
    margin-top: 0.2rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    outline: none;
    box-shadow: none;
    opacity: 0.7;
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    z-index: 10;
}
.toggle-theme:hover, .toggle-theme:focus {
    background: #fff2;
    color: gold;
    border-color: gold;
    opacity: 1;
}
body.light-mode .toggle-theme {
    color: #232526;
    border-color: #232526;
    background: #fff8;
    opacity: 0.7;
}
body.light-mode .toggle-theme:hover, body.light-mode .toggle-theme:focus {
    background: #e6b80022;
    color: #e6b800;
    border-color: #e6b800;
    opacity: 1;
}
#theme-icon {
    font-size: 1.2em;
    vertical-align: middle;
}

@media (max-width: 900px) {
    section {
        gap: 1.2rem;
    }
    .buttonx {
        min-width: 100px;
        min-height: 100px;
    }
    .iconx, .iconxyz {
        height: 70px;
        width: 70px;
    }
}
@media (max-width: 600px) {
    main {
        padding-top: 1.5rem;
    }
    section {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.7rem;
        align-items: center;
        justify-content: center;
        margin-bottom: 1.2rem;
    }
    .buttonx {
        min-width: 70px;
        min-height: 70px;
        width: 90px;
        max-width: 110px;
        margin: 0.3rem 0.2rem;
    }
    .iconx, .iconxyz {
        height: 50px;
        width: 50px;
    }
    #toggle-theme {
        right: 0.7rem;
        top: 0.7rem;
    }
}

@media (max-width: 400px) {
    .buttonx {
        min-width: 54px;
        min-height: 54px;
        width: 70px;
        max-width: 80px;
    }
    .iconx, .iconxyz {
        height: 36px;
        width: 36px;
    }
}

/* Fix for stuck :active on mobile (remove after tap) */
@media (hover: none) and (pointer: coarse) {
  .buttonx:active, .reset-score:active {
    transition: none;
  }
}

/* Modal styles */
#reset-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0; top: 0; right: 0; bottom: 0;
    background: rgba(30, 30, 40, 0.35);
    backdrop-filter: blur(2.5px);
    align-items: center;
    justify-content: center;
    transition: background 0.4s cubic-bezier(.4,0,.2,1);
}
#reset-modal.active {
    display: flex;
    animation: modal-fade-in 0.4s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.reset-modal-content {
    background: rgba(40, 40, 55, 0.92);
    color: #fffbe6;
    border-radius: 22px;
    box-shadow: 0 8px 32px #0006;
    padding: 2.2rem 1.5rem 1.5rem 1.5rem;
    min-width: 260px;
    max-width: 90vw;
    text-align: center;
    position: relative;
    transition: background 0.4s cubic-bezier(.4,0,.2,1), color 0.4s cubic-bezier(.4,0,.2,1);
    opacity: 0;
    transform: scale(0.95);
    animation: modal-content-in 0.4s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes modal-content-in {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.reset-modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.1rem;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 1px;
}
.reset-modal-btns {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    margin-top: 1.2rem;
}
.reset-modal-btn {
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
    color: gold;
    border: none;
    border-radius: 18px;
    padding: 0.5rem 1.3rem;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 2px 8px #0002;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.12s;
}
.reset-modal-btn:active {
    transform: scale(0.95);
}
.reset-modal-btn:hover, .reset-modal-btn:focus {
    background: linear-gradient(135deg, #444 0%, #2d2d2d 100%);
    color: #fffbe6;
}
body.light-mode #reset-modal {
    background: rgba(220, 220, 240, 0.35);
}
body.light-mode .reset-modal-content {
    background: rgba(255, 255, 255, 0.97);
    color: #232526;
    box-shadow: 0 8px 32px #23252622;
}
body.light-mode .reset-modal-btn {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #e6b800;
}
body.light-mode .reset-modal-btn:hover, body.light-mode .reset-modal-btn:focus {
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    color: #fff;
}
