/* === Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === Body === */
body {
  background: #0a0a1a;
  color: #ffffff;
  font-family: 'Courier New', monospace;
  min-height: 100vh;
  overflow: hidden;
}

/* === Screen management === */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* === Title screen === */
#screen-title {
  gap: 1.5rem;
  text-align: center;
}

#screen-title h1 {
  font-size: 3.5rem;
  color: #00e5ff;
  text-shadow:
    0 0 10px rgba(0, 229, 255, 0.8),
    0 0 30px rgba(0, 229, 255, 0.5),
    0 0 60px rgba(0, 229, 255, 0.3);
  letter-spacing: 0.15em;
}

.subtitle {
  color: #8899aa;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

#btn-start {
  margin-top: 1rem;
  padding: 0.8rem 2.5rem;
  font-size: 1.2rem;
  font-family: 'Courier New', monospace;
  color: #00e5ff;
  background: transparent;
  border: 2px solid #00e5ff;
  border-image: linear-gradient(135deg, #00e5ff, #6a5acd) 1;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#btn-start:hover,
#btn-continue:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow:
    0 0 15px rgba(0, 229, 255, 0.5),
    0 0 30px rgba(0, 229, 255, 0.3),
    inset 0 0 15px rgba(0, 229, 255, 0.1);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

#btn-continue {
  padding: 0.8rem 2.5rem;
  font-size: 1.2rem;
  font-family: 'Courier New', monospace;
  color: #7cff7c;
  background: transparent;
  border: 2px solid #7cff7c;
  border-image: linear-gradient(135deg, #7cff7c, #00e5ff) 1;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#btn-continue:hover {
  background: rgba(124, 255, 124, 0.1);
  box-shadow:
    0 0 15px rgba(124, 255, 124, 0.5),
    0 0 30px rgba(124, 255, 124, 0.3),
    inset 0 0 15px rgba(124, 255, 124, 0.1);
  text-shadow: 0 0 10px rgba(124, 255, 124, 0.8);
}

#btn-next-year:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.version {
  position: fixed;
  bottom: 1.5rem;
  color: #445566;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

/* === Starfield background === */
body::before,
body::after,
#screen-title::before,
#screen-title::after {
  content: '';
  position: fixed;
  width: 3px;
  height: 3px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.6;
  pointer-events: none;
}

body::before {
  top: 15%;
  left: 20%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  animation: star-drift-1 12s linear infinite;
}

body::after {
  top: 70%;
  left: 80%;
  width: 2px;
  height: 2px;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);
  animation: star-drift-2 18s linear infinite;
}

#screen-title::before {
  top: 40%;
  left: 60%;
  width: 2px;
  height: 2px;
  opacity: 0.4;
  box-shadow: 0 0 3px rgba(0, 229, 255, 0.3);
  animation: star-drift-3 15s linear infinite;
}

#screen-title::after {
  top: 25%;
  left: 75%;
  width: 2px;
  height: 2px;
  opacity: 0.5;
  box-shadow: 0 0 4px rgba(106, 90, 205, 0.4);
  animation: star-drift-4 20s linear infinite;
}

@keyframes star-drift-1 {
  0%   { transform: translate(0, 0); opacity: 0.6; }
  25%  { opacity: 0.3; }
  50%  { transform: translate(60px, 40px); opacity: 0.7; }
  75%  { opacity: 0.4; }
  100% { transform: translate(0, 0); opacity: 0.6; }
}

@keyframes star-drift-2 {
  0%   { transform: translate(0, 0); opacity: 0.5; }
  33%  { transform: translate(-40px, -30px); opacity: 0.3; }
  66%  { transform: translate(-80px, 20px); opacity: 0.6; }
  100% { transform: translate(0, 0); opacity: 0.5; }
}

@keyframes star-drift-3 {
  0%   { transform: translate(0, 0); opacity: 0.4; }
  50%  { transform: translate(-50px, 60px); opacity: 0.7; }
  100% { transform: translate(0, 0); opacity: 0.4; }
}

