/* ─── Training Dashboard Layout ─── */
.training-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 40px;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  width: 100%;
}

/* ─── Header Stats ─── */
.training-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  position: relative; /* For absolute centering */
  min-height: 60px;
}

.progress-container {
  border: 1px solid rgba(255, 205, 48, 0.3);
  padding: 8px 24px;
  border-radius: 8px;
  background: rgba(255, 205, 48, 0.05);
}

.label-dim {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 1px;
}

.value-bright {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  margin-left: 8px;
}

.pause-goal-plate {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

.pause-goal-plate.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
}

.pause-goal-content {
    width: 100%;
    max-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pause-goal-text {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.pg-label {
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.pg-val {
    font-size: 11px;
    font-weight: 900;
    color: var(--accent);
}

.pg-bar-bg {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1.5px;
    overflow: hidden;
}

.pg-bar-fill {
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-indicator {
  display: none; /* Replaced by side-info style */
}

/* ─── Game Area ─── */
.game-area-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 100px;
  width: 100%;
  flex: 1;
}

/* ─── Hotkeys (Left) ─── */
.side-info {
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-info .info-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.hotkey-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.key-cap {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

/* ─── N-Back Grid (Center) ─── */
.nback-grid-wrap {
  position: relative;
  width: 320px;
  height: 320px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 205, 48, 0.15);
  border-radius: 20px;
  padding: 15px;
}

.grid-3x3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  height: 100%;
}

.grid-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 30px 5px rgba(255, 205, 48, 0.4);
}

.center-cross {
  font-size: 32px;
  color: var(--accent);
  font-weight: 400;
  opacity: 0.5;
}

/* ─── Controls (Bottom) ─── */
.training-bottom {
  margin-top: 60px; /* Increased gap from game field */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.controls-group {
  display: flex;
  gap: 60px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.control-text {
  display: flex;
  flex-direction: column;
  text-align: right;
}
.control-item.left-aligned .control-text { text-align: left; }

.mouse-btn-label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.mouse-action-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ─── Mouse Icons ─── */
.mouse-icon {
  width: 22px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  position: relative;
}

.mouse-icon::after {
  content: '';
  position: absolute;
  top: 4px;
  width: 50%;
  height: 10px;
  background: var(--accent);
  opacity: 0.3;
}

.mouse-icon.right-active::after { right: 0; border-top-right-radius: 6px; background: var(--accent); opacity: 1; box-shadow: 0 0 5px var(--accent); }
.mouse-icon.left-active::after  { left: 0; border-top-left-radius: 6px; background: var(--accent); opacity: 1; box-shadow: 0 0 5px var(--accent); }

/* Sidebar Collapse and Responsive logic moved to local-page.css */

/* Toggle Button */
.sidebar-toggle-btn {
  margin-top: auto;
  width: 100%;
  height: 60px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center; /* Always center the icon */
  transition: color 0.3s;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-toggle-btn:hover { color: var(--accent); }

.arrow-icon {
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(-45deg); /* Points left */
  transition: transform 0.4s;
}

.sidebar.collapsed .arrow-icon {
  transform: rotate(135deg); /* Points right */
  margin-left: 0;
}

/* Sidebar Locking during active session */
.sidebar.locked {
  pointer-events: none !important;
  opacity: 0.3 !important;
  filter: grayscale(1) !important;
  transition: all 0.5s ease;
}

/* ─── Responsive: 1024px (Tablets & Mobile) ─── */
@media (max-width: 1024px) {
    .training-top {
        flex-direction: column;
        padding: 0;
        min-height: auto;
        gap: 15px; /* Increased from 10px */
        margin-bottom: 25px; /* Added air below top plates */
    }

    .training-progress-plate, 
    .level-box {
        width: 100% !important;
        max-width: 320px !important; /* Match PC grid width */
        margin-left: auto !important;
        margin-right: auto !important;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        align-items: center;
        padding: 10px 16px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 12px;
    }

    .pause-goal-plate {
        width: 100% !important;
        max-width: 320px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important; /* Block instead of grid to allow full-width content */
        padding: 10px 16px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 12px;
        position: relative !important;
        left: auto !important;
        transform: none !important;
    }

    .pause-goal-plate.hide {
        display: none;
    }

    .pause-goal-content {
        max-width: none !important;
        width: 100% !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
    }

    .training-top .side-info {
        width: 100% !important; /* Override 140px from global */
    }

    .game-area-wrapper {
        margin: 30px 0; /* Add air above and below the grid */
    }

    .training-bottom {
        margin-top: 50px; /* Increased from 30px */
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .controls-group {
        gap: 12px;
        width: 100%;
        max-width: 320px; /* Match grid width on tablets */
        justify-content: center;
        margin: 0 auto;
    }

    .control-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 8px 10px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 10px;
    }

    .mouse-icon {
        width: 18px;
        height: 26px;
    }

    .mouse-icon::after {
        top: 3px;
        height: 8px;
    }

    .mouse-btn-label {
        font-size: 8px;
    }

    .mouse-action-label {
        font-size: 10px;
    }

    .training-progress-plate {
        background: rgba(255, 205, 48, 0.06);
        border-color: rgba(255, 205, 48, 0.15);
    }

    .training-progress-plate .label-dim, 
    .level-box .info-title {
        justify-self: end;
        text-align: right;
        margin: 0 !important;
        font-size: 11px;
    }

    .training-progress-plate .value-bright, 
    .level-box .value-bright {
        justify-self: start;
        text-align: left;
        margin: 0 !important;
        font-size: 18px;
    }

    .pause-goal-plate {
        position: relative;
        left: auto;
        transform: none;
    }

    .pause-goal-plate.hide {
        display: none;
    }

    .pause-goal-content {
        max-width: 100%;
        background: rgba(255, 205, 48, 0.03);
        padding: 4px 0;
        border-radius: 0;
        border: none;
    }
}

/* ─── Responsive: 768px (Mobile & Tablets) ─── */
@media (max-width: 768px) {
    .training-layout {
        padding: 10px 15px 30px;
        justify-content: flex-start;
        gap: 20px;
        height: auto;
        min-height: 100%;
    }

    .training-progress-plate, 
    .level-box,
    .pause-goal-plate {
        max-width: 290px !important; /* Match 768px grid width */
    }

    .level-box {
        text-align: center;
        margin: 0 !important;
    }

    .game-area-wrapper {
        display: contents; /* Allows children to be ordered relative to training-layout */
    }

    .grid-stage {
        order: 2;
        width: 100%;
        display: flex;
        justify-content: center;
        margin-bottom: 10px;
    }

    /* Move Hotkeys to the VERY Bottom and align them on axis */
    .game-area-wrapper .side-info:first-child {
        order: 10;
        width: 100%;
        max-width: 260px;
        margin: 30px auto 0;
        padding-top: 20px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        display: grid;
        grid-template-columns: 80px 1fr; /* Fixed width for keys column to align them */
        gap: 12px 16px;
        align-items: center;
    }

    .game-area-wrapper .side-info:first-child .info-title {
        grid-column: 1 / -1;
        text-align: center;
        margin-bottom: 8px;
    }

    .hotkey-row {
        display: contents; /* Key-cap and label-dim become direct grid children */
    }

    .key-cap {
        justify-self: end; /* Align keys to the center-line of the two columns */
        min-width: 60px;
        text-align: center;
    }

    .game-area-wrapper .side-info:first-child .label-dim {
        justify-self: start;
        text-align: left;
    }

    /* Hide redundant level info on the side */
    .game-area-wrapper .side-info.right-aligned {
        display: none;
    }

    .nback-grid-wrap {
        width: 290px;
        height: 290px;
        margin: 0 auto;
    }

    /* Daily Goal bar below Level Indicator */
    .pause-goal-plate {
        max-width: 290px !important;
    }

    .pause-goal-content {
        width: 100% !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
    }

    .training-bottom {
        margin-top: 20px;
        order: 4; /* ABOVE hotkeys (which are 10) */
        width: 100%;
    }

    .controls-group {
        gap: 20px;
        width: 100%;
        justify-content: center;
    }

    .control-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 12px 10px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 12px;
    }

    /* Keep PC-style alignment: Text-Icon for Left, Icon-Text for Right */
    #btn-position {
        flex-direction: row;
    }
    #btn-audio {
        flex-direction: row;
    }

    .control-text {
        /* Allow HTML inline styles (text-align: right/left) to work */
    }

    .mouse-icon {
        width: 28px;
        height: 40px;
    }
}

/* ─── Responsive: 480px (Standard Mobile) ─── */
@media (max-width: 480px) {
    .training-progress-plate, 
    .level-box,
    .pause-goal-plate {
        max-width: 260px !important; /* Match 480px grid width */
    }

    .nback-grid-wrap {
        width: 260px;
        height: 260px;
        padding: 10px;
    }

    .grid-3x3 {
        gap: 8px;
    }

    .value-bright {
        font-size: 16px;
    }

    .mouse-btn-label {
        font-size: 9px;
    }

    .mouse-action-label {
        font-size: 11px;
    }
}

/* ─── Fluid Adaptation for Ultra-Narrow Screens (410px and below) ─── */
@media (max-width: 410px) {
    .training-progress-plate, 
    .level-box,
    .pause-goal-plate,
    .nback-grid-wrap,
    .controls-group {
        max-width: calc(100vw - 80px) !important;
    }

    .nback-grid-wrap {
        width: calc(100vw - 80px) !important;
        height: calc(100vw - 80px) !important;
        padding: 8px;
    }

    .grid-3x3 {
        gap: 6px;
    }

    .controls-group {
        gap: 8px;
    }

    .control-item {
        padding: 6px 8px;
        gap: 6px;
        border-radius: 8px;
    }

    .mouse-icon {
        width: 14px;
        height: 22px;
    }

    .mouse-icon::after {
        top: 2px;
        height: 7px;
    }

    .mouse-btn-label {
        font-size: 7px;
    }

    .mouse-action-label {
        font-size: 9px;
    }

    .center-cross {
        font-size: 24px;
    }
}

