/* ==================== 自定義布局（替換 Bootstrap） ==================== */

.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ===== Header / toolbar / stats ===== */
.app-header {
    margin-bottom: 4px;
}

.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.app-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #1a1a1a;
}

body.dark-mode .app-title {
    color: #f2f2f7;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    background: #f4f7f9;
    border: 1px solid #e3ebf0;
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
}

body.dark-mode .stat-card {
    background: #171726;
    border-color: #2c2c40;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: #0b6e99;
    font-variant-numeric: tabular-nums;
}

.stat-value-good {
    color: #2e7d32;
}

body.dark-mode .stat-value {
    color: #7ec8e3;
}

body.dark-mode .stat-value-good {
    color: #81c784;
}

.stat-label {
    margin-top: 4px;
    font-size: 12px;
    color: #6b7c86;
}

body.dark-mode .stat-label {
    color: #9aa3ad;
}

.toolbar-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.toolbar-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: center;
    margin-top: 8px;
}

.select-grow {
    flex: 1 1 220px;
    max-width: none;
    min-width: 180px;
}

.select-duration {
    flex: 0 0 auto;
    width: auto;
    min-width: 110px;
    max-width: none;
}

.btn-start {
    flex: 0 0 auto;
    min-width: 108px;
    padding: 9px 18px;
}

.btn-ghost {
    background: transparent;
    color: #5a6a75;
    border: 1px solid #d0dbe3;
}

.btn-ghost:hover {
    background: #f0f4f7;
    color: #333;
}

body.dark-mode .btn-ghost {
    color: #c5c9d1;
    border-color: #3a3a55;
}

body.dark-mode .btn-ghost:hover {
    background: #222238;
    color: #fff;
}

.btn-text {
    background: transparent;
    color: #0b6e99;
    padding: 4px 0;
    font-size: 13px;
}

.btn-text:hover {
    text-decoration: underline;
    background: transparent;
}

.btn-text:disabled {
    color: #a0aab2;
    text-decoration: none;
    cursor: not-allowed;
    opacity: 1;
}

body.dark-mode .btn-text {
    color: #8fd3f0;
}

body.dark-mode .btn-text:disabled {
    color: #667;
}

.progress-container {
    margin-top: 12px;
}

.practice-hint {
    position: absolute;
    z-index: 3;
    left: 18px;
    right: 18px;
    top: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: #60707a;
    font-size: 13px;
    pointer-events: none;
    border: 1px dashed #c5d6e0;
}

body.dark-mode .practice-hint {
    background: rgba(18, 18, 31, 0.92);
    color: #9aa3ad;
    border-color: #3a3a55;
}

.practice-hint.is-hidden {
    display: none;
}

@media (max-width: 640px) {
    .stats-row {
        gap: 8px;
    }

    .stat-value {
        font-size: 18px;
    }

    .toolbar-primary {
        flex-direction: column;
        align-items: stretch;
    }

    .select-duration,
    .btn-start {
        width: 100%;
    }
}

.app-row {
    display: flex;
    flex-wrap: wrap;
}

.app-main-col {
    flex: 0 0 66.666%;
    max-width: 66.666%;
    padding: 0 15px;
}

.form-section {
    margin-bottom: 15px;
}

.float-right {
    float: right;
}

/* 按鈕樣式 */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #0096CD;
    color: white;
}