@keyframes star-drift-4 {
  0%   { transform: translate(0, 0); opacity: 0.5; }
  33%  { transform: translate(30px, -50px); opacity: 0.3; }
  66%  { transform: translate(-20px, -30px); opacity: 0.6; }
  100% { transform: translate(0, 0); opacity: 0.5; }
}

/* === Announcement screen === */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.announcement-box {
  max-width: 600px;
  width: 90%;
  background: rgba(10, 10, 40, 0.9);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fade-in 0.6s ease-out;
}

.announcement-box h2 {
  font-size: 1.6rem;
  color: #00e5ff;
  text-align: center;
  text-shadow:
    0 0 10px rgba(0, 229, 255, 0.6),
    0 0 30px rgba(0, 229, 255, 0.3);
}

.announcement-content {
  text-align: left;
  line-height: 1.8;
  padding: 0 1rem;
  max-height: 50vh;
  overflow-y: auto;
  color: #ccddee;
  font-size: 0.95rem;
}

.announcement-content p {
  margin-bottom: 0.8em;
}

.announcement-content::-webkit-scrollbar {
  width: 6px;
}

.announcement-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.announcement-content::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.3);
  border-radius: 3px;
}

#btn-enter {
  padding: 0.8rem 2.5rem;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  color: #00e5ff;
  background: transparent;
  border: 2px solid #00e5ff;
  border-image: linear-gradient(135deg, #00e5ff, #6a5acd) 1;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
}

#btn-enter:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow:
    0 0 15px rgba(0, 229, 255, 0.5),
    0 0 30px rgba(0, 229, 255, 0.3),
    inset 0 0 15px rgba(0, 229, 255, 0.1);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

/* === Create screen === */
.create-box {
  max-width: 600px;
  width: 90%;
  background: rgba(10, 10, 40, 0.9);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fade-in 0.6s ease-out;
}

.create-box h2 {
  font-size: 1.6rem;
  color: #00e5ff;
  text-align: center;
  text-shadow:
    0 0 10px rgba(0, 229, 255, 0.6),
    0 0 30px rgba(0, 229, 255, 0.3);
}

.create-hint {
  color: #8899aa;
  font-size: 0.9rem;
  text-align: center;
}

.create-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.create-form label {
  color: #8899aa;
  font-size: 0.9rem;
}

.create-form input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 6px;
  outline: none;
  transition: all 0.3s ease;
}

.create-form input::placeholder {
  color: #556677;
}

.create-form input:focus {
  border-color: #00e5ff;
  box-shadow:
    0 0 10px rgba(0, 229, 255, 0.3),
    inset 0 0 10px rgba(0, 229, 255, 0.05);
}

#btn-roll,
#btn-confirm {
  padding: 0.8rem 2.5rem;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  color: #00e5ff;
  background: transparent;
  border: 2px solid #00e5ff;
  border-image: linear-gradient(135deg, #00e5ff, #6a5acd) 1;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
}

#btn-roll:hover,
#btn-confirm:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow:
    0 0 15px rgba(0, 229, 255, 0.5),
    0 0 30px rgba(0, 229, 255, 0.3),
    inset 0 0 15px rgba(0, 229, 255, 0.1);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

#btn-confirm {
  color: #7cff7c;
  border: 2px solid #7cff7c;
  border-image: linear-gradient(135deg, #7cff7c, #00e5ff) 1;
}

#btn-confirm:hover {
  background: rgba(124, 255, 124, 0.1);
  box-shadow:
    0 0 15px rgba(124, 255, 124, 0.5),
    0 0 30px rgba(124, 255, 124, 0.3),
    inset 0 0 15px rgba(124, 255, 124, 0.1);
  text-shadow: 0 0 10px rgba(124, 255, 124, 0.8);
}

.attr-preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.attr-name {
  width: 3em;
  color: #8899aa;
  font-size: 0.9rem;
  text-align: right;
  flex-shrink: 0;
}

.attr-bar {
  flex: 1;
  height: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.attr-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease-out;
}

