:root {
    --safe-color: #2ecc71;
    --danger-color: #e74c3c;
    --neutral-tile-color: #7f8c8d;
    --prob-text-color: #ffffff;
    --hint-bg: #f39c12;
}

body.protanopia {
    --safe-color: #3498db;   /* Blue */
    --danger-color: #e67e22; /* Orange */
}

body.deuteranopia {
    --safe-color: #3498db;   /* Blue */
    --danger-color: #e67e22; /* Orange */
}

body.tritanopia {
    --safe-color: #3498db;   /* Cyan-ish blue */
    --danger-color: #c0392b; /* Dark Red */
}

body.high-contrast {
    --safe-color: #ffffff;
    --danger-color: #000000;
    --prob-text-color: #ffff00;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #2c3e50;
    color: #ecf0f1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.container {
    text-align: center;
    background-color: #34495e;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

h1 {
    margin-bottom: 0.5rem;
}

.subtitle {
    margin-bottom: 1.5rem;
    font-style: italic;
    opacity: 0.8;
    font-size: 0.9rem;
}

.game-container {
    display: inline-block;
    position: relative;
    margin-bottom: 1.5rem;
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 10px;
    width: 410px; /* (6*60) + (5*10) = 410 */
    height: 410px;
    margin: 0 auto;
    box-sizing: border-box;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
    gap: 10px;
    grid-column: 1 / 6;
    grid-row: 1 / 6;
}

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.mode-selector button {
    background-color: #5d6d7e;
    opacity: 0.7;
}

.mode-selector button.active {
    background-color: #2ecc71;
    opacity: 1;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.controls {
    margin-top: 1rem;
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

#play-controls, #solve-controls {
    display: flex;
    gap: 15px;
}

#mark-btn.active {
    background-color: #f1c40f;
    color: #2c3e50;
}

.tile .memos {
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    font-size: 0.6rem;
    line-height: 1;
}

.tile .memo {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.1s;
}

.tile .memo.active {
    opacity: 1;
    color: #f1c40f;
}

body.play-mode.mark-mode-active .tile:not(.flipped) .memo:hover {
    opacity: 0.5;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.tile.flipped .memos {
    display: none;
}

.tile {
    width: 60px;
    height: 60px;
    background-color: var(--neutral-tile-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    transition: background-color 0.2s;
    position: relative;
}

.tile:hover {
    background-color: #95a5a6;
}

.tile.flipped {
    background-color: #ecf0f1;
    color: #2c3e50;
    cursor: default;
}

.tile.voltorb {
    background-color: var(--danger-color);
    color: white;
}

.tile .prob {
    font-size: 0.8rem;
    position: absolute;
    bottom: 2px;
    right: 2px;
    color: var(--prob-text-color);
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
    font-weight: bold;
}

.tile.safe {
    background-color: var(--safe-color);
}

.tile.danger {
    background-color: var(--danger-color);
}

.row-hints {
    grid-column: 6;
    grid-row: 1 / 6;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.col-hints {
    grid-column: 1 / 6;
    grid-row: 6;
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.hint-box {
    width: 60px;
    height: 60px;
    background-color: var(--hint-bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 5px;
    box-sizing: border-box;
}

.row-hints .hint-box {
    width: 60px;
    height: 60px;
}

.col-hints .hint-box {
    width: 60px;
    height: 60px;
}

input[type="number"] {
    width: 35px;
    height: 25px;
    border: none;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
    background-color: white;
    color: black;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"][readonly] {
    background-color: transparent;
    color: white;
    cursor: default;
    font-weight: bold;
    font-size: 1.1rem;
    outline: none;
}

.controls {
    margin-top: 1rem;
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.controls-item {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #5d6d7e;
    padding: 0 15px;
    border-radius: 5px;
    height: 40px;
    box-sizing: border-box;
}

#color-scheme {
    padding: 5px 25px 5px 10px;
    border-radius: 5px;
    background-color: #ecf0f1;
    color: #2c3e50;
    border: none;
    font-weight: bold;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%232c3e50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    font-family: inherit;
}

button {
    padding: 0 20px;
    height: 40px;
    border: none;
    border-radius: 5px;
    background-color: #2ecc71;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    background-color: #27ae60;
}

#reset-btn {
    background-color: #e67e22;
}

#reset-btn:hover {
    background-color: #d35400;
}

#new-game-btn {
    background-color: #3498db;
}

#new-game-btn:hover {
    background-color: #2980b9;
}

#status-message {
    margin-top: 1rem;
    font-weight: bold;
    min-height: 1.2em;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 5px;
}

#status-message.error {
    background-color: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 2px solid #e74c3c;
    animation: shake 0.5s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.explanation {
    margin-top: 1.5rem;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.explanation p {
    margin: 8px 0;
}

.explanation p:first-child {
    margin-top: 0;
}

.explanation p:last-child {
    margin-bottom: 0;
}
