/* =========================================================
   GLOBAL RESET
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

body {
    min-height: 100vh;
    font-family: Arial, sans-serif;
    text-align: center;
    background: linear-gradient(135deg, #f793f2, #67e4f5);
    color: #333;
    overflow-x: hidden;
}


/* =========================================================
   MAIN LAYOUT
========================================================= */

.main-box {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    padding: 15px;
}


/* =========================================================
   LEFT / HUD
========================================================= */

.left-box {
    flex: 0 0 300px;
    width: 300px;
    padding: 5px;
}

.hud {
    width: 100%;
    background: #fff;
    border: 1px solid #dfe5ee;
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 10px 30px rgba(31, 41, 55, .10),
        0 3px 8px rgba(31, 41, 55, .06);
    color: #111827;
}

.hud-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 13px;
    background: linear-gradient(135deg, #eef6ff, #f7faff);
    border-bottom: 1px solid #e3eaf3;
}

.hud-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 23px;
}

.hud-label {
    margin-bottom: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #64748b;
}

.hud-header h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.2;
}

.hud-header p {
    margin: 5px 0 0;
    font-size: 11px;
    color: #635bff;
    font-weight: 700;
}


/* =========================================================
   STAT BOX
========================================================= */

.stat-box {
    margin: 7px 14px;
    padding: 7px 12px;
    min-height: 38px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-title {
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #4f46e5;
}


/* =========================================================
   RESULT GRID HUD
========================================================= */

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 14px;
}

.result-card {
    min-height: 55px;
    padding: 7px;
    text-align: center;
    border-radius: 11px;
    border: 1px solid;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.correct-card {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.correct-card .result-title {
    color: #15803d;
}

.correct-card .result-value {
    color: #16a34a;
}

.wrong-card {
    background: #fef2f2;
    border-color: #fecaca;
}

.wrong-card .result-title {
    color: #b91c1c;
}

.wrong-card .result-value {
    color: #dc2626;
}

.result-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 3px;
}

.result-value {
    font-size: 18px;
    font-weight: 600;
}


/* =========================================================
   WPM
========================================================= */

.wpm-box {
    margin: 8px 14px 14px;
    padding: 8px;
    background: linear-gradient(135deg, #f5f3ff, #eef2ff);
    border: 1px solid #ddd6fe;
    border-radius: 11px;
    text-align: center;
}

.wpm-title {
    margin-bottom: 4px;
    color: #6366f1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.wpm-value {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 5px;
    color: #4338ca;
}

.wpm-value span {
    font-size: 20px;
    font-weight: 700;
}

.wpm-value small {
    font-size: 10px;
    font-weight: 700;
}


/* =========================================================
   MAIN RIGHT
========================================================= */

.main-right {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
}


/* =========================================================
   DETAILS / GUIDE
========================================================= */

.details-box {
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-width: 0;
}

.guide-text {
    flex: 1;
    min-width: 0;
    padding: 15px 10px;
    margin-top: 10px;
    border-radius: 5px 0 0 5px;
    font-weight: bold;
    background: #ffffff46;
    overflow-wrap: anywhere;
}

.guide-text span {
    font-size: clamp(18px, 2.5vw, 30px);
    font-weight: bold;
    padding: 1px;
}

#guideText .dim {
    color: #999 !important;
}

.active-char {
    background: #3700ff;
    color: #fff;
    border-radius: 3px;
}

.correct-char {
    color: green;
}

.wrong-char {
    color: red;
    text-decoration: underline;
}

.details-box select {
    flex: 0 0 auto;
    max-width: 250px;
    color: #3700ff;
    font-weight: bold;
    font-size: 16px;
    padding: 12px 35px 12px 12px;
    border: none;
    border-radius: 0 5px 5px 0;
    background: #ffffff70;
    margin-top: 10px;
    cursor: pointer;
}


/* =========================================================
   KEYBOARD CONTAINER
========================================================= */

.keyboard {
    /* width: 100%; */
    /* max-width: 100%; */
    overflow-x: auto;
    overflow-y: hidden;
    background: #e4e3e377;
    margin-top: 10px;
    border: 2px solid #999;
    padding: 12px;
    padding-bottom: 25px;
    border-radius: 15px;

    /* Smooth mobile scrolling */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.keyboard-main {
    display: flex;
    justify-content: flex-start;
    width: max-content;
    min-width: max-content;
}

.main-block,
.numpad-block,
.enter {
    flex-shrink: 0;
}


/* =========================================================
   KEYBOARD ROW
========================================================= */

.keyboard-row {
    display: flex;
    justify-content: flex-start;
    margin: 2px 0;
    white-space: nowrap;
}

.keyboard-row1 {
    display: flex;
    align-items: center;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 3px;
}


/* =========================================================
   KEYS
========================================================= */

.key {
    border: 1px solid #75cef1;
    padding: 10px;
    margin: 2px;
    border-radius: 5px;
    min-width: 40px;
    min-height: 40px;
    text-align: center;
    background: #fff;
    box-shadow: 0 3px 2px 0 #75cef1;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    font-size: 14px;
}

.key:hover {
    transform: translateY(-1px);
}

.key.wide {
    min-width: 70px;
}

.key.extra-wide {
    min-width: 280px;
}

.key.active {
    background: #ffcccc;
}

.key.correct {
    background: #c8e6c9;
}

.key.wrong {
    background: #ffcdd2;
}

.key1 {
    width: 100px;
}

.key3 {
    width: 90px;
}

.key4 {
    width: 110px;
}

.key5 {
    width: 51px;
}

.key6 {
    width: 86px;
}

.key8 {
    height: 78px;
    margin-top: 6px;
}

.key9 {
    width: 43px;
}

.reset1 {
    margin-left: 20px;
}

#reset {
    background: #fff;
    color: #db3030;
    font-weight: bold;
}

#keyfinger {
    border: 1px solid red;
}