.attr-bar-fill.level-terrible { background: linear-gradient(90deg, #ff3333, #cc2222); }
.attr-bar-fill.level-poor     { background: linear-gradient(90deg, #ff8800, #cc6600); }
.attr-bar-fill.level-normal   { background: linear-gradient(90deg, #ffdd00, #ccaa00); }
.attr-bar-fill.level-good     { background: linear-gradient(90deg, #00cc66, #009944); }
.attr-bar-fill.level-great    { background: linear-gradient(90deg, #00e5ff, #6a5acd); box-shadow: 0 0 8px rgba(0, 229, 255, 0.5); }

.attr-value {
  width: 2.5em;
  color: #ffffff;
  font-size: 0.9rem;
  text-align: right;
  flex-shrink: 0;
}

.attr-level {
  width: 3em;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.attr-level.level-terrible { color: #ff3333; }
.attr-level.level-poor     { color: #ff8800; }
.attr-level.level-normal   { color: #ffdd00; }
.attr-level.level-good     { color: #00cc66; }
.attr-level.level-great    { color: #00e5ff; }

/* === Game screen === */
.game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.status-bar {
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid rgba(0, 229, 255, 0.2);
  padding: 0.6rem 1rem;
  flex-shrink: 0;
}

.status-info {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: #ccddee;
}

.status-info #display-name {
  color: #00e5ff;
  font-weight: bold;
}

.status-info #display-stage {
  color: #ffdd00;
}

.attr-panel {
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.attr-panel .attr-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.attr-panel .attr-row > span:first-child {
  width: 3em;
  color: #8899aa;
  font-size: 0.85rem;
  text-align: right;
  flex-shrink: 0;
}

.attr-panel .bar {
  flex: 1;
  height: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.attr-panel .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease-out;
}

.attr-val {
  width: 2.5em;
  text-align: right;
  font-size: 0.85rem;
  color: #ffffff;
  flex-shrink: 0;
}

.resource-bar {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid rgba(0, 229, 255, 0.1);
  border-bottom: 1px solid rgba(0, 229, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.95rem;
  color: #ccddee;
  flex-shrink: 0;
}

.life-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.life-log::-webkit-scrollbar {
  width: 6px;
}

.life-log::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.life-log::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.3);
  border-radius: 3px;
}

.log-entry {
  color: #aabbcc;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-entry .log-age {
  color: #00e5ff;
  margin-right: 0.5em;
}

.action-bar {
  padding: 1rem;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(0, 229, 255, 0.2);
}

#btn-next-year {
  padding: 0.9rem 3rem;
  font-size: 1.2rem;
  font-family: 'Courier New', monospace;
  color: #00e5ff;
  background: transparent;
  border: 2px solid #00e5ff;
  border-image: linear-gradient(135deg, #00e5ff, #6a5acd) 1;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.1em;
}

#btn-next-year:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow:
    0 0 15px rgba(0, 229, 255, 0.5),
    0 0 30px rgba(0, 229, 255, 0.3),
    inset 0 0 15px rgba(0, 229, 255, 0.1);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

/* === Event overlay === */
.event-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.event-box {
  max-width: 500px;
  width: 90%;
  background: rgba(10, 10, 40, 0.95);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow:
    0 0 20px rgba(0, 229, 255, 0.2),
    0 0 60px rgba(0, 229, 255, 0.1);
}

.event-box h3 {
  font-size: 1.3rem;
  color: #00e5ff;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.event-box p {
  color: #ccddee;
  font-size: 0.95rem;
  line-height: 1.7;
  text-align: center;
}

.event-choices {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.event-choices button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.event-choices button:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: #00e5ff;
  box-shadow:
    0 0 10px rgba(0, 229, 255, 0.4),
    inset 0 0 10px rgba(0, 229, 255, 0.05);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.event-effect-text {
  color: #ffdd00 !important;
  font-size: 0.9rem !important;
  text-align: center;
  padding: 0.3rem 0;
}

@keyframes event-pop-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.event-pop {
  animation: event-pop-in 0.3s ease-out;
}

/* === Responsive === */
@media (max-width: 480px) {
  #screen-title h1 {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 0.9rem;
    padding: 0 1rem;
  }

  #btn-start {
    font-size: 1rem;
    padding: 0.7rem 2rem;
  }
}
