* {
  box-sizing: border-box;
}

body {
  background: linear-gradient(145deg, #3d3b2f 0%, #2a2820 100%); /* Wartime olive drab to dark khaki */
  font-family: 'Georgia', 'Times New Roman', serif;
  color: #1a1a1a; /* Dark military ink */
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Responsive, iPad-friendly Game Container --- */
#game-container {
  position: relative;
  width: 90vw;
  height: 90vw;
  max-width: 800px;
  max-height: 800px;
  background: #4a4736; /* Weathered military canvas */
  border: 8px solid #2d2b20; /* Dark aged canvas */
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(0,0,0,0.6);
  margin: 20px auto;
}
@media (max-width: 900px) {
  #game-container {
    width: 95vw;
    height: 95vw;
    max-width: 650px;
    max-height: 650px;
  }
}
@media (max-width: 700px) {
  #game-container {
    width: 99vw;
    height: 99vw;
    max-width: 99vw;
    max-height: 99vw;
    min-width: 0;
    min-height: 0;
  }
}

/* --- Decorative Corner Images: Scaled for all screens --- */
.corner-img {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 33vw;
  min-width: 60px;
  max-width: 150px;
  height: auto;
  opacity: 0.6; /* More muted for wartime effect */
  z-index: 0;
  pointer-events: none;
  filter: sepia(0.7) contrast(0.9); /* Stronger sepia with muted contrast */
}
.left-corner { left: 0; margin-left: 35px; }
.right-corner { right: 0; margin-right: 20px; }
@media (max-width: 900px) {
  .corner-img {
    width: 25vw;
    max-width: 220px;
    opacity: 0.55;
  }
}
@media (max-width: 600px) {
  .corner-img {
    width: 18vw;
    max-width: 90px;
    opacity: 0.5;
  }
}

/* --- Draggable styles --- */
.draggable {
  touch-action: none;
  cursor: grab;
  user-select: none;
  position: fixed !important;
}
.draggable.dragging {
  opacity: 0.85;
  z-index: 9999;
  cursor: grabbing;
}

/* --- Board --- */
#board {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 0;
}

