/*=========================================================
  CogniGrid
  Version : 0.3.0
  Codename: Framework

  Think. Plan. Discover.
  Every attempt is a chance to learn.
=========================================================*/


/*=========================================================
  PAGE
=========================================================*/

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

body{

    font-family:Arial, Helvetica, sans-serif;

    background:#eef3f8;

    color:#222;

}


/*=========================================================
  HEADER
=========================================================*/

header{

    background:#1565c0;

    color:white;

    padding:18px;

    text-align:center;

}

header h1{

    font-size:34px;

}

.tagline{

    margin-top:8px;

    font-style:italic;

}


/*=========================================================
  MAIN LAYOUT
=========================================================*/

main {

    max-width: 1400px;

    margin: 25px auto;

    display: flex;

    gap: 30px;

    align-items: flex-start;

    padding: 0 20px;

}
.gameArea {

    flex: 1;

    display: flex;

    flex-direction: column;

    gap: 20px;

}

.sidePanel {

    width: 320px;

    display: flex;

    flex-direction: column;

    gap: 20px;

}

/*=========================================================
  PANELS
=========================================================*/

.sidebar{

    width:260px;

}

.panel {

    background: white;

    border-radius: 12px;

    padding: 18px;

    box-shadow: 0 4px 12px rgba(0,0,0,.12);

}
.panel h2{

    margin-bottom:12px;

    color:#1565c0;

}


/*=========================================================
  BOARD
=========================================================*/

.boardPanel {

    background: white;

    border-radius: 12px;

    padding: 20px;

    display: flex;

    justify-content: center;

    box-shadow: 0 4px 12px rgba(0,0,0,.12);

}

#board{

    display:grid;

    grid-template-columns:repeat(7,60px);

    grid-template-rows:repeat(7,60px);

    gap:2px;

}


/*=========================================================
  CELLS
=========================================================*/

.cell{

    width:60px;

    height:60px;

    background:white;

    border:1px solid #cfd8dc;

    display:flex;

    justify-content:center;

    align-items:center;

    cursor:pointer;

    transition:.15s;

    font-size:28px;

    font-weight:bold;

}

.cell:hover{

    background:#d9ecff;

}


/*=========================================================
  PIECE CARDS
=========================================================*/

.pieceCard {


    border: 2px solid #cfd8dc;

    border-radius: 8px;

    margin-bottom: 12px;

    padding: 10px;

    cursor: pointer;

    transition: .2s;

}
    

.pieceCard:hover{

    background:#f2f8ff;

}

.pieceCard.selected{

    border-color:#1565c0;

    background:#d9ecff;

}

.pieceTitle{

    display:flex;

    justify-content:space-between;

    margin-bottom:8px;

    font-weight:bold;

}

/*.shape {

    white-space: pre;

    font-family: monospace;

    font-size: 20px;

    line-height: 1.05;

    margin: 8px 0;

}*/
.selectedPlacedPiece {

    outline: 3px solid orange;
    outline-offset: -3px;

}

/*=========================================================
  LETTER BUTTONS
=========================================================*/

#letterContainer{

     display: flex;

    justify-content: center;

    gap: 8px;

    flex-wrap: wrap;
    
    /*display:grid;

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

    gap:10px;*/

}

.letterButton{

    height:48px;

    font-size:24px;
    font-weight: bold;
    cursor:pointer;

    border:none;

    border-radius:8px;

    background:#eceff1;
    cursor: pointer;
    transition:0.2s;

}

.lettersPanel {

    text-align: center;

}


.letterButton:hover{

    background:#bbdefb;

}

.selectedLetter{
  border: 3px solid #3498db;

    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5);

    transform: translateY(-2px);
   

}


/*=========================================================
  STATISTICS
=========================================================*/

.panel p {

    display:flex;

    justify-content:space-between;

    align-items:center;

    margin-bottom:10px;

    font-size:15px;

}

.panel span{

    font-weight:bold;

    color:#1565c0;

}


/*=========================================================
  FOOTER
=========================================================*/

footer{

    margin-top:20px;

    padding:18px;

    text-align:center;

    color:#555;

}

.footerMessage{

    margin-top:8px;

    font-style:italic;

}


/*=========================================================
  FUTURE GHOST PIECE
=========================================================*/

.ghost{

    background:#90caf9 !important;

}

