@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    font-family: 'Press Start 2P', monospace;
    background-color: #0a0a0a;
    color: #d0d0d0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Portal --- */

#portal {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.scanlines {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    z-index: 100;
}

.portal-header {
    text-align: center;
    margin-bottom: 3rem;
}

.portal-header h1 {
    font-size: 2rem;
    color: #00ff41;
    text-shadow: 0 0 20px rgba(0, 255, 65, 0.5), 0 0 40px rgba(0, 255, 65, 0.2);
    margin-bottom: 1rem;
    letter-spacing: 4px;
}

.subtitle {
    font-size: 0.6rem;
    color: #666;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* --- Game Cards --- */

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 380px));
    gap: 2rem;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
}

.game-card {
    position: relative;
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border: 1px solid #333;
    border-radius: 4px;
    padding: 2rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.game-card:hover {
    border-color: #00ff41;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.1), inset 0 0 20px rgba(0, 255, 65, 0.03);
}

.card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.5rem;
    color: #555;
    border: 1px solid #333;
    padding: 4px 8px;
    border-radius: 2px;
}

.game-card h2 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 1rem;
}

.card-desc {
    font-size: 0.55rem;
    line-height: 1.8;
    color: #888;
    margin-bottom: 1.5rem;
}

.card-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-play {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 12px 24px;
    background: #00ff41;
    color: #000;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-play:hover {
    background: #33ff66;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.btn-help {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #00ff41;
    text-decoration: none;
    padding: 12px 16px;
    border: 1px solid #00ff41;
    border-radius: 2px;
    transition: background 0.2s;
    letter-spacing: 1px;
}

.btn-help:hover {
    background: rgba(0, 255, 65, 0.1);
}

/* --- Footer --- */

.portal-footer {
    margin-top: 3rem;
    text-align: center;
}

.portal-footer p {
    font-size: 0.45rem;
    color: #444;
    letter-spacing: 1px;
}

/* --- Game container --- */

#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    background: #000;
}

#game-container canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- Help page --- */

.help-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

.help-page h1 {
    font-size: 1.5rem;
    color: #00ff41;
    text-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
    margin-bottom: 2rem;
    text-align: center;
}

.help-page h2 {
    font-size: 1rem;
    color: #fff;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #333;
}

.help-page p,
.help-page li {
    font-size: 0.75rem;
    line-height: 2;
    color: #aaa;
}

.help-page ul {
    list-style: none;
    padding-left: 1rem;
}

.help-page ul li::before {
    content: '>';
    color: #00ff41;
    margin-right: 0.75rem;
}

.help-page .back-link {
    display: inline-block;
    margin-bottom: 2rem;
    font-size: 0.7rem;
    color: #00ff41;
    text-decoration: none;
    letter-spacing: 1px;
}

.help-page .back-link:hover {
    text-decoration: underline;
}

.key-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.key-table th,
.key-table td {
    font-size: 0.7rem;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #222;
}

.key-table th {
    color: #00ff41;
    font-weight: normal;
}

.key-table td {
    color: #aaa;
}

kbd {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    background: #222;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 3px 8px;
    color: #fff;
}

.tile-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.tile-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tile-swatch {
    width: 24px;
    height: 24px;
    border: 1px solid #555;
    border-radius: 2px;
    flex-shrink: 0;
}

.tile-item span {
    font-size: 0.7rem;
    color: #aaa;
}

.tip-box {
    background: #1a1a2e;
    border-left: 3px solid #00ff41;
    padding: 1rem 1.2rem;
    margin: 1rem 0;
}

.tip-box p {
    font-size: 0.7rem;
    line-height: 2;
    color: #aaa;
}

.tip-box strong {
    color: #00ff41;
}

/* --- Key binding configuration --- */

.keybind-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem 1rem;
    align-items: center;
    margin: 1rem 0;
}

.keybind-grid .action-label {
    font-size: 0.7rem;
    color: #aaa;
}

.keybind-grid .bind-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.keybind-grid .bind-key {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    background: #222;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 6px 10px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.keybind-grid .bind-key .remove-key {
    color: #ff4444;
    cursor: pointer;
    font-size: 0.5rem;
    margin-left: 0.25rem;
}

.keybind-grid .bind-key .remove-key:hover {
    color: #ff8888;
}

.keybind-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #00ff41;
    color: #00ff41;
    border-radius: 2px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.keybind-btn:hover {
    background: rgba(0, 255, 65, 0.1);
}

.keybind-btn.listening {
    border-color: #FFD700;
    color: #FFD700;
    animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: #FFD700; }
    50% { border-color: #ff8800; }
}

.keybind-reset {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #555;
    color: #888;
    border-radius: 2px;
    cursor: pointer;
    margin-top: 1rem;
    transition: border-color 0.2s, color 0.2s;
}

.keybind-reset:hover {
    border-color: #ff4444;
    color: #ff4444;
}