.cell {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #e8dcc0, #d4c4a0); /* Aged military map paper */
  border: 2px solid #1a1a1a; /* Dark military ink border */
  border-radius: 8px;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.8rem;
  text-align: center;
  padding: 5px;
}
.cell:hover {
  transform: scale(1.05);
  box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
}
.cell.current {
  border: 3px solid #5a5a2d; /* Military olive highlight */
  box-shadow: 0 0 20px rgba(90, 90, 45, 0.7);
  transform: scale(1.1);
}
.cell.owned-p1 {
  background: linear-gradient(145deg, #b22222, #8b0000); /* Red tiles */
  border-color: #800000; /* Red border */
}
.cell.owned-p2 {
  background: linear-gradient(145deg, #483d8b, #2f2f6b); /* Blue tiles */
  border-color: #2a2a70; /* Blue border */
}
.cell.available {
  background: linear-gradient(145deg, #e8dcc0, #d4c4a0); /* Aged map paper */
  border-color: #1a1a1a; /* Military ink */
}
.ownership-crown {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 1.2rem;
  background: #e8dcc0; /* Aged paper */
  border-radius: 50%;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  z-index: 5;
}
.cell .date {
  font-weight: bold;
  font-size: 1rem;
  color: #000000; /* Black for better contrast on unowned tiles */
  margin-bottom: 3px;
}
.cell .event-icon {
  font-size: 1.8rem;
  margin: 3px 0;
}
.cell .title {
  font-size: 0.7rem;
  font-weight: bold;
  color: #000000; /* Black for better contrast on unowned tiles */
  text-align: center;
  line-height: 1.1;
  margin-top: 2px;
}
.cell .cell-num {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.7rem;
  color: #000000; /* Black for better contrast on unowned tiles */
  background: rgba(232,220,192,0.8); /* Faded aged paper */
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Ensure owned cells use light text for contrast */
.cell.owned-p1 .date,
.cell.owned-p1 .title,
.cell.owned-p2 .date,
.cell.owned-p2 .title {
  color: #e8dcc0; /* Light aged paper text for owned cells */
}

/* --- Board cells positioning (absolute for each cell) --- */
.cell:nth-child(1) { top: 5px; left: 5px; width: 130px; height: 145px; }
.cell:nth-child(2) { top: 0; left: 140px; width: 130px; height: 120px; }
.cell:nth-child(3) { top: 0; left: 270px; width: 130px; height: 120px; }
.cell:nth-child(4) { top: 0; left: 400px; width: 130px; height: 120px; }
.cell:nth-child(5) { top: 0; left: 525px; width: 130px; height: 120px; }
.cell:nth-child(6) { top: 0px; right: 0; width: 130px; height: 160px; }
.cell:nth-child(7) { top: 160px; right: 0; width: 130px; height: 120px; }
.cell:nth-child(8) { top: 280px; right: 0; width: 130px; height: 120px; }
.cell:nth-child(9) { top: 400px; right: 0; width: 130px; height: 120px; }
.cell:nth-child(10) { top: 520px; right: 0; width: 130px; height: 120px; }
.cell:nth-child(11) { bottom: 8px; right: 0; width: 130px; height: 135px; }
.cell:nth-child(12) { bottom: 8px; left: 525px; width: 130px; height: 120px; }
.cell:nth-child(13) { bottom: 8px; left: 395px; width: 130px; height: 120px; }
.cell:nth-child(14) { bottom: 8px; left: 265px; width: 130px; height: 120px; }
.cell:nth-child(15) { bottom: 8px; left: 135px; width: 130px; height: 120px; }
.cell:nth-child(16) { bottom: 8px; left: 5px; width: 130px; height: 135px; }
.cell:nth-child(17) { top: 520px; left: 5px; width: 130px; height: 120px; }
.cell:nth-child(18) { top: 400px; left: 5px; width: 130px; height: 120px; }
.cell:nth-child(19) { top: 280px; left: 5px; width: 130px; height: 120px; }
.cell:nth-child(20) { top: 160px; left: 5px; width: 130px; height: 120px; }

/* --- Central Area and Game Card --- */
#center-area {
  position: absolute;
  top: 140px; left: 140px; right: 140px; bottom: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #3d3b2f, #2a2820); /* Wartime olive drab */ 
  border-radius: 15px; padding: 20px;
}
#game-card {
  width: 340px; max-width: 98vw; height: auto; min-height: 330px;
  background: linear-gradient(145deg, #e8dcc0, #d4c4a0); /* Aged map paper */
  border: 3px solid #1a1a1a; /* Military ink */ border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
  display: none; flex-direction: column; overflow: hidden; position: relative;
}
#game-card.show { display: flex; animation: cardFlip 0.6s ease-in-out; }
@keyframes cardFlip { 0% { transform: rotateY(-90deg) scale(0.8); } 100% { transform: rotateY(0deg) scale(1); } }
.card-header { 
  background: linear-gradient(145deg, #654321, #4a2c17); /* Military brown */ 
  color: #e8dcc0; /* Aged paper text */ 
  padding: 15px; text-align: center; font-weight: bold; font-size: 1.1rem; 
}
.card-year { 
  background: #d4c4a0; /* Faded aged paper */ 
  color: #654321; /* Military brown ink */ 
  padding: 8px; text-align: center; font-weight: bold; font-size: 1.2rem; 
  border-bottom: 2px solid #a89570; /* Aged border */ 
}
.card-content { flex: 1; padding: 16px 16px 24px 16px; display: flex; flex-direction: column; justify-content: flex-start; }
.card-info {
  font-size: 1rem; color: #1a1a1a; /* Military ink */ text-align: center; margin: 0 0 14px 0; font-weight:bold;
  line-height: 1.3; word-break: break-word; white-space: normal; padding-bottom: 0.2em;
  max-width: 99%; overflow-wrap: break-word;
}
.quiz-section {
  margin: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; width: 100%;
}
.quiz-question {
  font-weight: normal; font-size:1.03rem;
  margin: 0 0 8px 0; color: #654321; /* Military brown ink */ text-align: left; line-height: 1.3;
  word-break: break-word; white-space: normal; padding-bottom: 0.1em;
}
.quiz-answers {
  width:100%; display: flex; flex-direction: column; gap: 9px; margin:0 0 5px 0;
}
.answer-btn {
  display: block; width: 100%; margin: 0; padding: 10px;
  background: linear-gradient(145deg, #5a5a2d, #3a3a1d); /* Military olive */ 
  color: #e8dcc0; /* Aged paper text */ border: none;
  border-radius: 8px; cursor: pointer; font-size: 0.96rem; transition: all 0.3s ease;
  text-align: left; white-space: normal; word-break: break-word;
}
.answer-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
.answer-btn.incorrect { background: linear-gradient(145deg, #8b0000, #6b0000); /* Red for incorrect */ }
.answer-btn .crossmark {
  color: #e8dcc0; /* Aged paper */
  font-size: 1.1em;
  float: right;
  margin-left: 8px;
}
.next-btn {
  background: linear-gradient(145deg, #5a5a2d, #3a3a1d); /* Military olive */ 
  color: #e8dcc0; /* Aged paper text */ border: none;
  padding: 12px 30px; border-radius: 8px; cursor: pointer; font-size: 1rem;
  font-weight: bold; margin-top: 10px; transition: all 0.3s ease;
}
.next-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }

/* --- Score Display (smaller version) --- */
#score-display {
  top: 20px; right: 20px;
  background: rgba(45, 43, 32, 0.9); /* Dark military canvas */ 
  color: #e8dcc0; /* Aged paper text */ padding: 10px 14px;
  border-radius: 10px; backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25); min-width: 110px; max-width: 160px;
  font-size: 0.95rem;
}
#score-display h3 {
  margin-bottom: 10px;
  text-align: center;
  color: #d4c4a0; /* Faded aged paper */
  font-size: 1rem;
}
.player-score {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 0; padding: 4px 2px; border-radius: 7px; transition: all 0.3s ease;
  font-size: 0.93rem;
}
.player-score.active { 
  background: rgba(232,220,192,0.1); /* Faded aged paper */ 
  border-left: 3px solid #5a5a2d; /* Military olive */ 
}
.player-score .name { font-weight: bold; }
.player-score .cards { 
  background: rgba(232,220,192,0.2); /* Faded aged paper */ 
  padding: 3px 7px; border-radius: 10px; font-size: 0.9rem; 
}

/* --- Controls (Dice, Buttons, Turn Display) as column with brown background --- */
#controls {
  bottom: 20px; left: 20px; right: auto; transform: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(74, 71, 54, 0.9); /* Military canvas */ 
  padding: 10px 16px; border-radius: 14px; backdrop-filter: blur(7px); z-index: 100;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
#dice { cursor: pointer; transition: transform 0.3s ease; }
#dice:hover { transform: scale(1.09); }
.die-face {
  width: 38px; height: 38px;
  background: linear-gradient(145deg, #e8dcc0, #d4c4a0); /* Aged paper */
  border: 2px solid #4a4736; /* Military canvas */
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-family: 'Georgia', 'Times New Roman', serif; font-weight: bold;
  box-shadow: 0 2px 7px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.47,1.64,0.41,0.8);
  color: #654321; /* Military brown ink */
  user-select: none;
}
.die-face.rolling {
  transform: rotate(360deg) scale(1.12);
  animation: rollAnimation 0.8s ease-in-out;
}
@keyframes rollAnimation {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.04); }
  50% { transform: rotate(180deg) scale(1.09); }
  75% { transform: rotate(270deg) scale(1.04); }
}
#rollBtn {
  background: linear-gradient(145deg, #5a5a2d, #3a3a1d); /* Military olive */ 
  color: #e8dcc0; /* Aged paper text */
  border: none;
  padding: 7px 18px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.97rem;
  font-weight: bold;
  transition: all 0.3s ease;
  margin-top: 6px;
}
#rollBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(90,90,45,0.25); /* Military olive shadow */
}
#rollBtn:disabled {
  background: #4a4736; /* Military canvas */
  cursor: not-allowed;
  opacity: 0.6;
}
#playerTurn {
  color: #e8dcc0; /* Aged paper text */
  font-size: 1rem;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
  margin-top: 8px;
  text-align: center;
  width: 100%;
}