.invalidGhost{

    background:#ef9a9a !important;

}
#rotateButton {

    margin-top: 5px;
    padding: 10px 18px;

    font-size: 16px;
    font-weight: bold;

    border: none;
    border-radius: 8px;

    background: #1e88e5;
    color: white;

    cursor: pointer;

}

#rotateButton:hover {

    background: #1565c0;
}




/*=========================================================
DISABLED PIECES
=========================================================*/

.pieceCard.disabled {

    opacity: 0.35;

    cursor: not-allowed;

    border: 2px solid #999;

}
/*ToolBar*/
 
#toolbar {

    display: flex;

    justify-content: center;

    gap: 12px;

    flex-wrap: wrap;

}


#toolbar button {

    min-width: 110px;

    padding: 8px 14px;

    font-size: 15px;

    font-weight: bold;

    border: none;

    border-radius: 10px;

    cursor: pointer;

    transition: 0.2s;

}

#toolbar button:hover {

    transform: translateY(-2px);

}
#rotateButton {

    background: #3498db;

    color: white;

}

#undoButton {

    background: #f39c12;

    color: white;

}

#removePieceButton {

    background: #e74c3c;

    color: white;

}

#saveButton {

    background: #27ae60;

    color: white;

}

#loadButton {

    background: #8e44ad;

    color: white;

}
#toolbar button:active {

    transform: scale(0.97);

}



/* {

    font-size: 24px;

    line-height: 1.1;

    font-family: monospace;

    margin-bottom: 10px;

}*/
.pieceCount {

    font-size: 20px;

    font-weight: bold;

    color: #3498db;

}

/*=========================================================
COGNIGRID v0.5
NEW GAME LAYOUT
=========================================================*/



#toolbar button:hover {

    transform: translateY(-2px);

}

#toolbar button:active {

    transform: scale(.97);

}

#rotateButton {
    background: #3498db;
}

#undoButton {
    background: #f39c12;
}

#removePieceButton {
    background: #e74c3c;
}

#toolbar {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

#toolbar button {
    min-width: 120px;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: .2s;
}

#saveButton {
    background: #27ae60;
}

#loadButton {
    background: #8e44ad;
}


/*=========================================================
BOARD + STATUS
=========================================================*/

.gameWorkspace {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 260px;
    gap: 20px;
    align-items: start;
}


/*=========================================================
BOARD
=========================================================*/

.boardPanel {

    background: white;

    padding: 20px;

    border-radius: 12px;

    box-shadow: 0 4px 12px rgba(0,0,0,.12);

    display: flex;

    justify-content: center;

}

#board {

    display: grid;

    grid-template-columns: repeat(7, 60px);

    grid-template-rows: repeat(7, 60px);

    gap: 2px;

}


/*=========================================================
STATUS PANEL
=========================================================*/

.statusPanel {

    display: flex;

    flex-direction: column;

    gap: 20px;

}


/*=========================================================
AVAILABLE PIECES
=========================================================*/

 .piecesPanel {

    margin-top: 25px;

    text-align: center;

}



/*=========================================================
PIECE CARDS
=========================================================*/



.pieceCard:hover {

    background: #f2f8ff;

    transform: translateY(-2px);

}

.pieceCard.selected {

    border-color: #1565c0;

    background: #d9ecff;

    box-shadow: 0 4.piecepx 10px rgba(21,101,192,.25);

}

.pieceTitle {

    width: 100%;

    display: flex;

    justify-content: space-between;

    font-weight: bold;

}
Card .shape {

    white-space: pre;

    display: block;

    width: max-content;

    font-family: monospace;

    font-size: 22px;

    line-height: 1;

    text-align: left;

    margin: 5px auto;

}


/*=========================================================
CHOOSE LETTER
=========================================================*/

.lettersPanel {

    margin-top: 25px;

    text-align: center;

}

#letterContainer {

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

}

.letterButton {

    width: 52px;

    height: 52px;

    font-size: 24px;

    font-weight: bold;

    border: none;

    border-radius: 10px;

    background: #eceff1;

    cursor: pointer;

    transition: .2s;

}

.letterButton:hover {

    background: #bbdefb;

    transform: translateY(-2px);

}

.letterButton.selectedLetter {

    border: 3px solid #3498db;

    box-shadow: 0 0 8px rgba(52,152,219,.5);

    transform: translateY(-2px);

}


/*=========================================================
PANELS
=========================================================*/

.panel {

    background: white;

    border-radius: 12px;

    padding: 18px;

    box-shadow: 0 4px 12px rgba(0,0,0,.12);

}

