/*
 * Copyright (c) 2024 Agoston Torok
 * All rights reserved. This software and its game logic are proprietary.
 * Any use, reproduction, or distribution of this software beyond the current testing setup
 * requires explicit license and approval from Agoston Torok.
 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    color: var(--text-color);
    font-size: 0.7em;
    line-height: 1.6;
    padding: 20px;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header and Stats */
header {
    font-family: var(--font-family);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    color: var(--text-color);
    margin-bottom: 1rem;
    background-color: var(--primary-color);
    border-radius: 10px;
}

.game-title {
    text-align: center;
    padding-right: 2rem;
    line-height: 1.2;
    min-width: 25%;
}

.game-title .main-title {
    color: var(--neutral-color);
    font-family: var(--game-font);
    font-size: 2em;
    letter-spacing: -1px;
}

.game-title .sub-title {
    color: var(--card-bg-color);
    font-family: monospace;
    font-size: 1.4em;
    letter-spacing: -1px;
    letter-spacing: 4px;
}

.game-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    min-width: 80px;
    text-transform: uppercase;
    letter-spacing: -1px;
}

.header-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-buttons a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--secondary-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    min-width: 80px;
    text-align: center;
    transition: all 0.3s ease;
}

.header-buttons a:hover {
    background-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rules-link,
.settings-link {
    /* These styles are now handled by .header-buttons a */
}

.stat-item label {
    color: var(--accent-color);
    font-size: 0.9em;
}

.stat-item span {
    font-weight: bold;
    font-size: 1.1em;
}

/* Header Buttons */
.header-buttons {
    display: flex;
    position: relative;
    gap: 10px;
    align-items: center;
}

.header-buttons button {
    font-family: var(--font-family);
    font-size: 0.7em;
    padding: 8px 16px;
    font-size: 14px;
    background: var(--secondary-color);
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.header-buttons button:hover {
    background-color: var(--accent-color);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    border-radius: 5px;
    padding: 5px;
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 1000;
    margin-top: 5px;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-menu button {
    white-space: nowrap;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-yellow);
    cursor: pointer;
    font-size: 1em;
}

.dropdown-menu button:hover {
    background-color: var(--text-yellow);
    color: var(--bg-color);
}

/* Main Game Board */
.game-board {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    height: calc(100vh - 200px);
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.left-section, .right-section {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.status-objectives, .main-objectives {
    display: flex;
    flex-direction: row;
    gap: 20px;
    flex-wrap: nowrap;
}

.center-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.objective {
    position: relative;
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding-bottom: 25px;
}

.objective h3 {
    font-size: 0.75em;
    text-align: center;
    line-height: 1.2;
    margin: 0;
    text-transform: uppercase;
}

.objective:hover {
    transform: scale(1.05);
}

.objective.selected {
    outline: 2px solid var(--accent-color);
    border-radius: 4px;
}

.objective.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-color);
    opacity: 0.1;
}

.objective-track {
    width: 30px;
    outline-color: var(--card-bg-color);
    outline-style: solid;
    outline-width: 2px;
    height: 170px;
    position: relative;
    margin: 10px;
    }

.bar-marker {
    position: absolute;
    bottom: 0;
    width: 100%;
    transition: height 0.3s ease, background-color 0.3s ease;
}

.bar-marker.neutral {
    background-color: var(--neutral-color); /* Golden Yellow */
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.3);
}

.bar-marker.positive {
    background-color: #2ecc71;
}

.bar-marker.warning {
    background-color: #e74c3c;
}

.objective-value {
    position: absolute;
    left: 50%;
    bottom: -25px;
    transform: translateX(-50%);
    font-size: 14px;
    color: var(--text-color);
}

.position {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    border: 2px solid var(--accent-color);
    transition: all 0.3s ease;
}

.position.warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.position.positive {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.position.current {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.position.completed {
    background-color: var(--success-color);
    border-color: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(46, 204, 113, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

.game-title {
    text-align: center;
}

.game-title .logo {
    height: auto;
    width: auto;
}

/* Objective Styles */
.objective {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
}

.left-section .objective {
    flex-direction: column;
}

.right-section .objective {
    flex-direction: column;
}

.objective h3 {
    margin: 0 10px;
    font-size: 0.9em;
    white-space: nowrap;
}



/* Card Hand Styles */
/* Fallback classes for browsers that don't support :has() */
.three-cards .card:hover:nth-of-type(1) {
  transform: translate(5rem, 1rem) scale(1.6);
  z-index: 4;
}

.three-cards .card:hover:nth-of-type(2) {
  transform: translate(0, 0rem) scale(1.6);
  z-index: 4;
}

.three-cards .card:hover:nth-of-type(3) {
  transform: translate(-5rem, 1rem) scale(1.6);
  z-index: 4;
}

.two-cards .card:hover:nth-of-type(1) {
  transform: translate(5rem, 1rem) scale(1.6);
  z-index: 4;
}

.two-cards .card:hover:nth-of-type(2) {
  transform: translate(-5rem, 1rem) scale(1.6);
  z-index: 4;
}

/* Original :has() selectors for browsers that support it */
#card-hand:has(.card:nth-of-type(3)) {  
    .card:hover:nth-of-type(1) {
      transform: translate(5rem, 1rem) scale(1.6);
      z-index: 4;
    }

    .card:hover:nth-of-type(2) {
      transform: translate(0, 0rem) scale(1.6);
      z-index: 4;
    }

    .card:hover:nth-of-type(3) {
      transform: translate(-5rem, 1rem) scale(1.6);
      z-index: 4;
    }
  }

#card-hand:has(.card:nth-of-type(2)):not(:has(.card:nth-of-type(3))) {

    .card:hover:nth-of-type(1) {
      transform: translate(5rem, 1rem) scale(1.6);
      z-index: 4;
    }

    .card:hover:nth-of-type(2) {
      transform: translate(-5rem, 1rem) scale(1.6);
      z-index: 4;
    } 
  }

.card-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: calc(var(--card-width) * 0.2);
    margin: 20px 0;
    position: relative;
}

.card-deck {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
}

.card-glow-effects,
#card-hand {
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--card-height);
    perspective: 1000px;
    width: calc(var(--card-width) * 2.5); /* Width for 3 cards plus gaps */
    position: relative;
}

