body {
  font-family: "Segoe UI", sans-serif;
  background: #fafafa;
  margin: 20px;
}

h1 {
  margin-bottom: 15px;
}

.core-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

fieldset {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
}

.card-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.card-group label {
  flex: 0 0 auto;
  text-align: center;
  padding: 6px 16px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}

.card-group input {
  display: none;
}

.rarity-options label {
  flex: 1 1 auto !important;
}

.rarity-없음   { background: gray;       color: #fff; }
.rarity-영웅   { background: purple;     color: #fff; }
.rarity-전설   { background: goldenrod;  color: #fff; }
.rarity-유물   { background: darkorange; color: #fff; }
.rarity-고대   { background: khaki;      color: #333; }

.card-group input:checked + label,
.card-group label:has(input:checked) {
  border-color: #333;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
  transform: scale(1.05);
}

.point-card {
  background: #f8f8f8;
  color: #333;
}

.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
}

.modal-content {
  background: #fff;
  margin: 2% auto;
  border-radius: 10px;
  width: 90%;
  max-width: 1000px;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.modal-content::-webkit-scrollbar {
  display: none;
}

.modal-header {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.modal-header h2 {
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  color: #333;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #000;
}

.modal-body {
  padding: 1rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.gem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.card textarea {
  width: 100%;
  height: 80px;
  box-sizing: border-box;
  resize: none;
  padding: 0.5rem;
  font-family: monospace;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.hint {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.hint strong {
  color: #222;
}

.hint code {
  background: #f0f0f0;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: monospace;
}

.calc-btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background: #4CAF50;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.calc-btn:hover {
  background: #45a049;
}

.calc-btn:disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
}

.result-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1em;
}

.result-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.core-card {
  border: 2px solid #ccc;
  border-radius: 10px;
  padding: 0.75rem;
  background: #fff;
}

.core-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.core-name {
  font-size: 1.1rem;
}

.core-thresholds {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.threshold {
  margin: 0 0.25rem;
  font-weight: bold;
}

.threshold.active {
  color: inherit;
}

.threshold.inactive {
  color: #bbb;
}

.rarity-영웅 .core-name,
.rarity-영웅 .threshold.active,
.rarity-영웅 .core-max { color: purple; }

.rarity-전설 .core-name,
.rarity-전설 .threshold.active,
.rarity-전설 .core-max { color: goldenrod; }

.rarity-유물 .core-name,
.rarity-유물 .threshold.active,
.rarity-유물 .core-max { color: darkorange; }

.rarity-고대 .core-name,
.rarity-고대 .threshold.active,
.rarity-고대 .core-max { color: khaki; }

.rarity-없음 .core-name,
.rarity-없음 .threshold.active,
.rarity-없음 .core-max { color: gray; }

.core-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gem-card {
  flex: 1 1 calc(50% - 0.5rem);
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  background: #f9f9f9;
  color: #222;
}

@media (max-width: 768px) {
  .result-cards {
    grid-template-columns: 1fr;
  }

  .core-grid {
    grid-template-columns: 1fr;
  }
}