.panel h2 {

    margin-bottom: 12px;

    color: #1565c0;

}

.panel p {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 10px;

    font-size: 15px;

}

.panel span {

    font-weight: bold;

    color: #1565c0;

}


/*=========================================================
DISABLED PIECES
=========================================================*/

.pieceCard.disabled {

    opacity: .35;

    cursor: not-allowed;

    border-color: #999;

}


/*=========================================================
SELECTED BOARD PIECE
=========================================================*/

.selectedPlacedPiece {

    outline: 3px solid orange;

    outline-offset: -3px;

}


/*=========================================================
RESPONSIVE LAYOUT
=========================================================*/

@media (max-width: 900px) {

    .gameWorkspace {

        grid-template-columns: 1fr;

    }
.leftInfoPanel,
    .statusPanel {

        width: 100%;

    }

}

@media (max-width: 600px) {

    #board {

        grid-template-columns: repeat(7, 42px);

        grid-template-rows: repeat(7, 42px);

    }

    .cell {

        width: 42px;

        height: 42px;

        font-size: 22px;

    }

    #toolbar button {

        min-width: 105px;

    }

}
/*=========================================================
FINAL PAGE FLOW
=========================================================*/

main {

    max-width: 1200px;

    margin: 25px auto;

    padding: 0 20px;

    display: flex;

    flex-direction: column;

    gap: 25px;

}
/*=========================================================
COMPACT GAME CONTROLS
=========================================================*/

 



#toolbar {

    gap: 8px;

}

#toolbar button {

    min-width: 105px;

    padding: 8px 12px;

    font-size: 14px;

}
/*=========================================================
AVAILABLE PIECES - HORIZONTAL TRAY
=========================================================*/

 .piecesPanel{

    text-align: center;

    padding: 15px 20px;

}
 .piecesPanel{

    width: fit-content;

    min-width: 0;

    margin: 0 auto;

    padding: 12px 18px;

}
.piecesPanel h2 {

    margin-bottom: 12px;

}



/*=========================================================
GAME CONTENT HORIZONTAL POSITION
=========================================================*/


.lettersPanel {

    position: relative;

    left: 246px;

}
/*=========================================================
COMPACT AVAILABLE PIECES PANEL
=========================================================*/

.piecesPanel {

    padding-top: 8px;
    padding-bottom: 8px;

}

.piecesPanel h2 {

    margin-top: 0;
    margin-bottom: 6px;

}

#pieceContainer {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}


.pieceCard .shape {

    white-space: pre;

    display: block;

    width: max-content;

    font-family: monospace;

    font-size: 10px;

    line-height: 1;

    text-align: left;

    margin: 5px auto;

}

.shape {

    white-space: pre;

    font-family: monospace;

    font-size: 22px;

    line-height: 1;

    display: block;

    width: fit-content;

    margin: 6px auto;

}
/*=========================================================
COMPACT AVAILABLE PIECES PANEL
=========================================================*/




/*=========================================================
AVAILABLE PIECES + CHOOSE LETTER - SIDE BY SIDE
=========================================================*/

.piecesPanel,
.lettersPanel {

    margin-top: 0;

    margin-bottom: 0;

}

/* Available Pieces */

.piecesPanel {

    grid-column: 1;

    grid-row: 1;

}

/* Choose Letter */

.lettersPanel {

    grid-column: 2;

    grid-row: 1;

    width: 200px;

}

/* The two panels need a shared grid.
   This uses the main content area below the board. */

main {

    display: grid;

    grid-template-columns: minmax(0, 1fr) 200px;

    column-gap: 15px;

    row-gap: 25px;

}

/* These sections span the complete page width */



.gameWorkspace {

    grid-column: 1 / -1;

    grid-row: 2;

}

.piecesPanel {

    grid-column: 1;

    grid-row: 3;

}

.lettersPanel {

    grid-column: 2;

    grid-row: 3;

}

/* Keep the letter buttons compact */

.lettersPanel #letterContainer {

    display: grid;

    grid-template-columns: repeat(2, 52px);

    justify-content: center;

    gap: 8px;

}
/*=========================================================
COMPACT AVAILABLE PIECES WIDTH
=========================================================*/

.piecesPanel {

    width: fit-content;

    justify-self: start;

}


/*=========================================================
HORIZONTAL CHOOSE LETTER
=========================================================*/

.lettersPanel {

    width: fit-content;

    justify-self: start;

}

