:root {
  --primary-gradient: linear-gradient(180deg, #ff9f43, #ff6b6b);
  --bg-gradient: linear-gradient(to bottom, #e0f7fa 0%, #b2ebf2 100%);
  --wheel-rim: #ff7f50;
  --wheel-rim-inner: #ffa502;
  --text-color: #5d4037;
  --accent-color: #ff6b6b;
  --btn-shadow: #c0392b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Kanit", "Outfit", sans-serif;
  min-height: 100vh;
  background: transparent;
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative; /* For mascot positioning */
}

/* Background decorations removed */

.main-container {
  text-align: center;
  padding: 2rem;
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 10;
}

header h1 {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #ff6b6b;
  text-shadow: 2px 2px 0px white, 4px 4px 0px rgba(0, 0, 0, 0.1);
  -webkit-text-stroke: 1px white;
}

header p {
  font-size: 1.3rem;
  color: #5d4037;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.6);
  padding: 5px 15px;
  border-radius: 20px;
  display: inline-block;
}

.logo {
  max-width: 100%; /* Responsive width */
  height: auto; /* Maintain aspect ratio */
  max-height: 200px; /* Adjust as needed */
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  position: relative;
}

.wheel-container {
  position: relative;
  width: 90vw;
  max-width: 480px;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px; /* Space for shadow/glow */
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  /* Canvas dropshadow handled by logic now, or keep subtle one here */
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
  transition: transform 0.1s;
}

.pointer {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 60px;
  background: linear-gradient(
    to bottom,
    #f1c40f,
    #f39c12
  ); /* Golden for a premium look */
  clip-path: polygon(20% 0%, 80% 0%, 100% 20%, 50% 100%, 0% 20%);
  filter: drop-shadow(0 4px 0px #d35400)
    drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3)); /* 3D effect + shadow */
  z-index: 20;
  /* Simple CSS triangle pointer fallback/decoration */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5px;
}
.pointer::after {
  content: "▼";
  font-size: 1.5rem;
  color: white;
  display: none; /* Hiding text pointer, using shape */
}

.wheel-shadow {
  position: absolute;
  bottom: -20px;
  width: 60%;
  height: 20px;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0) 70%
  );
  z-index: -1;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 20; /* Above mascot */
}

.spin-button {
  background: linear-gradient(to bottom, #ffeb3b, #fbc02d);
  border: 4px solid white;
  padding: 1rem 3rem;
  font-size: 2rem;
  font-weight: 800;
  color: #e65100;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 0 #f57f17, 0 15px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.1s;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.spin-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 #f57f17, 0 20px 25px rgba(0, 0, 0, 0.2);
  filter: brightness(1.1);
}

.spin-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #f57f17, 0 5px 10px rgba(0, 0, 0, 0.2);
}

.spin-button:disabled {
  background: #bdbdbd;
  color: #757575;
  box-shadow: 0 4px 0 #9e9e9e;
  cursor: not-allowed;
  transform: none;
}

.result-display {
  font-size: 1.8rem;
  min-height: 2.5rem;
  font-weight: 700;
  color: #d35400;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 30px;
  border-radius: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Mascot Removed */

@media (min-width: 768px) {
  .game-area {
    margin-top: 2rem;
  }
}

/* --- Management System Styles --- */

/* Settings Button */
.settings-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: white;
  border: 2px solid #ddd;
  color: #555;
  font-size: 1.5rem;
  padding: 0.5rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
}

.settings-btn:hover {
  transform: rotate(90deg);
  border-color: #aaa;
  color: #333;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  background: #ffffff;
  padding: 2rem;
  border-radius: 20px;
  width: 95%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  color: #333;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 0.8rem;
  flex-shrink: 0;
}

.modal-header h2 {
  color: #ff6b6b;
}

.close-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover {
  color: #ff6b6b;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  overflow-y: auto;
  padding-right: 5px; /* Prevent scrollbar overlap content */
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

.settings-group label {
  font-weight: bold;
  color: #555;
}

.settings-group input {
  padding: 0.8rem;
  border-radius: 8px;
  border: 2px solid #eee;
  background: #fafafa;
  color: #333;
  font-family: inherit;
}
.settings-group input:focus {
  outline: none;
  border-color: #ff6b6b;
}

.segments-list-container h3 {
  text-align: left;
  color: #555;
  margin-bottom: 0.5rem;
}

.segments-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  gap: 0.5rem;
  overflow-y: auto;
  /* Let the modal body scroll instead if needed, or keep this internal scroll */
  max-height: 200px;
  margin-bottom: 0.5rem;
  padding-right: 5px;
}

.segment-item {
  display: grid;
  grid-template-columns: 30px 2fr 1fr 1fr 30px;
  gap: 0.5rem;
  align-items: center;
  background: #f9f9f9;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #eee;
}

.segment-item input {
  width: 100%;
  padding: 0.4rem;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.color-preview {
  width: 100%;
  height: 35px;
  border: none;
  cursor: pointer;
  padding: 0;
  background: none;
}

.remove-segment-btn {
  background: #ff6b6b;
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 2px 0 #d32f2f;
}
.remove-segment-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.add-btn {
  width: 100%;
  padding: 0.8rem;
  background: #e0f2f1;
  border: 2px dashed #4db6ac;
  color: #00897b;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.add-btn:hover {
  background: #b2dfdb;
}

.settings-actions,
.saved-wheels-section {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 2px solid #f0f0f0;
}

.saved-wheels-section h3 {
  width: 100%;
  text-align: left;
  color: #555;
}

.action-btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  background: #eee;
  color: #555;
  transition: all 0.2s;
}

.action-btn.primary {
  background: #ff9f43;
  color: white;
  box-shadow: 0 2px 5px rgba(255, 159, 67, 0.4);
}
.action-btn.danger {
  background: #ef5350;
  color: white;
}
.action-btn:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

select {
  padding: 0.7rem;
  border-radius: 8px;
  background: #fafafa;
  color: #333;
  border: 2px solid #eee;
  flex-grow: 1;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}