.btn-primary:hover {
    background-color: #007acc;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* 深色模式按鈕 */
body.dark-mode .btn-primary {
    background-color: #673ab7;
}

body.dark-mode .btn-primary:hover {
    background-color: #7e57c2;
}

body.dark-mode .btn-secondary {
    background-color: #4a148c;
}

body.dark-mode .btn-secondary:hover {
    background-color: #6a1b9a;
}

/* 選單樣式 */
select.select {
    font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    max-width: 400px;
}

body.dark-mode select.select {
    background-color: #0f3460;
    color: #eee;
    border-color: #16213e;
}

/* 進度條 */
.progress {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-custom {
    height: 100%;
    background: linear-gradient(90deg, #0096CD 0%, #007ACC 100%);
    transition: width 0.3s ease;
}

body.dark-mode .progress {
    background-color: #2a2a4a;
}

/* footer */
footer {
    margin-top: 30px;
    padding: 20px 0;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #999;
}

body.dark-mode footer {
    border-top-color: #2a2a4a;
}

/* 響應式 */
@media (max-width: 768px) {
    .app-main-col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ==================== 原有樣式 ==================== */

body{
        font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
        font-size: 15px;
      }

      .copyright{
        text-align: center;
      }

      .navbar-brand{
          margin-right: 20px;
          padding: 0px;
      }

      .navbar-band img{
          height: 100%;
      }

      .space-20{
          height: 20px;
      }

      .space-100{
          height: 100px;
      }

      .headline h3{
          margin-left: 15px;
      }

      .headline-text{
          font-size: 14px;
      }

      .index-game-list .img-block{
          width: 200px;
          height: 200px;
          overflow: hidden;
          margin: auto auto;
      }

      .index-game-list .index-game-box{
          margin-bottom: 10px;
          padding-bottom: 5px;
          border: 1px solid #f5f5f5;
      }

      .ad{
          min-height: 350px;
          max-height: 350px;
      }

      .ad-banner{
          height: 100px;
      }


      .index-game-list .index-game-box b{
          font-size: 17px;
      }

      .dropdown-menu-zone{
          margin-bottom: 15px;
          text-align: right;
      }

      .gamelist .gamelist-box{
          border-radius: 3px;
          border: 1px solid #f5f5f5;
          padding: 5px;
          margin-bottom: 10px;
          min-height: 350px;
          margin: 15px;
          text-align: center;
      }


      .gamelist .gamelist-box b{
          text-align: left;
      }

      .gamelist a:hover{
        text-decoration: none;
      }

      .gamelist .gamelist-box img{
          height: 200px;
          overflow: hidden;
      }

      .gamelist .gamelist-box .img-area{
          text-align: center;
          margin-top: 5px;
          margin-bottom: 5px;    
      }

      .game-img-slide .col-md-4{
          margin-bottom: 5px;
      }

      .game-panel h4{
          font-size: 16px;
      }

      .game-detail-area{
          text-align: center;
      }

      .game-download-area{
          text-align: center;
          margin-top: 10px;
          margin-bottom: 10px;
      }

      .game-download-area a{
          padding: 20px;
          font-size: 16px;
          font-weight: bold;
      }

      .pagination-zone{
          text-align: center;
      }

      .center-cropped {
          width: 100%;
          height: 200px;
          background-position: center center;
          background-repeat: no-repeat;
      }

      #login-dp{
          min-width: 250px;
          padding: 14px 14px 0;
          overflow:hidden;
          background-color:rgba(255,255,255,.8);
      }
      #login-dp .help-block{
          font-size:12px    
      }
      #login-dp .bottom{
          background-color:rgba(255,255,255,.8);
          border-top:1px solid #ddd;
          clear:both;
          padding:14px;
      }
      #login-dp .social-buttons{
          margin:12px 0    
      }
      #login-dp .social-buttons a{
          width: 49%;
      }
      #login-dp .form-group {
          margin-bottom: 10px;
      }
      .btn-fb{
          color: #fff;
          background-color:#3b5998;
      }
      .btn-fb:hover{
          color: #fff;
          background-color:#496ebc 
      }
      .btn-tw{
          color: #fff;
          background-color:#55acee;
      }
      .btn-tw:hover{
          color: #fff;
          background-color:#59b5fa;
      }
      .note-group-select-from-files {
        display: none;
      }

      .home-banner{
        max-height: 150px;
        margin: 0 auto;
      }

      .home-fav-game-box{
        margin: 10px;
        white-space: normal;
        text-align: left;
        max-height: 150px;
        overflow: hidden;
      }


      .lightbox {
        /** Default lightbox to hidden */
        display: none;

        /** Position and style */
        position: fixed;
        z-index: 999;
        width: 100%;
        height: 100%;
        text-align: center;
        left: 0;
        background: rgba(0,0,0,0.8);
      }

      .lightbox img {
        /** Pad the lightbox image */
        max-width: 90%;
        max-height: 80%;
        margin-top: 5%;
      }

      .lightbox:target {
        /** Remove default browser outline */
        outline: none;

        /** Unhide lightbox **/
        display: block;
      }

      @media(min-width: 768px){
          .headline{
              max-height: 430px;
              overflow-y: hidden;
          }  

          .lightbox{
            top: 20px;
          }
      }

      @media(max-width:768px){
          #login-dp{
              background-color: inherit;
              color: #fff;
          }
          #login-dp .bottom{
              background-color: inherit;
              border-top:0 none;
          }

          #login-dp a{
              color: #FFF;
          }

          .lightbox{
            top: 50px;
          }
      }

      @media(min-width: 768px){
        .index-anim-space{
          height: 100px;
        }
        .index-animation{
          max-width: 1000px;
        }

        .enter-1{
          /*margin: -15px;*/
        }
        .enter-2{
          /*margin: -15px;*/
        }
        .enter-3{
          /*margin: -15px;*/
        }
        .enter-4{
          /*margin: -15px;*/
        }

        .index-anim-block, .index-anim-block img{
          text-align: center;
        }
      }


      @media(max-width: 768px){

        .index-anim-space{
          height: 0px;
        }
        .index-animation{
          max-width: 100%;
          max-height: 100%;
        }

        .index-anim-block, .index-anim-block img{
          text-align: center;
          height: 100%;
        }

        .index-anim-block div{
          height: 150px;
          margin-bottom: -20px;
        }

        .copyright{
          margin-top: -100px;
        }
      }

      /* ==================== 前端優化新增樣式 ==================== */

      /* 進度條樣式 */
      .progress-container {
          margin: 15px 0;
          display: none;
      }

      .progress-bar-custom {
          height: 8px;
          background: linear-gradient(90deg, #0096CD 0%, #007ACC 100%);
      }

      .progress-bar-custom .progress-bar {
          height: 100%;
          background: #0096CD;
          transition: width 0.3s ease;
      }

      /* 錯誤標記樣式 */
      .char-correct {
          color: #333;
      }

      .char-wrong {
          color: #d9534f;
          background-color: #f2dede;
          border-radius: 2px;
          text-decoration: underline;
      }

      .char-current {
          background-color: #d9edf7;
          border-radius: 2px;
      }

      .char-pending {
          color: #999;
      }

      /* 隱藏元素 */
      .hidden {
          display: none;
      }

      /* 按鈕樣式優化 */
      .btn-start {
          width: 100%;
          max-width: 300px;
      }

      /* 成績顯示區域 */
      .stats-display {
          display: flex;
          justify-content: space-around;
          flex-wrap: wrap;
          margin: 20px 0;
          padding: 15px;
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          border-radius: 10px;
          color: white;
          text-align: center;
      }

      .stat-item {
          margin: 10px;
          min-width: 120px;
      }

      .stat-value {
          font-size: 28px;
          font-weight: bold;
          display: block;
      }

      .stat-label {
          font-size: 14px;
          opacity: 0.9;
      }

/* 深色模式 */
body.dark-mode {
    background-color: #1a1a2e;
    color: #eee;
}

body.dark-mode .container {
    background-color: #16213e;
}

body.dark-mode .headline-text h4,
body.dark-mode .headline-text h5 {
    color: #eee;
}

body.dark-mode .stats-display {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}

body.dark-mode #txtInput {
    background-color: #0f3460;
    color: #eee;
}