.lettersPanel #letterContainer {

    display: flex;

    flex-direction: row;

    justify-content: center;

    align-items: center;

    gap: 8px;

    flex-wrap: nowrap;

}
/* Move Choose Letter closer to Available Pieces */

.lettersPanel {

    position: relative;

    left: -270px;

}
/*=========================================================
PUZZLE TARGET CELLS
=========================================================*/

.cell.targetCell {

    background: #fff3cd;

}
/*=========================================================
PUZZLE SELECTOR
=========================================================*/

.puzzleSelector {

    margin-bottom: 10px;

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 8px;

}

.puzzleSelector label {

    font-weight: bold;

}

#puzzleSelect {

    padding: 6px 10px;

    border: 1px solid #cfd8dc;

    border-radius: 6px;

    font-size: 14px;

    background: white;

}
#loadPuzzleButton {

    padding: 6px 12px;

    border: none;

    border-radius: 6px;

    background: #1565c0;

    color: white;

    font-weight: bold;

    cursor: pointer;

}

#loadPuzzleButton:hover {

    background: #0d47a1;

}
.learningFeature {
    display: none;
}
.rotation-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}




.rotation-controls button {
    display: inline-block;
    min-width: 52px;
    padding: 7px 12px;

    background-color: #eeeeee !important;
    color: #222222 !important;

    border: 2px solid #666666 !important;
    border-radius: 6px;

    font-weight: 700;
    opacity: 1 !important;
    visibility: visible !important;

    cursor: pointer;
}

.rotation-controls button:hover {
    background-color: #dbeafe !important;
    color: #222222 !important;
    border-color: #2563eb !important;
}

.rotation-controls button.rotation-active {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border-color: #2563eb !important;
}

.results-history {
    margin-top: 20px;
}

.result-history-item {
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    background: #f7f7f7;
}
.results-summary {
    margin-top: 20px;
    margin-bottom: 20px;
}

.result-summary-item {
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid #999;
    border-radius: 6px;
    background: #eeeeee;
}

.delete-result-button {
    display: block;
    margin-top: 8px;
    padding: 4px 10px;
    cursor: pointer;
}
.top-game-panels {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(200px, 1fr);
    gap: 16px;
    align-items: start;
}

 
.top-game-panels .piecesPanel {
    margin-top: 0;
}

.top-game-panels .lettersPanel {
    margin-top: 0;
}

.top-game-panels .controlsPanel {
    width: auto;
    margin-bottom: 0;
}

.top-game-panels .piecesPanel {
    width: auto;
    margin-bottom: 0;
}

.top-game-panels {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(20px, 0fr);
    gap: 16px;
    align-items: start;
}

.top-game-panels > .controlsPanel {
    width: auto;
    max-width: none;
    margin: 0;
    grid-column: 1;
}

.top-game-panels > .piecesPanel {
    width: auto;
    max-width: none;
    margin: 0;
    grid-column: 2;
}
.top-game-panels > .piecesPanel {
    margin-top: -220px;
}
.top-game-panels > .piecesPanel {
    padding: 8px 12px;
}
.top-game-panels > .piecesPanel h2 {
    margin-top: 0;
    margin-bottom: 8px;
}
/*.top-game-panels #pieceContainer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    align-items: flex-start;
}*/

.top-game-panels .pieceCard {
    display: inline-block;
    vertical-align: top;
    margin-right: 8px;
    margin-bottom: 8px;
    padding: 8px;
}

#toolbar .rotation-controls button {
    min-width: 52px;
    padding: 7px 12px;
}
.pieceTitle {
    font-size: 12px;
}

.pieceCount {
    font-size: 11px;
}
.saved-puzzle-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

/* =========================================================
   COGNIGRID SECTION BORDERS
   ========================================================= */

/* Main three-column game area */
.gameWorkspace {
    border: 2px solid #b0bec5;
    border-radius: 12px;
    padding: 16px;
}

/* Left-side information sections */
.leftInfoPanel > section {
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

/* Game Status */
.statusPanel > .panel {
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 12px;
}

/* Puzzle board area */
.boardPanel {
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 12px;
}
/* =========================================================
   TOP GAME AREA BORDER
   ========================================================= */
.top-game-panels > .controlsPanel {
    border: 2px solid #b0bec5;
    border-radius: 12px;
    padding: 12px;
}

.top-game-panels > .piecesPanel {
    border: 2px solid #b0bec5;
    border-radius: 12px;
    padding: 8px 10px;
}
@media (max-width: 900px) {

    .top-game-panels {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        width: 100%;
    }

    .top-game-panels > .controlsPanel {
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
        grid-column: 1;
    }

    .top-game-panels > .piecesPanel {
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
        grid-column: 1;
    }

    #pieceContainer {
        width: 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        gap: 6px;
    }
.controlsPanel > button,
.controlsPanel > select,
.controlsPanel > input {
    margin: 3px;
    vertical-align: middle;
}

#toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

.saved-puzzle-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 6px auto;
}