.numpad-block {
    margin-left: 20px;
}

.enter {
    padding-top: 2px;
    width: 40px;
    display: flex;
    flex-direction: column;
}

.buttent {
    display: flex;
    flex-direction: column;
}

body.dark {
    background: #121212;
    color: #eee;
}

body.dark .key {
    background: #333;
    color: #eee;
    border-color: #555;
}

body.dark .guide-text {
    background: #333;
    color: #eee;
}


/* =========================================================
   RESULT POPUP
========================================================= */

.result-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 12px;
}

.result-box {
    width: min(950px, 100%);
    max-height: 94vh;
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    overflow-y: auto;
    overflow-x: hidden;
}


/* =========================================================
   RESULT HEADER
========================================================= */

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.result-header h2 {
    flex: 1;
    margin: 0;
    color: #1976d2;
    font-size: clamp(20px, 4vw, 30px);
}

.close-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    color: #f44336;
    cursor: pointer;
    font-size: 18px;
}


/* =========================================================
   RESULT CIRCLES
========================================================= */

.circle-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.circle-card {
    position: relative;
    text-align: center;
    min-width: 0;
}

.circleSvg {
    width: 110px;
    height: 110px;
    max-width: 100%;
    transform: rotate(-90deg);
}

.bg {
    fill: none;
    stroke: #ddd;
    stroke-width: 10;
}

.progress {
    fill: none;
    stroke: #00c853;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 314.16;
    stroke-dashoffset: 314.16;
    transition: 1s;
}

.circleText {
    position: absolute;
    top: 39px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    font-weight: bold;
}

.circle-card h4 {
    font-size: 15px;
    margin: 4px 0;
}


/* =========================================================
   PROGRESS
========================================================= */

.progress-bar {
    width: 100%;
    height: 16px;
    background: #ddd;
    border-radius: 50px;
    overflow: hidden;
    margin: 15px 0;
}

#progressFill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00c853, #4caf50);
    transition: 1.2s;
}


/* =========================================================
   DATE / TIME
========================================================= */

.date-time {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 8px;
    margin-bottom: 10px;
}

.date-time .ldate {
    color: #f44336;
    font-weight: 500;
}

.date-time .date {
    font-weight: 500;
}


/* =========================================================
   GRADE DETAILS
========================================================= */

.Grade_details_box {
    display: flex;
    width: 100%;
    gap: 15px;
}

.Grade-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 60%;
}

.grade-details {
    display: flex;
    align-items: center;
    min-width: 0;
}

