* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    background: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
}

.calculator {
    width: 100%;
    height: 100vh;
    height: 100dvh;

    display: flex;
    flex-direction: column;

    background: #ffffff;
}


/* =========================
   DISPLAY
========================= */

.display {
    flex: 1;

    min-height: 150px;

    display: flex;
    flex-direction: column;

    justify-content: flex-end;
    align-items: flex-end;

    padding: 25px 38px 15px;

    overflow: hidden;
}

#expression {
    width: 100%;

    min-height: 30px;

    color: #888888;

    font-size: 22px;

    text-align: right;

    overflow: hidden;
    white-space: nowrap;
}

#result {
    width: 100%;

    color: #222222;

    font-size: 48px;
    font-weight: 400;

    text-align: right;

    overflow: hidden;
    white-space: nowrap;
}


/* =========================
   TOP TOOLS
========================= */

.tools {
    display: flex;

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

    margin: 0 38px;

    padding: 5px 0 15px;

    border-bottom: 1px solid #dddddd;
}

.tool-button {
    border: none;
    outline: none;

    background: transparent;

    color: #888888;

    font-size: 27px;

    height: 55px;

    cursor: pointer;
}

.tool-button:active {
    opacity: 0.5;
}


/* =========================
   BUTTON AREA
========================= */

.buttons {
    display: grid;

    grid-template-columns: repeat(4, 1fr);

    gap: 12px;

    padding: 30px 38px 22px;
}


/* =========================
   GENERAL BUTTON
========================= */

.button {
    width: 100%;
    aspect-ratio: 1 / 1;

    border: none;
    outline: none;

    border-radius: 50%;

    background: #f0f0f2;

    font-size: 34px;
    font-weight: 400;

    color: #555555;

    cursor: pointer;

    transition:
        transform 0.08s ease,
        background 0.08s ease;
}

.button:active {
    transform: scale(0.93);
}


/* =========================
   NUMBERS
========================= */

.number {
    color: #4d4d4d;
}


/* =========================
   FUNCTIONS
========================= */

.function {
    color: #378f18;
}


/* Clear button */
.button[data-action="clear"] {
    color: #d43c35;
}


/* =========================
   OPERATORS
========================= */

.operator {
    color: #328c15;

    font-size: 38px;
}


/* =========================
   EQUALS
========================= */

.equals {
    background: #39a900;

    color: #ffffff;

    font-size: 42px;
}


/* =========================
   HISTORY
========================= */

.history-panel {
    position: fixed;

    top: 0;
    right: -100%;

    width: 100%;
    max-width: 430px;

    height: 100%;

    background: #ffffff;

    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);

    z-index: 100;

    transition: right 0.25s ease;

    padding: 25px;
}

.history-panel.open {
    right: 0;
}

.history-header {
    display: flex;

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

    padding-bottom: 20px;

    border-bottom: 1px solid #dddddd;

    font-size: 24px;
}

.history-header button {
    border: none;

    background: transparent;

    font-size: 32px;

    color: #555555;
}

#historyList {
    padding-top: 20px;

    overflow-y: auto;

    max-height: calc(100% - 80px);
}

.history-item {
    padding: 15px 5px;

    border-bottom: 1px solid #eeeeee;

    font-size: 18px;
}


/* =========================
   SMALL SCREENS
========================= */

@media (max-height: 700px) {

    .display {
        min-height: 120px;

        padding-top: 10px;
    }

    #result {
        font-size: 40px;
    }

    .buttons {
        gap: 8px;

        padding-top: 18px;
        padding-bottom: 12px;
    }

    .button {
        font-size: 28px;
    }

    .operator {
        font-size: 32px;
    }

    .equals {
        font-size: 36px;
    }
}

/* =========================
   CALCULATOR ADVERTISEMENT
========================= */

#calculatorAd {

    position: fixed;

    inset: 0;

    z-index: 99999;

    display: flex;

    align-items: center;

    justify-content: center;

    padding: 20px;

    box-sizing: border-box;

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

    opacity: 0;

    visibility: hidden;

    pointer-events: none;

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}


/* =========================
   VISIBLE
========================= */

#calculatorAd.ad-visible {

    opacity: 1;

    visibility: visible;

    pointer-events: auto;
}


/* =========================
   AD BOX
========================= */

.calculator-ad {

    position: relative;

    width: 100%;

    max-width: 430px;

    max-height: 90vh;

    overflow: hidden;

    border-radius: 20px;

    background: #ffffff;

    box-shadow:
        0 20px 60px
        rgba(0, 0, 0, 0.45);

    animation:
        adAppear 0.25s ease;
}


/* =========================
   APPEAR
========================= */

@keyframes adAppear {

    from {

        transform:
            scale(0.94);

        opacity: 0;
    }

    to {

        transform:
            scale(1);

        opacity: 1;
    }
}


/* =========================
   ONLINE AREA
========================= */

.ad-online {

    position: relative;

    width: 100%;

    background: #000000;
}


/* =========================
   VIDEO
========================= */

.ad-video {

    display: block;

    width: 100%;

    height: auto;

    max-height: 80vh;

    min-height: 220px;

    object-fit: contain;

    background: #000000;
}


/* =========================
   PLAY BUTTON
========================= */

.ad-play-button {

    position: absolute;

    left: 50%;

    top: 50%;

    transform:
        translate(-50%, -50%);

    display: none;

    align-items: center;

    justify-content: center;

    min-width: 130px;

    min-height: 48px;

    padding: 12px 20px;

    border: none;

    border-radius: 25px;

    background: rgba(
        255,
        255,
        255,
        0.95
    );

    color: #111111;

    font-size: 15px;

    font-weight: 600;

    cursor: pointer;

    box-shadow:
        0 5px 20px
        rgba(0, 0, 0, 0.35);
}


/* =========================
   OFFLINE AREA
========================= */

.ad-offline {

    width: 100%;

    background: #ffffff;
}


/* =========================
   OFFLINE BANNER
========================= */

.ad-banner {

    display: block;

    width: 100%;

    height: auto;

    max-height: 80vh;

    object-fit: contain;
}


/* =========================
   CLOSE BUTTON
========================= */

.ad-close {

    position: absolute;

    top: 10px;

    right: 10px;

    z-index: 10;

    display: flex;

    align-items: center;

    justify-content: center;

    width: 36px;

    height: 36px;

    padding: 0;

    border: none;

    border-radius: 50%;

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

    color: rgba(255, 255, 255, 0.55);

    font-size: 25px;

    line-height: 1;

    cursor: not-allowed;

    opacity: 0.55;

    -webkit-tap-highlight-color: transparent;

}


/* =========================
   CLOSE ENABLED
========================= */

.ad-close.ad-close-active {

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

    color: #ffffff;

    opacity: 1;

    cursor: pointer;
}

/* =========================
   AD LABEL
========================= */

.ad-label {

    padding: 7px 10px;

    text-align: center;

    background: #ffffff;

    color: #777777;

    font-size: 11px;

    line-height: 1.2;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 480px) {

    #calculatorAd {

        padding: 12px;
    }


    .calculator-ad {

        max-width: 100%;

        border-radius: 16px;
    }


    .ad-video {

        min-height: 180px;

        max-height: 78vh;
    }


    .ad-close {

        width: 34px;

        height: 34px;

        top: 8px;

        right: 8px;

        font-size: 23px;
    }

}