:root {
  --accent: #2f6fed;
  --accent-light: #eaf1ff;
  --border: #d7dce3;
  --bg: #f7f8fa;
  --panel-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --correct: #2e9e5b;
  --incorrect: #e0483f;
  --cell-size: 40px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Pretendard", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 20px;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

.panel { display: none; }
.panel.active { display: block; }

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

#entry-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

#entry-table th, #entry-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#entry-table th { background: #f0f2f5; font-size: 13px; color: var(--muted); }

#entry-table input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.row-num { width: 32px; color: var(--muted); font-size: 13px; padding-top: 14px; }
.row-del { width: 40px; text-align: center; }

.row-del button {
  border: none;
  background: none;
  color: var(--incorrect);
  cursor: pointer;
  font-size: 16px;
}

.row-actions { margin: 10px 0; }

button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

button:hover { background: #f0f2f5; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover { background: #2559c7; }

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.file-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  position: relative;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.status {
  min-height: 20px;
  font-size: 13px;
  color: var(--incorrect);
}

.puzzle-meta {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.puzzle-layout {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.grid-container {
  display: grid;
  gap: 2px;
  background: var(--border);
  border: 2px solid var(--text);
  width: fit-content;
}

.cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  background: #fff;
}

.cell.blocked {
  background: var(--text);
}

.cell input {
  width: 100%;
  height: 100%;
  border: none;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  background: transparent;
  outline: none;
  caret-color: var(--accent);
}

.cell .cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.cell.active-word input { background: var(--accent-light); }
.cell.active-cell input { background: #cfe0ff; }

.cell input.correct { color: var(--correct); }
.cell input.incorrect { background: #ffe4e1; }

.clues {
  display: flex;
  gap: 32px;
  min-width: 260px;
  flex: 1;
}

.clue-group h2 {
  font-size: 15px;
  margin: 0 0 8px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}

.clue-group ol {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.7;
}

.clue-group li {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.clue-group li.active-clue {
  background: var(--accent-light);
  font-weight: 600;
}

.play-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-result {
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 640px) {
  main { padding: 14px; }
  .puzzle-layout { flex-direction: column; }
  :root { --cell-size: 32px; }
}