#name {
    width: 50%;
    font-size: 18px;
    margin: 0 15px 10px 0;
    color: #3700ff;
    display: flex;
    justify-content: flex-end;
}

#rLesson,
#student_Id,
#resultGrade {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    word-break: break-word;
}

.Grade-right {
    width: 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.Grade-right img {
    height: 90px;
    width: 90px;
    object-fit: cover;
    border: 5px dashed #3700ff;
    border-radius: 50%;
}

#student_name {
    max-width: 100%;
    font-size: 18px;
    word-break: break-word;
}


/* =========================================================
   RESULT BUTTONS
========================================================= */

.result-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 12px 0 0;
    border-top: 1px solid #ddd;
}

#backBtn,
#restartBtn,
#nextBtn,
#printBtn {
    width: 130px;
    padding: 10px;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
}

#backBtn {
    background: #fb8c00;
}

#restartBtn {
    background: #1976d2;
}

#nextBtn {
    background: #00c853;
}

#printBtn {
    background: #3c00c8;
}


/* =========================================================
   RESPONSIVE ROTATED KEYBOARD SYSTEM
   Desktop / Laptop / Tablet / Mobile / Small Mobile
========================================================= */


/* =========================================================
   DESKTOP
   1200px और उससे ऊपर
========================================================= */

