:root {
  --wood-bg: #8b5a2b;
  --wood-grain: #704214;
  --black-stone: #1a1a1a;
  --white-stone: #f0f0f0;
  --primary-color: oklch(0.6 0.15 250);
  --accent-color: oklch(0.7 0.2 150);
  --text-color: oklch(0.95 0.01 200);
  --bg-color: oklch(0.15 0.02 240);
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --board-size: min(85vw, 600px);
  --grid-size: 15;
  --modal-bg: rgba(0, 0, 0, 0.8);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3ExternalIcon %3Ffilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem;
  width: 100%;
  max-width: 1000px;
}

header h1 {
  font-size: 2.5rem;
  text-align: center;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#game-status {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

#game-layout {
  display: flex;
  gap: 2rem;
  width: 100%;
  justify-content: center;
  align-items: flex-start;
}

#board-area {
  flex-shrink: 0;
}

#board-container {
  padding: 20px;
  background-color: var(--wood-bg);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0,0,0,0.05) 40px, rgba(0,0,0,0.05) 80px),
    linear-gradient(to bottom, rgba(255,255,255,0.05), transparent);
}

#game-board {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-template-rows: repeat(var(--grid-size), 1fr);
  width: var(--board-size);
  height: var(--board-size);
  position: relative;
}

#game-board::before {
  content: '';
  position: absolute;
  top: calc(100% / var(--grid-size) / 2);
  left: calc(100% / var(--grid-size) / 2);
  right: calc(100% / var(--grid-size) / 2);
  bottom: calc(100% / var(--grid-size) / 2);
  background-image: 
    linear-gradient(to right, #333 1px, transparent 1px),
    linear-gradient(to bottom, #333 1px, transparent 1px);
  background-size: calc(100% / (var(--grid-size) - 1)) calc(100% / (var(--grid-size) - 1));
  pointer-events: none;
}

.cell {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

.cell:hover::after {
  content: '';
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px dashed rgba(255, 255, 255, 0.3);
}

.stone {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: min(2vw, 12px);
  font-weight: bold;
}

.stone.black {
  background: radial-gradient(circle at 30% 30%, #444, #000);
  color: rgba(255, 255, 255, 0.7);
}

.stone.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ddd);
  color: rgba(0, 0, 0, 0.7);
}

.stone.place-anim {
  animation: place-stone 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes place-stone {
  from { transform: scale(1.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Sidebar */
#sidebar {
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  height: var(--board-size);
}

#move-history {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

#history-list {
  flex-grow: 1;
  overflow-y: auto;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.9rem;
}

.history-item {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
}

.history-item span:first-child { opacity: 0.6; }

#view-controls {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

#view-controls button {
  width: 100%;
}

.small {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

.link-btn {
  background: transparent;
  color: var(--accent-color);
  text-decoration: underline;
  box-shadow: none;
  padding: 0;
  font-size: 0.9rem;
}

.link-btn:hover {
  color: var(--primary-color);
  background: transparent;
  transform: none;
  box-shadow: none;
}

button {
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.glow-on-hover:hover {
  box-shadow: 0 0 15px var(--primary-color);
  filter: brightness(1.1);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-bg);
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: #2a2a2a;
  margin: 10% auto;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 1.5rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: white;
  font-family: inherit;
}

.form-group textarea {
  height: 120px;
  resize: vertical;
}

@media (max-width: 900px) {
  #game-layout {
    flex-direction: column;
    align-items: center;
  }
  #sidebar {
    width: var(--board-size);
    height: auto;
  }
}