.discard-pile {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
    border: 2px dashed var(--accent-color);
    font-size: 14px;
    box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.2);
}



#active-card {
    display: flex;
    justify-content: center;
    margin: 20px auto;
}

#active-card .card {
    width: 120px;
    height: 180px;
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.discard-placeholder {
    color: #999;
    text-align: center;
    padding: 10px;
}

.discard-pile .card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    transform-origin: center;
    transition: transform 0.3s ease;
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.discard-pile .card:not(:last-child) {
    transform: rotate(-3deg);
    background: white;
}

.discard-pile .card:last-child {
    transform: rotate(2deg);
    background: white;
}

.card-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: calc(var(--card-width) * 0.2); /* Make gap relative to card width */
    margin: 20px 0;
}

/* Dice Section */
.dice-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 20px 0;
    perspective: 1000px;
}

.die {
    width: 60px;
    height: 60px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transform: rotateX(-10deg) rotateY(5deg);
}

.dice-face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #F0EAD6;
    border: 2px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px;
    backface-visibility: visible;
}

/* Position faces */
.face-1 { transform: translateZ(30px); }
.face-2 { transform: rotateX(180deg) translateZ(30px); }
.face-4 { transform: rotateY(90deg) translateZ(30px); }
.face-3 { transform: rotateY(-90deg) translateZ(30px); }
.face-6 { transform: rotateX(90deg) translateZ(30px); }
.face-5 { transform: rotateX(-90deg) translateZ(30px); }

.dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: black;
    border-radius: 50%;
}