@media screen and (min-width: 1201px) {

    .keyboard {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .keyboard-main {
        display: flex;
        flex-direction: row;
        width: max-content;
        min-width: max-content;

        /* Normal keyboard */
        transform: none;
        transform-origin: center center;
    }

    .keyboard-row {
        display: flex;
        flex-direction: row;
    }

    .key {
        flex-shrink: 0;
    }
}


/* =========================================================
   LAPTOP
   769px - 1200px
========================================================= */

@media screen and (min-width: 769px)  {

    .keyboard {
        width: 100%;
        max-width: 100%;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 10px;
    }

    .keyboard-main {
        display: flex;
        flex-direction: row;

        width: max-content;
        min-width: max-content;

        /* Normal */
        transform: none;
        transform-origin: center center;
    }
    
    .keyboard-row1{
        display:none;
    }

    .keyboard-row {
        display: flex;
        flex-direction: row;

        white-space: nowrap;
    }

    .key {
        min-width: 38px;
        min-height: 38px;

        padding: 5px;

        font-size: 13px;
    }

    .key.wide {
        min-width: 65px;
    }

    .key.extra-wide {
        min-width: 230px;
    }
    .left-box{
        display:none;
    }

}


/* =========================================================
   TABLET
   600px - 768px
========================================================= */

@media screen and (min-width: 600px) and (max-width: 768px) {

    .keyboard {
        width: 100%;

        overflow: hidden;

        padding: 8px;

        position: relative;
    }

    .keyboard-main {
        display: flex;

        width: max-content;
        min-width: max-content;

        /* 90 Degree Rotation */
        transform: rotate(90deg);
        transform-origin: center center;
    }

    .keyboard-row {
        display: flex;

        flex-direction: row;

        white-space: nowrap;
    }

    .key {
        min-width: 36px;
        min-height: 36px;

        padding: 7px 5px;

        font-size: 12px;
    }

    .key.wide {
        min-width: 62px;
    }

    .key.extra-wide {
        min-width: 210px;
    }

    .key1 {
        width: 85px;
    }

    .key3 {
        width: 75px;
    }

    .key4 {
        width: 90px;
    }

    .key5 {
        width: 43px;
    }

    .key6 {
        width: 70px;
    }

    .key8 {
        height: 68px;
    }

    .key9 {
        width: 36px;
    }
        .keyboard-row1{
        display:none;
    }
}


/* =========================================================
   MOBILE
   421px - 599px
========================================================= */

@media screen and (min-width: 421px) and (max-width: 599px) {

    .keyboard {
        position: relative;

        width: 100%;

        overflow: hidden;

        padding: 7px;

        border-radius: 9px;
    }

    .keyboard-main {
        display: flex;

        width: max-content;
        min-width: max-content;

        /* 90 Degree Rotation */
        transform: rotate(90deg);
        transform-origin: center center;
    }

    .keyboard-row {
        display: flex;

        flex-direction: row;

        white-space: nowrap;
    }

    .key {
        min-width: 34px;
        min-height: 35px;

        padding: 6px 5px;

        font-size: 11px;
    }

    .key.wide {
        min-width: 60px;
    }

    .key.extra-wide {
        min-width: 200px;
    }

    .key1 {
        width: 82px;
    }

    .key3 {
        width: 73px;
    }

    .key4 {
        width: 87px;
    }

    .key5 {
        width: 42px;
    }

    .key6 {
        width: 68px;
    }

    .key8 {
        height: 66px;
    }

    .key9 {
        width: 35px;
    }

    .numpad-block {
        margin-left: 8px;
    }
}


/* =========================================================
   SMALL MOBILE
   330px - 420px
========================================================= */

@media screen and (min-width: 331px) and (max-width: 420px) {

    .guide-text span {
        font-size: 14px;
    }

    /* First row hide */
    .keyboard-row1 {
        display: none;
    }

    .keyboard {
        position: relative;

        width: 100%;

        overflow: hidden;

        padding: 6px;

        border-radius: 8px;
    }

    .keyboard-main {
        display: flex;

        width: max-content;
        min-width: max-content;

        /* 90 Degree Rotation */
        transform: rotate(90deg);
        transform-origin: center center;
    }

    .keyboard-row {
        display: flex;

        flex-direction: row;

        white-space: nowrap;
    }

    .key {
        min-width: 32px;
        min-height: 34px;

        padding: 6px 4px;

        font-size: 11px;
    }

    .key.wide {
        min-width: 58px;
    }

    .key.extra-wide {
        min-width: 190px;
    }

    .key1 {
        width: 78px;
    }

    .key3 {
        width: 70px;
    }

    .key4 {
        width: 82px;
    }

    .key5 {
        width: 40px;
    }

    .key6 {
        width: 65px;
    }

    .key8 {
        height: 65px;
    }

    .key9 {
        width: 34px;
    }

    .numpad-block {
        margin-left: 8px;
    }
}


/* =========================================================
   VERY SMALL MOBILE
   330px से नीचे
========================================================= */

@media screen and (max-width: 330px) {

    .guide-text span {
        font-size: 13px;
    }

    /* First row hide */
    .keyboard-row1 {
        display: none;
    }

    .keyboard {
        position: relative;

        width: 100%;

        overflow: hidden;

        padding: 5px;

        border-radius: 7px;
    }

    .keyboard-main {
        display: flex;

        width: max-content;
        min-width: max-content;

        /* 90 Degree Rotation */
        transform: rotate(90deg);
        transform-origin: center center;
    }

    .keyboard-row {
        display: flex;

        flex-direction: row;

        white-space: nowrap;
    }

    .key {
        min-width: 30px;
        min-height: 32px;

        padding: 5px 3px;

        font-size: 10px;
    }

    .key.wide {
        min-width: 55px;
    }

    .key.extra-wide {
        min-width: 175px;
    }

    .key1 {
        width: 72px;
    }

    .key3 {
        width: 65px;
    }

    .key4 {
        width: 76px;
    }

    .key5 {
        width: 38px;
    }

    .key6 {
        width: 60px;
    }

    .key8 {
        height: 60px;
    }

    .key9 {
        width: 32px;
    }

    .numpad-block {
        margin-left: 6px;
    }
}


/* =========================================================
   LANDSCAPE TABLET
========================================================= */

@media screen and (min-width: 600px)
       and (max-width: 1024px)
       and (orientation: landscape) {

    .keyboard {
        width: 100%;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 8px;
    }

    .keyboard-main {
        width: max-content;
        min-width: max-content;

        transform: none;
    }

    .keyboard-row {
        display: flex;
        flex-direction: row;
    }
}


/* =========================================================
   LANDSCAPE MOBILE
========================================================= */

@media screen and (max-width: 599px)
       and (orientation: landscape) {

    .keyboard {
        width: 100%;

        max-height: 75vh;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 6px;
    }

    .keyboard-main {
        width: max-content;
        min-width: max-content;

        /* Landscape में rotate नहीं */
        transform: none;
    }

    .keyboard-row {
        display: flex;
        flex-direction: row;
    }

    .keyboard-row1 {
        display: flex;
    }

    .key {
        min-width: 32px;
        min-height: 32px;

        padding: 5px;

        font-size: 10px;
    }

    .key.wide {
        min-width: 55px;
    }

    .key.extra-wide {
        min-width: 180px;
    }
}


/* =========================================================
   TOUCH DEVICE
========================================================= */

@media (hover: none) and (pointer: coarse) {

    .key:hover {
        transform: none;
    }

    .key {
        cursor: pointer;

        -webkit-tap-highlight-color: transparent;

        touch-action: manipulation;
    }
}


/* =========================================================
   PREVENT HORIZONTAL PAGE SCROLL
========================================================= */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}


