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

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #ffffff;
  overflow: hidden;
}

#app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 10px 0;
  max-width: 500px;
  margin: 0 auto;
}

.header {
  width: 100%;
  text-align: center;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.toolbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.btn:active {
  transform: scale(0.95);
  background: #eee;
}

.btn.primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn.primary:active {
  background: #555;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tools {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
  width: 100%;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  min-width: 70px;
}

.tool-btn:active {
  transform: scale(0.95);
  background: #eee;
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-btn .tool-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.tool-btn .tool-count {
  font-size: 10px;
  color: #999;
}

.wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 10px 0;
}

.container {
  position: relative;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 16px;
  overflow: hidden;
}

.card-wrap {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  width: 40px;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.card {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #f0f0f0;
}

.card span {
  opacity: 0.4;
  font-size: 20px;
}

.is-allow {
  background: #ffffff;
  border-color: #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.is-allow span {
  opacity: 1;
}

@keyframes scaleDraw {
  0% {
    transform: scale(1.1);
  }
  20% {
    transform: scale(1);
  }
  100% {
    transform: scale(0);
  }
}

.slot-area {
  width: 100%;
  padding: 10px 0;
}

.card-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: 4px;
  height: 50px;
  width: 100%;
  max-width: 320px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  background: #fafafa;
  gap: 2px;
}

.slot-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  transition: all 0.2s;
}

.slot-card.clearing {
  animation: scaleDraw 400ms forwards;
}

.aside-area {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  justify-content: center;
}

.aside-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px dashed #ccc;
  border-radius: 8px;
  background: #fefefe;
  font-size: 20px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 30px 24px;
  text-align: center;
  max-width: 300px;
  width: 80%;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: #333;
}

.modal p {
  font-size: 14px;
  color: #666;
  margin-bottom: 20px;
}

.modal .btn {
  padding: 10px 30px;
  font-size: 14px;
}

.level-select {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.level-select h1 {
  font-size: 22px;
  font-weight: 600;
  color: #333;
  margin-bottom: 24px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 350px;
  width: 100%;
}

.level-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  border-radius: 12px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.level-item:active {
  transform: scale(0.95);
}

.level-item.locked {
  color: #ccc;
  cursor: not-allowed;
}

.level-item.current {
  background: #333;
  color: #fff;
  border-color: #333;
}

@media (max-width: 400px) {
  .card-wrap {
    height: 36px;
    width: 36px;
  }
  .card {
    width: 32px;
    height: 32px;
  }
  .card span {
    font-size: 18px;
  }
  .slot-card {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .aside-card {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
}
