/* --------------------------------------------------------------------------
   Towers  -  www.transum.org
   Styles for the puzzle only. The page furniture (tabs, trophy button,
   containers) is styled by Quiz_2026.css.
   -------------------------------------------------------------------------- */

#TOWWrap {
    font-family: Arial, Helvetica, sans-serif;
    padding: 0 12px 12px;
    box-sizing: border-box;
    max-width: 100%;
}

/* ---------- the row of buttons ---------- */

#TOWControls {
    text-align: center;
    margin: 10px auto 12px;
    line-height: 2.2;
}

#TOWControls button {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    padding: 5px 12px;
    margin: 2px 3px;
    border: 1px solid #999;
    border-radius: 6px;
    background: linear-gradient(to bottom, #ffffff, #e4e4e4);
    color: #222;
    cursor: pointer;
    vertical-align: middle;
}

#TOWControls button:hover:enabled {
    background: linear-gradient(to bottom, #ffffff, #d0e8ff);
    border-color: #4682b4;
}

#TOWControls button:active:enabled { transform: translateY(1px); }

#TOWControls button:disabled {
    color: #aaa;
    background: #f2f2f2;
    cursor: default;
}

#TOWControls #Checkbutton {
    font-weight: bold;
    background: linear-gradient(to bottom, #ffffff, #cfe9cf);
    border-color: #4a7d4a;
}

/* ---------- grid on the left, towers on the right ---------- */

#TOWPanels {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 14px;
}

#TOWLeft {
    flex: 1 1 380px;
    min-width: 300px;
    max-width: 430px;
}

#TOWRight {
    flex: 1 1 360px;
    min-width: 300px;
    max-width: 400px;
}

#TOWBoard { width: 100%; text-align: center; }

/* ---------- the grid ---------- */

#TOWGrid {
    margin: 0 auto;
    border-collapse: collapse;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#TOWGrid td {
    padding: 0;
    text-align: center;
    vertical-align: middle;
    box-sizing: border-box;
}

#TOWGrid td.tow-cell {
    border: 1px solid #8d99a6;
    background-color: #fbfcfe;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.12s ease;
}

#TOWGrid td.tow-cell:hover { outline: 2px solid #4682b4; outline-offset: -2px; }

#TOWGrid td.tow-filled .tow-num {
    color: #fff;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* squares the puzzle gave you, which cannot be changed */
#TOWGrid td.tow-given {
    cursor: default;
    box-shadow: inset 0 0 0 3px #2b2b2b;
}
#TOWGrid td.tow-given:hover { outline: none; }

#TOWGrid td.tow-selected { outline: 3px solid #111; outline-offset: -3px; }

/* the line you are currently looking along in the picture */
#TOWGrid td.tow-inline { box-shadow: inset 0 0 0 2px #ffd43b; }

#TOWGrid td.tow-error {
    background-image: repeating-linear-gradient(45deg,
        rgba(204, 0, 0, 0.55) 0, rgba(204, 0, 0, 0.55) 6px,
        rgba(255, 255, 255, 0.25) 6px, rgba(255, 255, 255, 0.25) 12px);
}

#TOWGrid .tow-num { display: block; line-height: 1; pointer-events: none; }

/* the clue numbers round the edge */

#TOWGrid td.tow-clue {
    border: 0;
    font-weight: bold;
    color: #333;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
}

#TOWGrid td.tow-clue:hover { background: #e7f0fa; }
#TOWGrid td.tow-clue-none { cursor: default; }
#TOWGrid td.tow-clue-none:hover { background: transparent; }
#TOWGrid td.tow-clue-done { color: #9aa5b1; }
#TOWGrid td.tow-clue-bad { color: #cc0000; }
#TOWGrid td.tow-clue-active {
    background: #ffd43b;
    color: #222;
    box-shadow: 0 0 0 2px #e6b800;
}

#TOWGrid td.tow-corner { border: 0; background: transparent; }

#TOWGrid.tow-won td.tow-cell { animation: tow-pop 0.7s ease; }

@keyframes tow-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ---------- the three-dimensional view ---------- */

#TOW3D {
    width: 100%;
    height: 340px;
    border: 1px solid #b6c2ce;
    border-radius: 8px;
    background: #eaf2fb;
    overflow: hidden;
    touch-action: none;         /* dragging here turns the towers */
    cursor: grab;
}

#TOW3D:active { cursor: grabbing; }

#TOW3D canvas { display: block; }

#TOWViewButtons { text-align: center; margin: 8px 0 4px; }

#TOWViewButtons button {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    padding: 4px 12px;
    margin: 0 3px;
    border: 1px solid #999;
    border-radius: 6px;
    background: linear-gradient(to bottom, #ffffff, #e4e4e4);
    cursor: pointer;
}

#TOWCaption {
    font-size: 15px;
    color: #333;
    text-align: center;
    margin: 6px auto 0;
    min-height: 3em;
    line-height: 1.4;
}

/* ---------- the key to the colours ---------- */

#TOWKey {
    text-align: center;
    margin: 10px auto 0;
    font-size: 14px;
    color: #444;
}

#TOWKey span.tow-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    margin: 2px 3px;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    vertical-align: middle;
}

/* ---------- the message under the puzzle ---------- */

#TOWMessage {
    min-height: 1.6em;
    margin: 14px auto 4px;
    text-align: center;
    font-size: 17px;
    color: #333;
    max-width: 640px;
}

#TOWMessage .tow-red, #TOWCaption .tow-red { color: #cc0000; font-weight: bold; }

p.TOWReminder {
    text-align: center;
    font-size: 16px;
    margin: 6px auto 0;
    color: #444;
    max-width: 660px;
}

/* ---------- how to play ---------- */

.TOWInstructions {
    max-width: 700px;
    margin: 20px auto;
    text-align: left;
    font-size: 16px;
    line-height: 1.5;
}

.TOWInstructions h3 { font-size: 19px; margin-bottom: 6px; }
.TOWInstructions ul { margin: 8px 0 8px 20px; }
.TOWInstructions li { margin-bottom: 6px; }

#TOWSolve {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    padding: 6px 16px;
    border: 1px solid #4a7d4a;
    border-radius: 6px;
    background: linear-gradient(to bottom, #ffffff, #cfe9cf);
    cursor: pointer;
}

/* ---------- smaller screens ---------- */

@media screen and (max-width: 760px) {
    #TOWLeft, #TOWRight { max-width: 100%; flex-basis: 100%; }
    #TOW3D { height: 300px; }
    #TOWControls button { font-size: 14px; padding: 4px 9px; }
    .TOWInstructions { padding: 0 10px; }
}

@media print {
    #TOWControls, #TOWMessage, #TOWViewButtons, #TOW3D, #TOWCaption { display: none; }
}