/* =========================================================
   ROTATION SAFETY
========================================================= */

.keyboard-main,
.keyboard-row,
.key {
    backface-visibility: hidden;
}





/* =========================================================
   ROTATED SCREEN
   896 × 414
========================================================= */

@media screen and (min-width: 896px) and (max-width: 896px)
       and (min-height: 414px) and (max-height: 414px) {

    .main-box {
        width: 100%;
        max-width: 896px;
        padding: 5px;
        gap: 10px;
    }

    .main-right {
        width: 100%;
        padding: 0;
    }

    .details-box {
        width: 100%;
    }

    .guide-text {
        padding: 8px 10px;
        margin-top: 5px;
    }

    .guide-text span {
        font-size: 18px;
    }

    .details-box select {
        max-width: 180px;
        font-size: 13px;
        padding: 8px 25px 8px 8px;
        margin-top: 5px;
    }


    /* =========================
       KEYBOARD
    ========================= */

    .keyboard {
        width: 100%;
        max-width: 896px;

        height: auto;

        margin-top: 5px;

        padding: 6px;

        overflow-x: auto;
        overflow-y: hidden;

        border-radius: 8px;
    }

    .keyboard-main {
        display: flex;

        width: max-content;
        min-width: max-content;

        transform: none;
    }

    .keyboard-row {
        display: flex;
        flex-direction: row;

        margin: 1px 0;

        white-space: nowrap;
    }


    /* =========================
       KEYS
    ========================= */

    .key {
        min-width: 32px;
        min-height: 32px;

        padding: 5px 4px;

        margin: 1px;

        font-size: 10px;

        border-radius: 4px;
    }

    .key.wide {
        min-width: 55px;
    }

    .key.extra-wide {
        min-width: 180px;
    }

    .key1 {
        width: 75px;
    }

    .key3 {
        width: 68px;
    }

    .key4 {
        width: 80px;
    }

    .key5 {
        width: 39px;
    }

    .key6 {
        width: 63px;
    }

    .key8 {
        height: 62px;
    }

    .key9 {
        width: 33px;
    }

    .numpad-block {
        margin-left: 8px;
    }


    /* =========================
       RESULT POPUP
    ========================= */

    .result-popup {
        padding: 5px;
        align-items: center;
    }

    .result-box {
        width: 96%;
        max-width: 850px;
        max-height: 98vh;

        padding: 10px;

        border-radius: 12px;
    }

    .circle-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
    }

    .circleSvg {
        width: 75px;
        height: 75px;
    }

    .circleText {
        top: 26px;
        font-size: 13px;
    }

    .circle-card h4 {
        font-size: 11px;
        margin: 2px 0;
    }


    /* =========================
       RESULT BUTTONS
    ========================= */

    .result-buttons {
        gap: 6px;
        margin-top: 5px;
        padding-top: 6px;
    }

    #backBtn,
    #restartBtn,
    #nextBtn,
    #printBtn {
        width: 105px;
        padding: 7px 5px;
        font-size: 12px;
    }


    /* =========================
       GRADE DETAILS
    ========================= */

    .Grade_details_box {
        flex-direction: row;
        gap: 8px;
    }

    .Grade-left {
        width: 70%;
    }

    .Grade-right {
        width: 30%;
    }

    .Grade-right img {
        width: 60px;
        height: 60px;
    }

    #student_name {
        font-size: 13px;
    }

    #name,
    #rLesson,
    #student_Id,
    #resultGrade {
        font-size: 13px;
    }
}