.gameWorkspace {
    display: flex;
    flex-direction: column;
}

.boardPanel {
    order: 1;
}

.statusPanel {
    order: 2;
}

.leftInfoPanel {
    order: 3;
}
}@media (max-width: 420px) {

    #pieceContainer {
        gap: 3px;
    }

    .pieceCard {
        padding: 4px;
        margin: 0;
    }

    .pieceTitle {
        font-size: 10px;
    }

    .pieceCount {
        font-size: 9px;
    }

    .pieceCard .shape {
        font-size: 9px;
    }

    #toolbar button {
        min-width: 0;
        width: auto;
        padding: 7px 8px;
        font-size: 13px;
    }

    #toolbar .rotation-controls button {
        min-width: 42px;
        padding: 6px 7px;
    }

    .rotation-controls {
        gap: 4px;
    }
}
/* Game Controls - structured desktop layout */

.controlsPanel .control-row {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px 0;
    flex-wrap: nowrap;
}

.controlsPanel .control-row button,
.controlsPanel .control-row select,
.controlsPanel .control-row input {
    margin: 0;
}

.controlsPanel #toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.controlsPanel .rotation-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}


/* Centre the main Game Controls rows */

.controlsPanel .puzzle-controls,
.controlsPanel .assist-controls,
.controlsPanel .random-id-controls {
    width: 100%;
    justify-content: center;
    margin-bottom: 12px;
}

.controlsPanel .saved-puzzle-controls {
    width: 100%;
    justify-content: center;
    margin-bottom: 12px;
}
/* Align all Game Control rows consistently */

.controlsPanel .control-row {
    display: flex !important;
    width: 100% !important;
    box-sizing: border-box;
    justify-content: center !important;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px 0 !important;
}

/* CogniGrid panel heading treatment */
.panel h2,
.panel h3,
.panel h4 {
    color: #1565c0;
    background-color: #eaf3fb;
    border-radius: 6px;
    padding: 6px 10px;
}

/* Subtle Game Status background */
.statusPanel > .panel {
    background-color: #f7fbff;
}

/* Subtle Available Pieces background */
.top-game-panels > .piecesPanel {
    background-color: #fffaf0;
}

/* Successful puzzle completion */
#status.status-success {
    color: #1b7f3a;
    background-color: #eaf7ee;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 4px;
}
/* Available Piece cards */
.piecesPanel .pieceCard {
    background-color: #fff4dc;
}
/* Brief visual cue when a puzzle is loaded */

#board.puzzle-loaded-highlight {
    animation: puzzleLoadedPulse 0.6s ease-in-out 4;
}

@keyframes puzzleLoadedPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(21, 101, 192, 0);
    }
 50% {
        box-shadow:
            0 0 0 6px rgba(21, 101, 192, 0.75),
            0 0 18px rgba(21, 101, 192, 0.55);
    }
}
/* Quick start guide */

.quick-guide {
    width: 100%;
    text-align: center;
    margin: 4px 0 12px 0;
}

.guide-step {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: bold;
}

.guide-step.active {
    background-color: #eaf3fb;
    border: 2px solid #1565c0;
    color: #1565c0;
}
/* Quick guide - highlight the next control */

#loadPuzzleButton.guide-highlight {
    outline: 3px solid #1565c0;
    outline-offset: 3px;
    box-shadow: 0 0 12px rgba(21, 101, 192, 0.55);
}

/* How to Play formatting */

#howToPlayContent {
    display: none;
    text-align: left;
    max-width: 760px;
    margin: 12px auto 0 auto;
    padding: 12px 16px;
    line-height: 1.5;
}

#howToPlayContent p {
    display: block;
    width: 100%;
    margin: 0 0 18px 0;
    padding: 0;
    text-align: left;
}

#howToPlayContent p strong:first-child {
    display: block;
    margin-bottom: 5px;
    font-size: 1.05em;
    color: #1565c0;
}

.how-to-heading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 14px;
}