body.dark-mode #divText {
    color: #eee;
}

body.dark-mode select,
body.dark-mode .btn-primary,
body.dark-mode .btn-secondary {
    background-color: #0f3460;
    color: #eee;
    border-color: #16213e;
}

body.dark-mode .stat-label {
    color: #aaa;
}

      /* 響應式設計 */
      @media (max-width: 768px) {
          .stats-display {
              flex-direction: column;
          }
          
          .stat-item {
              width: 100%;
          }
          
          .headline-text h4 {
              font-size: 20px;
          }
          
          .btn-start {
              width: 100%;
              margin-bottom: 10px;
          }
          
          #divMain {
              height: 350px;
          }
      }
      
      @media (max-width: 480px) {
          .headline-text h4 {
              font-size: 18px;
          }
          
          #divMain {
              height: 300px;
          }
          
          #divText, #txtInput {
              font-size: 18px;
              line-height: 45px;
          }
      }

      /* 字符標記容器 */
      .char-container span {
          padding: 2px 1px;
          border-radius: 2px;
      }

      /* 字符標記樣式 */
      .char-correct { color: #28a745; }
      .char-wrong { color: #dc3545; background-color: rgba(220, 53, 69, 0.2); text-decoration: underline; }
      .char-pending { color: #6c757d; }
      .char-current {
          background-color: #0096CD;
          color: white;
          border-radius: 3px;
          box-shadow: 0 0 0 2px rgba(0, 150, 205, 0.35);
      }

      body.dark-mode .char-correct { color: #81c784; }
      body.dark-mode .char-wrong { color: #ef9a9a; background-color: rgba(239, 154, 154, 0.18); }
      body.dark-mode .char-pending { color: #9aa0a6; }
      body.dark-mode .char-current {
          background-color: #7e57c2;
          box-shadow: 0 0 0 2px rgba(126, 87, 194, 0.45);
      }

      /* 加載動畫 */
      .loading {
          display: inline-block;
          width: 20px;
          height: 20px;
          border: 3px solid rgba(255,255,255,.3);
          border-radius: 50%;
          border-top-color: #fff;
          animation: spin 1s ease-in-out infinite;
      }

      @keyframes spin {
          to { transform: rotate(360deg); }
      }
      
      /* 彈窗動畫 */
      @keyframes modalSlideIn {
          from {
              opacity: 0;
              transform: translateY(-50px) scale(0.9);
          }
          to {
              opacity: 1;
              transform: translateY(0) scale(1);
          }
      }

      /* 成績歷史 */
      #historyList {
          margin-top: 10px;
      }

      .history-empty {
          color: #999;
          font-size: 13px;
          font-style: italic;
      }

      body.dark-mode .history-empty {
          color: #666;
      }

      .history-item {
          display: flex;
          align-items: center;
          padding: 8px 12px;
          margin-bottom: 4px;
          background: #f8f9fa;
          border-radius: 6px;
          font-size: 13px;
          gap: 10px;
      }

      body.dark-mode .history-item {
          background: #1a1a2e;
          color: #ccc;
      }

      .history-text {
          font-weight: bold;
          min-width: 120px;
          color: #333;
      }

      body.dark-mode .history-text {
          color: #eee;
      }

      .history-stats {
          flex: 1;
          color: #666;
      }

      body.dark-mode .history-stats {
          color: #999;
      }

      .history-date {
          color: #999;
          font-size: 12px;
          white-space: nowrap;
      }

      body.dark-mode .history-date {
          color: #666;
      }

/* 操作列 / 模式 / 紀錄區 */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn-accent {
    background-color: #e65100;
    color: #fff;
}

.btn-accent:hover:not(:disabled) {
    background-color: #f57c00;
}

.btn-accent:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

body.dark-mode .btn-accent {
    background-color: #ff8a65;
    color: #1a1a2e;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
    background: #eee;
    color: #333;
}

.btn-small:hover {
    background: #ddd;
}

body.dark-mode .btn-small {
    background: #333;
    color: #eee;
}

body.dark-mode .btn-small:hover {
    background: #444;
}

.btn-file {
    display: inline-block;
    cursor: pointer;
    margin: 0;
}

.mode-badge {
    margin-left: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: normal;
    vertical-align: middle;
    background: #fff3e0;
    color: #e65100;
}

body.dark-mode .mode-badge {
    background: #4a2c0a;
    color: #ffb74d;
}

.ad-slot {
    margin: 20px 0 8px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-slot[hidden] {
    display: none !important;
    min-height: 0;
    margin: 0;
}

.ad-slot .adsbygoogle {
    width: 100%;
}

.records-section {
    margin-top: 20px;
}

.records-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.records-title {
    margin: 0;
    font-size: 16px;
}

.records-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.records-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 720px) {
    .records-grid {
        grid-template-columns: 1fr;
    }
}

.records-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

body.dark-mode .records-subtitle {
    color: #999;
}

.history-tag {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    background: #ffe0b2;
    color: #e65100;
    font-weight: normal;
}

body.dark-mode .history-tag {
    background: #4a2c0a;
    color: #ffb74d;
}

.modal-btn {
    padding: 10px 22px;
    font-size: 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    color: #fff;
}

.modal-btn-primary {
    background: #1976d2;
}

.modal-btn-accent {
    background: #e65100;
}

.modal-btn-next {
    background: #00897b;
}

.session-box {
    margin: 12px 0 18px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

body.dark-mode .session-box {
    background: #1a1a2e;
}

.session-code-banner {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
}

.session-code-banner.is-new {
    background: #fff3e0;
    border-color: #ffb74d;
}

body.dark-mode .session-code-banner {
    background: #1e2a3a;
    border-color: #455a64;
}

body.dark-mode .session-code-banner.is-new {
    background: #3e2723;
    border-color: #ff8a65;
}

.session-code-banner-label {
    font-size: 13px;
    color: #555;
}

body.dark-mode .session-code-banner-label {
    color: #bbb;
}

.session-code-display {
    font-family: Consolas, monospace;
    font-size: 22px;
    letter-spacing: 0.12em;
    color: #0d47a1;
    user-select: all;
}

body.dark-mode .session-code-display {
    color: #90caf9;
}

.session-code-banner.is-new .session-code-display {
    color: #e65100;
}

body.dark-mode .session-code-banner.is-new .session-code-display {
    color: #ffb74d;
}

.session-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.session-label {
    font-size: 13px;
    color: #555;
    margin: 0;
}

body.dark-mode .session-label {
    color: #bbb;
}

.session-input {
    width: 110px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: Consolas, monospace;
}

body.dark-mode .session-input {
    background: #12121f;
    border-color: #444;
    color: #eee;
}

.session-status {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

.session-status.is-error {
    color: #c62828;
}

body.dark-mode .session-status {
    color: #999;
}

body.dark-mode .session-status.is-error {
    color: #ef9a9a;
}

.btn-small.btn-primary {
    background: #0096CD;
    color: #fff;
}

.btn-small.btn-primary:hover {
    background: #007acc;
}

/* 時限 / 自訂文章 */
.practice-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.option-label {
    font-size: 14px;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

body.dark-mode .option-label {
    color: #bbb;
}

.select-inline {
    width: auto;
    min-width: 120px;
}

.custom-panel {
    margin-top: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

body.dark-mode .custom-panel {
    background: #1a1a2e;
}

.custom-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.5;
    font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    resize: vertical;
    min-height: 96px;
}

body.dark-mode .custom-textarea {
    background: #12121f;
    border-color: #444;
    color: #eee;
}

.custom-panel-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* 練習區：較矮，讓第一屏可看到 AdSense；短視窗再收窄 */
#divMain.practice-box {
    height: min(300px, calc(100dvh - 360px)) !important;
    min-height: 200px;
}

#txtInput.practice-input,
#divText.practice-text {
    height: 100% !important;
}

/* 練習區深色模式（基本布局用 inline，避免 CSS 未上載時爆版） */
body.dark-mode #divMain.practice-box {
    background-color: #12121f !important;
    border-color: #3a3a55 !important;
}

body.dark-mode #txtInput.practice-input {
    background-color: #12121f !important;
    color: #e8e8ef !important;
}

body.dark-mode #divText.practice-text {
    color: #e8e8ef !important;
}

@media (max-width: 720px) {
    #divMain.practice-box {
        height: min(260px, calc(100dvh - 340px)) !important;
        min-height: 180px;
    }

    #txtInput.practice-input,
    #divText.practice-text {
        font-size: 20px !important;
        line-height: 44px !important;
        padding-top: 16px !important;
    }
}

body.dark-mode .modal-btn-primary {
    background: #673ab7;
}

body.dark-mode .modal-btn-accent {
    background: #ff8a65;
    color: #1a1a2e;
}

body.dark-mode .modal-btn-next {
    background: #26a69a;
}