.token {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid #d4c4a0; /* Faded aged paper */
  position: absolute; top: 5px; left: 5px; font-size: 1rem; font-weight: bold;
  color: #d4c4a0; /* Aged paper text */ display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5); z-index: 10; transition: all 0.3s ease;
}
.token.p1 { background: #8b0000; /* Red token */ }
.token.p2 { background: #2f2f6b; /* Blue token */ left: 35px; }

/* --- Welcome and Modals --- */
#welcome-message { text-align: center; color: #d4c4a0; /* Faded aged paper */ font-size: 1.1rem; margin-top: 20px; }
#victory-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center; z-index: 1000;
}
.victory-content {
  background: linear-gradient(145deg, #e8dcc0, #d4c4a0); /* Aged paper */ 
  padding: 40px; border-radius: 20px;
  text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.6); max-width: 400px;
}
.victory-content h2 { color: #654321; /* Military brown ink */ font-size: 2.5rem; margin-bottom: 20px; }
.victory-content .winner-name { font-size: 2rem; font-weight: bold; margin: 20px 0; }
.victory-content .cards-collected { font-size: 1.2rem; color: #1a1a1a; /* Military ink */ margin-bottom: 30px; }
.play-again-btn {
  background: linear-gradient(145deg, #5a5a2d, #3a3a1d); /* Military olive */ 
  color: #e8dcc0; /* Aged paper text */
  border: none; padding: 15px 30px; border-radius: 12px; cursor: pointer;
  font-size: 1.1rem; font-weight: bold; transition: all 0.3s ease;
}
.play-again-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(90,90,45,0.4); /* Military olive shadow */ }

/* --- Intro Modal --- */
#intro-modal {
  position: fixed; z-index: 2000; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(42,40,32,0.95); /* Dark wartime khaki */ 
  display: flex; align-items: center; justify-content: center; 
  color: #d4c4a0; /* Faded aged paper */
}
.intro-content {
  background: linear-gradient(145deg, #4a4736, #2d2b20); /* Military canvas */ 
  border-radius: 20px; max-width: 450px; box-shadow: 0 8px 35px rgba(0,0,0,0.7);
  padding: 38px 38px 28px 38px; text-align: center;
}
.intro-content h2 { color: #d4c4a0; /* Faded aged paper */ font-size: 2.2rem; margin-bottom: 14px; }
.intro-content p { margin-bottom: 14px; font-size: 1.08rem; }
.intro-content ul { text-align: left; margin-bottom: 16px; padding-left: 1.1em; }
.intro-content ul li { margin-bottom: 7px; font-size: 1rem; }
.start-btn {
  background: linear-gradient(145deg, #5a5a2d, #3a3a1d); /* Military olive */ 
  color: #e8dcc0; /* Aged paper text */ border: none; padding: 15px 40px;
  border-radius: 12px; cursor: pointer; font-size: 1.1rem; font-weight: bold; letter-spacing: 2px;
  transition: all 0.25s;
}
.start-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 5px 18px rgba(90,90,45,0.3); /* Military olive shadow */
  background: linear-gradient(145deg, #3a3a1d, #5a5a2d); /* Reversed for hover */
}

/* --- Volume Control Slider --- */
#volume-control {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: rgba(45, 43, 32, 0.9); /* Dark military canvas */
  padding: 10px 15px;
  border-radius: 15px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e8dcc0; /* Aged paper text */
  font-size: 0.9rem;
}
#volume-control input[type="range"] {
  width: 100px;
}

#board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2vw;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.side-img {
  width: 40vw;
  max-width: 160px;
  height: auto;
  opacity: 0.7;
  filter: sepia(0.6) contrast(0.9);
  border-radius: 12px;
}