* {
  box-sizing: border-box;
}

#dungeon {
  width: 100%;
  display: flex;
  justify-content: center;
}

#tutorial-modal {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  /* background-color: rgb(0, 0, 0); */
  background-color: rgba(0, 0, 0, 0.4);
}

#tutorial-modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
}

#tutorial-modal-actions {
  display: flex;
  justify-content: space-between;
}

#tutorial-modal.visible {
  display: block;
}

#message-modal {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  /* background-color: rgb(0, 0, 0); */
  background-color: rgba(0, 0, 0, 0.4);
}

#message-modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
}

#message-modal-actions {
  display: flex;
  justify-content: space-between;
}

#message-modal.visible {
  display: block;
}

.matrix {
  display: inline-grid;
  /* grid-template-rows: auto auto auto auto;
  grid-template-columns: auto auto auto auto; */
  grid-gap: 2px;
  margin: auto;
  /* width: 40px;
  height: 40px; */
  /* border: 1px solid black; */
  /* padding: 10px; */
}

#status-table {
  /* evenly spaced, all columns same width, faint border, clean */
  margin: auto;
  border-collapse: collapse;
  border-spacing: 0;
  border: 1px solid lightgray;
  width: 100%;
}

#status-table td {
  /* all columns same width */
  width: 20%;
  border: 1px solid lightgray;
  text-align: center;
  padding: 6px;
}

#status-table .card {
  /* all columns same width */
  margin: auto;
}

.cell {
  border: none;
  outline: 1px dotted lightgray;
  padding: 10px;
  background: #fff;
  width: 48px;
  height: 64px;
}

@keyframes pulsate-green-outline {
  0%   { outline-color: rgba(55, 205, 55, 1); }
  50%  { outline-color: rgba(55, 205, 55, 0.2); }
  100% { outline-color: rgba(55, 205, 55, 1); }
}

.cell.available {
  outline: 1px solid rgba(211, 211, 211, 0.4);
  animation: pulsate-green-outline 2s infinite;
}

.card {
  outline: 1px solid black;
  border: 4px solid lightgray;
  text-align: center;
  padding: 8px;
  font-weight: bold;
  font-family: system-ui;
  width: 48px;
  height: 64px;
}

.card.card-back {
  outline: 1px solid black;
  border: 4px solid white;
  color: white;

  /* diamond repeating pattern */
  background: repeating-linear-gradient(
    45deg,
    #606dbc,
    #606dbc 10px,
    #465298 10px,
    #465298 20px
  );
}

/* Rules Modal Styles */
.rules-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  overflow: hidden;
}

.rules-modal.visible {
  display: block;
}

.rules-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.rules-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.rules-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 28px;
  z-index: 10;
  transition: color 0.2s;
}

.rules-modal-close:hover,
.rules-modal-close:focus {
  color: #000;
}

.rules-modal-inner {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
}

.rules-modal-inner h2 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #333;
  border-bottom: 2px solid #465298;
  padding-bottom: 10px;
}

.rules-modal-inner h3 {
  color: #465298;
  margin-top: 20px;
  margin-bottom: 10px;
}

/* Tab Navigation */
.rules-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.rules-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.rules-tab:hover {
  color: #465298;
  background-color: #f5f5f5;
}

.rules-tab.active {
  color: #465298;
  border-bottom-color: #465298;
}

/* Tab Content */
.rules-section {
  display: none;
}

.rules-section.active {
  display: block;
}

.rules-section ul,
.rules-section ol {
  margin: 10px 0;
  padding-left: 25px;
}

.rules-section li {
  margin: 5px 0;
  line-height: 1.5;
}

/* Card Reference Styles */
.card-category {
  margin-bottom: 30px;
}

.card-category h3 {
  background-color: #f0f0f0;
  padding: 10px 15px;
  margin: 20px 0 15px 0;
  border-left: 4px solid #465298;
}

.card-list {
  display: grid;
  gap: 20px;
}

.card-item {
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 15px;
  background-color: #fafafa;
  transition: box-shadow 0.2s;
}

.card-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}

.card-item-name {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.card-item-suit {
  font-size: 14px;
  color: #666;
  font-family: monospace;
}

.card-item-description {
  line-height: 1.6;
  color: #444;
}

.card-item-description p {
  margin: 10px 0;
}

.card-item-description ul {
  margin: 10px 0;
  padding-left: 20px;
}

.card-item-description li {
  margin: 5px 0;
}

.card-item-description strong {
  color: #465298;
}

.card-item-description em {
  color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
  .rules-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .rules-modal-inner {
    padding: 20px 15px;
  }

  .rules-tab {
    padding: 8px 12px;
    font-size: 14px;
  }

  .card-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}

/* Open Rules Button */
#open-rules {
  margin-left: 10px;
  padding: 8px 16px;
  background-color: #465298;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s;
}

#open-rules:hover {
  background-color: #606dbc;
}

#open-rules:active {
  background-color: #3a4378;
}
