*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #f0f7ff 0, #e4ecff 30%, #f7f7ff 70%, #fdfdfd 100%);
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  padding: 2rem 2rem 1.5rem;
  background: linear-gradient(120deg, #2f80ed, #56ccf2);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.top-bar h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.top-bar p {
  font-size: 1.4rem;
  opacity: 0.95;
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(400px, 800px) minmax(350px, 600px);
  gap: 2rem;
  padding: 2rem;
}

.board-panel,
.control-panel {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.2rem 1.3rem 1.3rem;
  box-shadow: 0 8px 20px rgba(15, 35, 52, 0.08);
}

.board-header h2,
.control-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.board-subtitle,
.instructions {
  font-size: 1.2rem;
  color: #555;
}

.board {
  margin-top: 1rem;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #d8e2ff;
  border-radius: 12px;
  padding: 15px;
}

.tile {
  position: relative;
  border-radius: 9px;
  background: #f4f6ff;
  border: 1px solid #d4dcff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s;
  min-height: 0;
  aspect-ratio: 1 / 1;
}

.tile-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  border-radius: 9px;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0.7;
  pointer-events: none;
}

.tile-start {
  background: #e8fff1;
  border-color: #8bd5b3;
}

.tile-start::before {
  content: "BAŞLANGIÇ";
  position: absolute;
  bottom: 0.3rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #2e7d32;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  z-index: 1;
  white-space: nowrap;
}

.tile-goal {
  background: #fff3d9;
  border-color: #f5b947;
}

.tile-obstacle {
  background: repeating-linear-gradient(
    135deg,
    #ffd6d6,
    #ffd6d6 6px,
    #ffb4b4 6px,
    #ffb4b4 12px
  );
  border-color: #ff8a8a;
}

.tile-obstacle::before {
  content: "X";
  position: relative;
  font-weight: 700;
  color: #c62828;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  z-index: 1;
}

.info-panel {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  font-size: 1.3rem;
}

.info-item .label {
  font-weight: 600;
  margin-right: 0.25rem;
}

.info-item .value {
  font-family: "Consolas", "Fira Code", monospace;
  background: #f3f6ff;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #d3ddff;
}

.states-section {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: #f9f9ff;
  border-radius: 12px;
  border: 1px solid #e1e4ff;
}

.states-section h3 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
  color: #283593;
}

.state-buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.state-btn {
  padding: 1rem 2rem;
  border-radius: 999px;
  background: #4caf50;
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 1.4rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.35);
}

.state-btn:hover {
  background: #45a049;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(76, 175, 80, 0.4);
}

.state-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.35);
}

.state-btn-active {
  background: #2e7d32 !important;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.5) !important;
  transform: scale(1.08);
  border: 3px solid #1b5e20;
  font-weight: 700;
  position: relative;
}

.state-btn-active::before {
  content: "✓";
  position: absolute;
  left: 0.5rem;
  font-size: 1.2rem;
}

.buttons-row {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.6rem;
  align-items: center;
}

.buttons-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

button {
  border: none;
  cursor: pointer;
  font: inherit;
}

.cmd-btn {
  padding: 1.2rem 1.5rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #1a237e;
  border: 1px solid #c5cae9;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  font-size: 2.5rem;
  line-height: 1;
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cmd-turn-left {
  font-size: 3rem;
  /* Trafik sembolü - hareket yok */
}

.cmd-turn-right {
  font-size: 3rem;
  /* Trafik sembolü - hareket yok */
}

.cmd-turn-left:hover {
  /* Hareket yok, sadece arka plan değişir */
}

.cmd-turn-right:hover {
  /* Hareket yok, sadece arka plan değişir */
}

.cmd-btn:hover {
  background: #dde3ff;
  box-shadow: 0 2px 6px rgba(33, 46, 100, 0.25);
}

.cmd-forward:hover,
.cmd-backward:hover {
  transform: translateY(-1px);
}

.cmd-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.command-list-panel {
  margin-top: 1.2rem;
  border-radius: 12px;
  border: 1px solid #e1e4ff;
  background: #f9f9ff;
  padding: 0.8rem 0.9rem;
}

.command-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.command-list-header h3 {
  font-size: 1rem;
}

.command-list-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 600;
}

.primary-btn {
  background: #2f80ed;
  color: #fff;
  box-shadow: 0 2px 6px rgba(47, 128, 237, 0.35);
}

.primary-btn:hover {
  background: #266cd1;
}

.secondary-btn {
  background: #ffffff;
  border: 1px solid #cfd8ff;
  color: #283593;
}

.secondary-btn:hover {
  background: #eef2ff;
}

.command-list {
  margin-top: 0.6rem;
  padding-left: 1.3rem;
  max-height: 300px;
  overflow-y: auto;
  font-size: 1.3rem;
}

.command-list li {
  padding: 0.15rem 0.1rem;
}

.command-list li.running {
  background: #e3f2fd;
  border-radius: 6px;
}

.command-list li.done {
  color: #4caf50;
}

.message-box {
  margin-top: 0.8rem;
  min-height: 2rem;
  font-size: 1.2rem;
}

.message-box.ok {
  color: #2e7d32;
}

.message-box.error {
  color: #c62828;
}

.message-box.info {
  color: #1565c0;
}

.page-footer {
  padding: 0.8rem 1.5rem 1.1rem;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
}

/* Robot görseli - Üstten görünüm */
.robot {
  position: relative;
  width: 70%;
  max-width: 80px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  transition: transform 0.18s ease-out;
  z-index: 3;
}

.robot-body {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #808080, #5a5a5a);
  border: 2px solid #404040;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 2px 8px rgba(64, 64, 64, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.robot-body::before {
  content: "";
  position: absolute;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, #909090 0%, #707070 100%);
  border-radius: 50%;
  opacity: 0.6;
}

/* Tekerlekler */
.robot-body::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: 
    /* Sol üst tekerlek */
    radial-gradient(circle at 15% 15%, #2a2a2a 0%, #2a2a2a 25%, transparent 25%),
    /* Sağ üst tekerlek */
    radial-gradient(circle at 85% 15%, #2a2a2a 0%, #2a2a2a 25%, transparent 25%),
    /* Sol alt tekerlek */
    radial-gradient(circle at 15% 85%, #2a2a2a 0%, #2a2a2a 25%, transparent 25%),
    /* Sağ alt tekerlek */
    radial-gradient(circle at 85% 85%, #2a2a2a 0%, #2a2a2a 25%, transparent 25%);
  background-size: 30% 30%;
  background-repeat: no-repeat;
  background-position: 
    0% 0%,
    100% 0%,
    0% 100%,
    100% 100%;
  pointer-events: none;
}

.robot-front {
  position: absolute;
  width: 0;
  height: 0;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.robot-front::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid #ffd700;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.robot-front::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 12px;
  background: #ffd700;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Yönlere göre dönüş açıları (JS ile sınıf veya style atanacaksa da kullanılabilir) */
.dir-north {
  transform: rotate(0deg);
}

.dir-east {
  transform: rotate(90deg);
}

.dir-south {
  transform: rotate(180deg);
}

.dir-west {
  transform: rotate(270deg);
}

@media (max-width: 820px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .board {
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 480px) {
  .top-bar {
    padding-inline: 1rem;
  }

  .game-layout {
    padding: 1rem;
  }

  .command-list-actions {
    justify-content: flex-start;
  }
}

/* Feedback Modal */
.feedback-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.3s ease;
}

.feedback-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-modal-content {
  position: relative;
  background-color: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.feedback-image {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 8px;
}

.feedback-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 2rem;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.feedback-modal-close:hover {
  color: #000;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}