/* Dot positions */
.top { top: 10%; }
.bottom { bottom: 10%; }
.left { left: 10%; }
.right { right: 10%; }
.middle { top: 50%; transform: translateY(-50%); }
.center { left: 50%; transform: translateX(-50%); }
.middle.center { transform: translate(-50%, -50%); }

.die:hover {
    transform: scale(1.05) rotateX(-10deg) rotateY(5deg);
}

.die:active {
    transform: scale(0.95) rotateX(-10deg) rotateY(5deg);
}

@keyframes roll {
    0% { transform: rotateX(-10deg) rotateY(5deg); }
    20% { transform: rotateX(360deg) rotateY(180deg); }
    40% { transform: rotateX(720deg) rotateY(360deg); }
    60% { transform: rotateX(1080deg) rotateY(540deg); }
    80% { transform: rotateX(1440deg) rotateY(720deg); }
    100% { transform: rotateX(var(--final-x)) rotateY(var(--final-y)); }
}

.die[style*="animation"] {
    transform-style: preserve-3d;
}

/* Message */
.message {
    border: var(--pixel-border);
    background: var(--primary-color);
    box-shadow: var(--neon-glow);
    text-shadow: 0 0 5px var(--accent-color);
    text-align: center;
    margin-top: 20px;
    min-height: 1.5em;
    color: var(--accent-color);
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-controls button {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--background-color);
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    color: var(--text-color);
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

@media (max-width: 900px) {
    .modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 15px;
    }
}

/* Rules Modal Styles */
#rules-content {
    padding: 20px;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

#rules-content h1,
#rules-content h2,
#rules-content h3 {
    color: var(--accent-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

#rules-content h1:first-child {
    margin-top: 0;
}

#rules-content p {
    margin-bottom: 1em;
    line-height: 1.6;
}

#rules-content ul,
#rules-content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

#rules-content li {
    margin-bottom: 0.5em;
}

#rules-content code {
    background: var(--background-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: var(--font-family);
}

#rules-content pre {
    background: var(--background-color);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
}

#rules-content blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 0;
    padding-left: 1em;
    color: #888;
}

/* Rules Content Styles */
.rules-content {
    padding: 20px;
    line-height: 1.6;
}

.rules-content h1,
.rules-content h4,
.rules-content h5 {
    color: var(--accent-color);
    margin: 1.5em 0 0.5em;
}

.rules-content h1 {
    font-size: 2em;
    margin-top: 0;
}

.rules-content h4 {
    font-size: 1.4em;
}

.rules-content h5 {
    font-size: 1.2em;
}

.rules-content p {
    margin-bottom: 1em;
}

.rules-content hr {
    border: none;
    border-top: 1px solid var(--secondary-color);
    margin: 2em 0;
}

.rules-content ul,
.rules-content ol {
    margin: 0.5em 0 1em 2em;
}

.rules-content li {
    margin-bottom: 0.5em;
}

.rules-content strong {
    color: var(--accent-color);
}

.rules-content .faq-item {
    margin-bottom: 1.5em;
}

.rules-content .faq-item p {
    margin-bottom: 0.5em;
}

.rules-content .faq-item em {
    color: var(--text-color);
    opacity: 0.8;
}

/* Media queries for responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 15px;
    }
}

/* Settings Section Styles */
.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--secondary-color);
    border-radius: 8px;
}

.settings-section h3 {
    margin: 0 0 20px 0;
    color: var(--accent-color);
    font-size: 1.2em;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
}

.setting-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
}

.setting-group input:focus {
    outline: none;
    border-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

.button-group {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.primary-button,
.secondary-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.primary-button {
    background-color: var(--accent-color);
    color: var(--text-color);
}

.primary-button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.secondary-button {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.secondary-button:hover {
    background-color: #2c3e50;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#settings-reset {
    margin-right: auto; /* Push other buttons to the right */
}

/* Desktop Labels */
.mobile-label {
    display: none;
}

.desktop-label {
    word-wrap: break-word;
    white-space: pre-wrap;
    display: inline;
}
